|
6 | 6 | <#+ |
7 | 7 | public class TypeConfiguration |
8 | 8 | { |
9 | | - public TypeConfiguration(string typeName, string classPrefix = null, string oneLiteral = "1", string zeroLiteral = "0", bool supportsNumeric = true, bool supportsBitwise = true, IEnumerable<string> unsupportedMethods = null) |
| 9 | + public TypeConfiguration(string typeName, string classPrefix = null, string oneLiteral = "1", string zeroLiteral = "0", bool supportsNumeric = true, bool supportsBitwise = true, IEnumerable<string> unsupportedMethods = null, bool supportsVectorization = false) |
10 | 10 | { |
11 | 11 | TypeName = typeName; |
12 | 12 | ClassPrefix = classPrefix ?? char.ToUpper(typeName[0]) + typeName.Substring(1); |
13 | 13 | OneLiteral = oneLiteral; |
14 | 14 | ZeroLiteral = zeroLiteral; |
15 | 15 | SupportsNumeric = supportsNumeric; |
16 | 16 | SupportsBitwise = supportsBitwise; |
| 17 | + SupportsVectorization = supportsVectorization; |
17 | 18 | UnsupportedMethods = new HashSet<string>(unsupportedMethods ?? Enumerable.Empty<string>()); |
18 | 19 | } |
19 | 20 |
|
|
24 | 25 |
|
25 | 26 | public bool SupportsNumeric { get; } |
26 | 27 | public bool SupportsBitwise { get; } |
27 | | - public ISet<string> UnsupportedMethods { get; } |
28 | | - } |
| 28 | + public bool SupportsVectorization { get; } |
29 | 29 |
|
30 | | - public string GenerateInPlaceStatement(string trueCondition, string falseCondition) |
31 | | - { |
32 | | - return $"inPlace ? {trueCondition} : {falseCondition}"; |
| 30 | + public ISet<string> UnsupportedMethods { get; } |
33 | 31 | } |
34 | | - |
| 32 | + |
35 | 33 | public string GenerateIfStatementHeader(TypeConfiguration type) |
36 | 34 | { |
37 | 35 | string keyword = (type == typeConfiguration[0]) ? "if" : "else if"; |
|
139 | 137 | public TypeConfiguration[] typeConfiguration = new [] |
140 | 138 | { |
141 | 139 | new TypeConfiguration("bool", oneLiteral:"true", zeroLiteral:"false", supportsNumeric: false, unsupportedMethods: new[] {"LeftShift", "RightShift"}), |
142 | | - new TypeConfiguration("byte", unsupportedMethods: new[] {"All", "Any"}), |
143 | | - new TypeConfiguration("char", oneLiteral:"(char)1", zeroLiteral:"(char)0", unsupportedMethods: new[] {"All", "Any"}), |
| 140 | + new TypeConfiguration("byte", unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 141 | + new TypeConfiguration("char", oneLiteral:"(char)1", zeroLiteral:"(char)0", unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
144 | 142 | new TypeConfiguration("decimal", supportsBitwise: false, unsupportedMethods: new[] {"All", "Any"}), |
145 | | - new TypeConfiguration("double", oneLiteral:"1.0", supportsBitwise: false, unsupportedMethods: new[] {"All", "Any"}), |
146 | | - new TypeConfiguration("float", oneLiteral:"1.0f", supportsBitwise: false, unsupportedMethods: new[] {"All", "Any"}), |
147 | | - new TypeConfiguration("int", unsupportedMethods: new[] {"All", "Any"}), |
148 | | - new TypeConfiguration("long", unsupportedMethods: new[] {"All", "Any"}), |
149 | | - new TypeConfiguration("sbyte", classPrefix:"SByte", unsupportedMethods: new[] {"All", "Any"}), |
150 | | - new TypeConfiguration("short", unsupportedMethods: new[] {"All", "Any"}), |
151 | | - new TypeConfiguration("uint", classPrefix:"UInt", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}), |
152 | | - new TypeConfiguration("ulong", classPrefix:"ULong", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}), |
153 | | - new TypeConfiguration("ushort", classPrefix:"UShort", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}), |
| 143 | + new TypeConfiguration("double", oneLiteral:"1.0", supportsBitwise: false, unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 144 | + new TypeConfiguration("float", oneLiteral:"1.0f", supportsBitwise: false, unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 145 | + new TypeConfiguration("int", unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 146 | + new TypeConfiguration("long", unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 147 | + new TypeConfiguration("sbyte", classPrefix:"SByte", unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 148 | + new TypeConfiguration("short", unsupportedMethods: new[] {"All", "Any"}, supportsVectorization: true), |
| 149 | + new TypeConfiguration("uint", classPrefix:"UInt", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}, supportsVectorization: true), |
| 150 | + new TypeConfiguration("ulong", classPrefix:"ULong", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}, supportsVectorization: true), |
| 151 | + new TypeConfiguration("ushort", classPrefix:"UShort", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}, supportsVectorization: true), |
154 | 152 | new TypeConfiguration("DateTime", supportsBitwise: false, supportsNumeric: false, unsupportedMethods: new[] {"And", "Or", "Xor"}) |
155 | 153 | }; |
156 | 154 |
|
|
227 | 225 | new MethodConfiguration("Sum", MethodType.Reduction, "+", isNumeric:true, hasReturnValue:true, supportsRowSubsets: true, methodComments: "Returns the sum of the values at the rowIndices"), |
228 | 226 | new MethodConfiguration("Round", MethodType.ElementwiseComputation, "Math.Round", isNumeric:true, methodComments: "Calls Math.Round on each value in a column"), |
229 | 227 | }; |
230 | | - |
| 228 | + |
231 | 229 | public MethodConfiguration[] methodConfiguration = new [] |
232 | 230 | { |
233 | | - new MethodConfiguration("Add", MethodType.Binary, "+", isNumeric:true, methodComments: "Performs element-wise addition"), |
| 231 | + new MethodConfiguration("Add", MethodType.Binary, "+", isNumeric:true, methodComments: "Performs element-wise addition", supportsVectorization: true), |
234 | 232 | new MethodConfiguration("Add", MethodType.BinaryScalar, "+", isNumeric:true, methodComments: "Performs an element-wise addition on each column"), |
235 | | - new MethodConfiguration("Subtract", MethodType.Binary, "-", isNumeric:true, methodComments: "Performs element-wise subtraction"), |
| 233 | + new MethodConfiguration("Subtract", MethodType.Binary, "-", isNumeric:true, methodComments: "Performs element-wise subtraction", supportsVectorization: true), |
236 | 234 | new MethodConfiguration("Subtract", MethodType.BinaryScalar, "-", isNumeric:true, methodComments: "Performs an element-wise subtraction on each column"), |
237 | | - new MethodConfiguration("Multiply", MethodType.Binary, "*", isNumeric:true, methodComments: "Performs element-wise multiplication"), // element-wise product, not matrix product |
| 235 | + new MethodConfiguration("Multiply", MethodType.Binary, "*", isNumeric:true, methodComments: "Performs element-wise multiplication", supportsVectorization: true), |
238 | 236 | new MethodConfiguration("Multiply", MethodType.BinaryScalar, "*", isNumeric:true, methodComments: "Performs an element-wise multiplication on each column"), |
239 | | - new MethodConfiguration("Divide", MethodType.Binary, "/", isNumeric:true, methodComments: "Performs element-wise division"), |
| 237 | + new MethodConfiguration("Divide", MethodType.Binary, "/", isNumeric:true, methodComments: "Performs element-wise division", supportsVectorization: true), |
240 | 238 | new MethodConfiguration("Divide", MethodType.BinaryScalar, "/", isNumeric:true, methodComments: "Performs an element-wise division on each column"), |
241 | 239 | new MethodConfiguration("Modulo", MethodType.Binary, "%", isNumeric:true, methodComments: "Performs element-wise modulus"), |
242 | 240 | new MethodConfiguration("Modulo", MethodType.BinaryScalar, "%", isNumeric:true, methodComments: "Performs an element-wise modulus operation on each column"), |
|
265 | 263 |
|
266 | 264 | public class MethodConfiguration |
267 | 265 | { |
268 | | - public MethodConfiguration(string methodName, MethodType methodType, string op = null, bool isNumeric = false, bool isBitwise = false, bool hasReturnValue = false, bool supportsRowSubsets = false, string methodComments = null) |
| 266 | + public MethodConfiguration(string methodName, MethodType methodType, string op = null, bool isNumeric = false, bool isBitwise = false, bool hasReturnValue = false, bool supportsRowSubsets = false, string methodComments = null, bool supportsVectorization = false) |
269 | 267 | { |
270 | 268 | MethodName = methodName; |
271 | 269 | MethodType = methodType; |
|
275 | 273 | HasReturnValue = hasReturnValue; |
276 | 274 | SupportsRowSubsets = supportsRowSubsets; |
277 | 275 | MethodComments = methodComments; |
| 276 | + SupportsVectorization = supportsVectorization; |
278 | 277 | } |
279 | 278 |
|
280 | 279 | public string ResultName => "result"; |
|
330 | 329 | public MethodType MethodType { get; } |
331 | 330 | public string Operator { get; } |
332 | 331 | public string MethodComments { get; } |
333 | | - |
| 332 | + public bool SupportsVectorization { get; } |
334 | 333 | public string GetColumnSpecificMethodComments() |
335 | 334 | { |
336 | 335 | var str = MethodComments; |
|
0 commit comments