Changeset 6755 for trunk/sources
- Timestamp:
- 09/13/11 17:38:29 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r6741 r6755 44 44 private static MethodInfo log = typeof(Math).GetMethod("Log", new Type[] { typeof(double) }); 45 45 private static MethodInfo power = typeof(Math).GetMethod("Pow", new Type[] { typeof(double), typeof(double) }); 46 private static MethodInfo round = typeof(Math).GetMethod("Round", new Type[] { typeof(double) }); 46 47 47 48 internal delegate double CompiledFunction(int sampleIndex, IList<double>[] columns); … … 340 341 CompileInstructions(il, state); 341 342 CompileInstructions(il, state); 343 il.Emit(System.Reflection.Emit.OpCodes.Call, round); 342 344 il.Emit(System.Reflection.Emit.OpCodes.Call, power); 343 345 return; 344 346 } 345 347 case OpCodes.Root: { 346 throw new NotImplementedException(); 348 CompileInstructions(il, state); 349 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0); // 1 / round(...) 350 CompileInstructions(il, state); 351 il.Emit(System.Reflection.Emit.OpCodes.Call, round); 352 il.Emit(System.Reflection.Emit.OpCodes.Div); 353 il.Emit(System.Reflection.Emit.OpCodes.Call, power); 354 return; 347 355 } 348 356 case OpCodes.Exp: { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r6735 r6755 276 276 Evaluate(interpreter, ds, "(log -3.0)", 0, Math.Log(-3)); 277 277 278 // power 279 Evaluate(interpreter, ds, "(pow 2.0 3.0)", 0, 8.0); 280 Evaluate(interpreter, ds, "(pow 4.0 0.5)", 0, 1.0); // interpreter should round to the nearest integer value value (.5 is rounded to the even number) 281 Evaluate(interpreter, ds, "(pow 4.0 2.5)", 0, 16.0); // interpreter should round to the nearest integer value value (.5 is rounded to the even number) 282 Evaluate(interpreter, ds, "(pow -2.0 3.0)", 0, -8.0); 283 Evaluate(interpreter, ds, "(pow 2.0 -3.0)", 0, 1.0 / 8.0); 284 Evaluate(interpreter, ds, "(pow -2.0 -3.0)", 0, -1.0 / 8.0); 285 286 // root 287 Evaluate(interpreter, ds, "(root 9.0 2.0)", 0, 3.0); 288 Evaluate(interpreter, ds, "(root 27.0 3.0)", 0, 3.0); 289 Evaluate(interpreter, ds, "(root 2.0 -3.0)", 0, Math.Pow(2.0, -1.0 / 3.0)); 290 278 291 // mean 279 292 Evaluate(interpreter, ds, "(mean -1.0 1.0 -1.0)", 0, -1.0 / 3.0);
Note: See TracChangeset
for help on using the changeset viewer.