Changeset 16287 for trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 11/08/18 16:55:30 (6 years ago)
- Location:
- trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r16286 r16287 117 117 </Reference> 118 118 <Reference Include="System.Drawing" /> 119 <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">120 <HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\portable-net45+win8+wp8+wpa81\System.Numerics.Vectors.dll</HintPath>121 </Reference>122 119 <Reference Include="System.Xml.Linq"> 123 120 <RequiredTargetFramework>3.5</RequiredTargetFramework> … … 165 162 <Compile Include="Interfaces\IVariableSymbol.cs" /> 166 163 <Compile Include="Interpreter\BatchInstruction.cs" /> 167 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" />168 164 <Compile Include="Interpreter\BatchOperations.cs" /> 169 165 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs" /> 166 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" /> 170 167 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" /> 171 168 <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" /> … … 283 280 <Compile Include="TreeMatching\SymbolicExpressionTreePhenotypicSimilarityCalculator.cs" /> 284 281 <None Include="HeuristicLab.snk" /> 285 <None Include="packages.config" />286 282 <None Include="Plugin.cs.frame" /> 287 283 <None Include="Properties\AssemblyInfo.cs.frame" /> -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs
r16285 r16287 1 1 using System; 2 using System.Numerics;3 2 4 3 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 5 4 public static class BatchOperations { 6 5 public const int BATCHSIZE = 64; 7 private static readonly int STRIDE = Vector<double>.Count;8 6 9 7 public static void Load(double[] a, double[] b) { … … 12 10 13 11 public static void Add(double[] a, double[] b) { 14 for (int i = 0; i < BATCHSIZE; i += STRIDE) { 15 var va = new Vector<double>(a, i); 16 var vb = new Vector<double>(b, i); 17 (va + vb).CopyTo(a, i); 12 for (int i = 0; i < BATCHSIZE; ++i) { 13 a[i] += b[i]; 18 14 } 19 15 } 20 16 21 17 public static void Sub(double[] a, double[] b) { 22 for (int i = 0; i < BATCHSIZE; i += STRIDE) { 23 var va = new Vector<double>(a, i); 24 var vb = new Vector<double>(b, i); 25 (va - vb).CopyTo(a, i); 18 for (int i = 0; i < BATCHSIZE; ++i) { 19 a[i] -= b[i]; 26 20 } 27 21 } 28 22 29 23 public static void Div(double[] a, double[] b) { 30 for (int i = 0; i < BATCHSIZE; i += STRIDE) { 31 var va = new Vector<double>(a, i); 32 var vb = new Vector<double>(b, i); 33 (va / vb).CopyTo(a, i); 24 for (int i = 0; i < BATCHSIZE; ++i) { 25 a[i] /= b[i]; 34 26 } 35 27 } 36 28 37 29 public static void Mul(double[] a, double[] b) { 38 for (int i = 0; i < BATCHSIZE; i += STRIDE) { 39 var va = new Vector<double>(a, i); 40 var vb = new Vector<double>(b, i); 41 (va * vb).CopyTo(a, i); 30 for (int i = 0; i < BATCHSIZE; ++i) { 31 a[i] *= b[i]; 42 32 } 43 33 } 44 34 45 35 public static void Neg(double[] a, double[] b) { 46 for (int i = 0; i < BATCHSIZE; i += STRIDE) { 47 var vb = new Vector<double>(b, i); 48 Vector.Negate(vb).CopyTo(a, i); 36 for (int i = 0; i < BATCHSIZE; ++i) { 37 a[i] = -b[i]; 49 38 } 50 39 } 51 40 52 41 public static void Inv(double[] a, double[] b) { 53 for (int i = 0; i < BATCHSIZE; i += STRIDE) { 54 var vb = new Vector<double>(b, i); 55 (Vector<double>.One / vb).CopyTo(a, i); 42 for (int i = 0; i < BATCHSIZE; ++i) { 43 a[i] = 1 / b[i]; 56 44 } 57 45 } -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r16285 r16287 161 161 } 162 162 163 code[i].buf = new double[BATCHSIZE]; 164 163 165 if (node is VariableTreeNode variable) { 164 166 code[i].weight = variable.Weight; 165 167 code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray(); 166 code[i].buf = new double[BATCHSIZE];167 168 } else if (node is ConstantTreeNode constant) { 168 169 code[i].value = constant.Value; 169 code[i].buf = Enumerable.Repeat(code[i].value, BATCHSIZE).ToArray(); 170 } else if (node.SubtreeCount > 0) { 171 code[i].buf = new double[BATCHSIZE]; 170 for (int j = 0; j < BATCHSIZE; ++j) 171 code[i].buf[j] = code[i].value; 172 172 } 173 173
Note: See TracChangeset
for help on using the changeset viewer.