Changeset 7708 for trunk/sources
- Timestamp:
- 04/05/12 11:54:07 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7697 r7708 137 137 strBuilder.Append(@"\operatorname{expInt}_i \left( "); 138 138 } else if (node.Symbol is FresnelCosineIntegral) { 139 strBuilder.Append(@"\operatorname{fresnel}_\operator Name{cosInt} \left( ");139 strBuilder.Append(@"\operatorname{fresnel}_\operatorname{cosInt} \left( "); 140 140 } else if (node.Symbol is FresnelSineIntegral) { 141 strBuilder.Append(@"\operatorname{fresnel}_\operator Name{sinInt} \left( ");141 strBuilder.Append(@"\operatorname{fresnel}_\operatorname{sinInt} \left( "); 142 142 } else if (node.Symbol is Gamma) { 143 143 strBuilder.Append(@"\Gamma \left( "); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r7506 r7708 35 35 [StorableClass] 36 36 [Item("SymbolicDataAnalysisExpressionTreeILEmittingInterpreter", "Interpreter for symbolic expression trees.")] 37 public sealed class SymbolicDataAnalysisExpressionTreeILEmittingInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter { 38 private static MethodInfo listGetValue = typeof(IList<double>).GetProperty("Item", new Type[] { typeof(int) }).GetGetMethod(); 37 public sealed class SymbolicDataAnalysisExpressionTreeILEmittingInterpreter : ParameterizedNamedItem, 38 ISymbolicDataAnalysisExpressionTreeInterpreter { 39 private static MethodInfo listGetValue = 40 typeof(IList<double>).GetProperty("Item", new Type[] { typeof(int) }).GetGetMethod(); 41 39 42 private static MethodInfo cos = typeof(Math).GetMethod("Cos", new Type[] { typeof(double) }); 40 43 private static MethodInfo sin = typeof(Math).GetMethod("Sin", new Type[] { typeof(double) }); … … 44 47 private static MethodInfo power = typeof(Math).GetMethod("Pow", new Type[] { typeof(double), typeof(double) }); 45 48 private static MethodInfo round = typeof(Math).GetMethod("Round", new Type[] { typeof(double) }); 49 private static MethodInfo sqrt = typeof(Math).GetMethod("Sqrt", new Type[] { typeof(double) }); 50 51 private static Type thisType = typeof(SymbolicDataAnalysisExpressionTreeILEmittingInterpreter); 52 private static MethodInfo airyA = thisType.GetMethod("AiryA", new Type[] { typeof(double) }); 53 private static MethodInfo airyB = thisType.GetMethod("AiryB", new Type[] { typeof(double) }); 54 private static MethodInfo gamma = thisType.GetMethod("Gamma", new Type[] { typeof(double) }); 55 private static MethodInfo psi = thisType.GetMethod("Psi", new Type[] { typeof(double) }); 56 private static MethodInfo dawson = thisType.GetMethod("Dawson", new Type[] { typeof(double) }); 57 private static MethodInfo expIntegralEi = thisType.GetMethod("ExpIntegralEi", new Type[] { typeof(double) }); 58 private static MethodInfo sinIntegral = thisType.GetMethod("SinIntegral", new Type[] { typeof(double) }); 59 private static MethodInfo cosIntegral = thisType.GetMethod("CosIntegral", new Type[] { typeof(double) }); 60 private static MethodInfo hypSinIntegral = thisType.GetMethod("HypSinIntegral", new Type[] { typeof(double) }); 61 private static MethodInfo hypCosIntegral = thisType.GetMethod("HypCosIntegral", new Type[] { typeof(double) }); 62 private static MethodInfo fresnelCosIntegral = thisType.GetMethod("FresnelCosIntegral", new Type[] { typeof(double) }); 63 private static MethodInfo fresnelSinIntegral = thisType.GetMethod("FresnelSinIntegral", new Type[] { typeof(double) }); 64 private static MethodInfo norm = thisType.GetMethod("Norm", new Type[] { typeof(double) }); 65 private static MethodInfo erf = thisType.GetMethod("Erf", new Type[] { typeof(double) }); 66 private static MethodInfo bessel = thisType.GetMethod("Bessel", new Type[] { typeof(double) }); 46 67 47 68 internal delegate double CompiledFunction(int sampleIndex, IList<double>[] columns); 69 48 70 private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic"; 49 71 private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions"; 72 50 73 #region private classes 74 51 75 private class InterpreterState { 52 76 private Instruction[] code; … … 59 83 60 84 private bool inLaggedContext; 85 61 86 public bool InLaggedContext { 62 87 get { return inLaggedContext; } 63 88 set { inLaggedContext = value; } 64 89 } 90 65 91 internal InterpreterState(Instruction[] code) { 66 92 this.inLaggedContext = false; … … 73 99 } 74 100 } 101 75 102 private class OpCodes { 76 103 public const byte Add = 1; … … 112 139 113 140 public const byte VariableCondition = 27; 114 } 141 142 public const byte Square = 28; 143 public const byte SquareRoot = 29; 144 public const byte Gamma = 30; 145 public const byte Psi = 31; 146 public const byte Dawson = 32; 147 public const byte ExponentialIntegralEi = 33; 148 public const byte CosineIntegral = 34; 149 public const byte SineIntegral = 35; 150 public const byte HyperbolicCosineIntegral = 36; 151 public const byte HyperbolicSineIntegral = 37; 152 public const byte FresnelCosineIntegral = 38; 153 public const byte FresnelSineIntegral = 39; 154 public const byte AiryA = 40; 155 public const byte AiryB = 41; 156 public const byte Norm = 42; 157 public const byte Erf = 43; 158 public const byte Bessel = 44; 159 } 160 115 161 #endregion 116 162 117 private Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() { 118 { typeof(Addition), OpCodes.Add }, 119 { typeof(Subtraction), OpCodes.Sub }, 120 { typeof(Multiplication), OpCodes.Mul }, 121 { typeof(Division), OpCodes.Div }, 122 { typeof(Sine), OpCodes.Sin }, 123 { typeof(Cosine), OpCodes.Cos }, 124 { typeof(Tangent), OpCodes.Tan }, 125 { typeof(Logarithm), OpCodes.Log }, 126 { typeof(Exponential), OpCodes.Exp }, 127 { typeof(IfThenElse), OpCodes.IfThenElse }, 128 { typeof(GreaterThan), OpCodes.GT }, 129 { typeof(LessThan), OpCodes.LT }, 130 { typeof(And), OpCodes.AND }, 131 { typeof(Or), OpCodes.OR }, 132 { typeof(Not), OpCodes.NOT}, 133 { typeof(Average), OpCodes.Average}, 134 { typeof(InvokeFunction), OpCodes.Call }, 135 { typeof(HeuristicLab.Problems.DataAnalysis.Symbolic.Variable), OpCodes.Variable }, 136 { typeof(LaggedVariable), OpCodes.LagVariable }, 137 { typeof(Constant), OpCodes.Constant }, 138 { typeof(Argument), OpCodes.Arg }, 139 { typeof(Power),OpCodes.Power}, 140 { typeof(Root),OpCodes.Root}, 141 { typeof(TimeLag), OpCodes.TimeLag}, 142 { typeof(Integral), OpCodes.Integral}, 143 { typeof(Derivative), OpCodes.Derivative}, 144 { typeof(VariableCondition),OpCodes.VariableCondition} 145 }; 163 private Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() 164 { 165 {typeof (Addition), OpCodes.Add}, 166 {typeof (Subtraction), OpCodes.Sub}, 167 {typeof (Multiplication), OpCodes.Mul}, 168 {typeof (Division), OpCodes.Div}, 169 {typeof (Sine), OpCodes.Sin}, 170 {typeof (Cosine), OpCodes.Cos}, 171 {typeof (Tangent), OpCodes.Tan}, 172 {typeof (Logarithm), OpCodes.Log}, 173 {typeof (Exponential), OpCodes.Exp}, 174 {typeof (IfThenElse), OpCodes.IfThenElse}, 175 {typeof (GreaterThan), OpCodes.GT}, 176 {typeof (LessThan), OpCodes.LT}, 177 {typeof (And), OpCodes.AND}, 178 {typeof (Or), OpCodes.OR}, 179 {typeof (Not), OpCodes.NOT}, 180 {typeof (Average), OpCodes.Average}, 181 {typeof (InvokeFunction), OpCodes.Call}, 182 { 183 typeof (HeuristicLab.Problems.DataAnalysis.Symbolic.Variable), 184 OpCodes.Variable 185 }, 186 {typeof (LaggedVariable), OpCodes.LagVariable}, 187 {typeof (Constant), OpCodes.Constant}, 188 {typeof (Argument), OpCodes.Arg}, 189 {typeof (Power), OpCodes.Power}, 190 {typeof (Root), OpCodes.Root}, 191 {typeof (TimeLag), OpCodes.TimeLag}, 192 {typeof (Integral), OpCodes.Integral}, 193 {typeof (Derivative), OpCodes.Derivative}, 194 {typeof (VariableCondition), OpCodes.VariableCondition}, 195 {typeof (Square), OpCodes.Square}, 196 {typeof (SquareRoot), OpCodes.SquareRoot}, 197 {typeof (Gamma), OpCodes.Gamma}, 198 {typeof (Psi), OpCodes.Psi}, 199 {typeof (Dawson), OpCodes.Dawson}, 200 {typeof (ExponentialIntegralEi), OpCodes.ExponentialIntegralEi}, 201 {typeof (CosineIntegral), OpCodes.CosineIntegral}, 202 {typeof (SineIntegral), OpCodes.SineIntegral}, 203 { 204 typeof (HyperbolicCosineIntegral), 205 OpCodes.HyperbolicCosineIntegral 206 }, 207 { 208 typeof (HyperbolicSineIntegral), OpCodes.HyperbolicSineIntegral 209 }, 210 {typeof (FresnelCosineIntegral), OpCodes.FresnelCosineIntegral}, 211 {typeof (FresnelSineIntegral), OpCodes.FresnelSineIntegral}, 212 {typeof (AiryA), OpCodes.AiryA}, 213 {typeof (AiryB), OpCodes.AiryB}, 214 {typeof (Norm), OpCodes.Norm}, 215 {typeof (Erf), OpCodes.Erf}, 216 {typeof (Bessel), OpCodes.Bessel} 217 }; 146 218 147 219 public override bool CanChangeName { 148 220 get { return false; } 149 221 } 222 150 223 public override bool CanChangeDescription { 151 224 get { return false; } … … 153 226 154 227 #region parameter properties 228 155 229 public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter { 156 230 get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; } … … 160 234 get { return (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; } 161 235 } 236 162 237 #endregion 163 238 164 239 #region properties 240 165 241 public BoolValue CheckExpressionsWithIntervalArithmetic { 166 242 get { return CheckExpressionsWithIntervalArithmeticParameter.Value; } … … 172 248 set { EvaluatedSolutionsParameter.Value = value; } 173 249 } 250 174 251 #endregion 175 252 176 253 177 254 [StorableConstructor] 178 private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(bool deserializing) : base(deserializing) { } 179 private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(SymbolicDataAnalysisExpressionTreeILEmittingInterpreter original, Cloner cloner) : base(original, cloner) { } 255 private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(bool deserializing) 256 : base(deserializing) { 257 } 258 259 private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter( 260 SymbolicDataAnalysisExpressionTreeILEmittingInterpreter original, Cloner cloner) 261 : base(original, cloner) { 262 } 263 180 264 public override IDeepCloneable Clone(Cloner cloner) { 181 265 return new SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(this, cloner); … … 184 268 public SymbolicDataAnalysisExpressionTreeILEmittingInterpreter() 185 269 : base("SymbolicDataAnalysisExpressionTreeILEmittingInterpreter", "Interpreter for symbolic expression trees.") { 186 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 187 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 270 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, 271 "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", 272 new BoolValue(false))); 273 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, 274 "A counter for the total number of solutions the interpreter has evaluated", 275 new IntValue(0))); 188 276 } 189 277 … … 191 279 private void AfterDeserialization() { 192 280 if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName)) 193 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 281 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, 282 "A counter for the total number of solutions the interpreter has evaluated", 283 new IntValue(0))); 194 284 } 195 285 196 286 #region IStatefulItem 287 197 288 public void InitializeState() { 198 289 EvaluatedSolutions.Value = 0; … … 202 293 EvaluatedSolutions.Value = 0; 203 294 } 295 204 296 #endregion 205 297 206 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) { 298 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, Dataset dataset, 299 IEnumerable<int> rows) { 207 300 if (CheckExpressionsWithIntervalArithmetic.Value) 208 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); 301 throw new NotSupportedException( 302 "Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); 209 303 EvaluatedSolutions.Value++; // increment the evaluated solutions counter 210 304 var compiler = new SymbolicExpressionTreeCompiler(); … … 212 306 int necessaryArgStackSize = 0; 213 307 214 Dictionary<string, int> doubleVariableNames = dataset.DoubleVariables.Select((x, i) => new { x, i }).ToDictionary(e => e.x, e => e.i); 308 Dictionary<string, int> doubleVariableNames = 309 dataset.DoubleVariables.Select((x, i) => new { x, i }).ToDictionary(e => e.x, e => e.i); 215 310 IList<double>[] columns = (from v in doubleVariableNames.Keys 216 311 select dataset.GetReadOnlyDoubleValues(v)) 217 312 .ToArray(); 218 313 219 314 for (int i = 0; i < code.Length; i++) { … … 237 332 238 333 Type[] methodArgs = { typeof(int), typeof(IList<double>[]) }; 239 DynamicMethod testFun = new DynamicMethod("TestFun", typeof(double), methodArgs, typeof(SymbolicDataAnalysisExpressionTreeILEmittingInterpreter).Module); 334 DynamicMethod testFun = new DynamicMethod("TestFun", typeof(double), methodArgs, 335 typeof(SymbolicDataAnalysisExpressionTreeILEmittingInterpreter).Module); 240 336 241 337 ILGenerator il = testFun.GetILGenerator(); … … 355 451 CompileInstructions(il, state, ds); 356 452 il.Emit(System.Reflection.Emit.OpCodes.Call, log); 453 return; 454 } 455 case OpCodes.Square: { 456 CompileInstructions(il, state, ds); 457 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); 458 il.Emit(System.Reflection.Emit.OpCodes.Call, power); 459 return; 460 } 461 case OpCodes.SquareRoot: { 462 CompileInstructions(il, state, ds); 463 il.Emit(System.Reflection.Emit.OpCodes.Call, sqrt); 464 return; 465 } 466 case OpCodes.AiryA: { 467 CompileInstructions(il, state, ds); 468 il.Emit(System.Reflection.Emit.OpCodes.Call, airyA); 469 return; 470 } 471 case OpCodes.AiryB: { 472 CompileInstructions(il, state, ds); 473 il.Emit(System.Reflection.Emit.OpCodes.Call, airyB); 474 return; 475 } 476 case OpCodes.Bessel: { 477 CompileInstructions(il, state, ds); 478 il.Emit(System.Reflection.Emit.OpCodes.Call, bessel); 479 return; 480 } 481 case OpCodes.CosineIntegral: { 482 CompileInstructions(il, state, ds); 483 il.Emit(System.Reflection.Emit.OpCodes.Call, cosIntegral); 484 return; 485 } 486 case OpCodes.Dawson: { 487 CompileInstructions(il, state, ds); 488 il.Emit(System.Reflection.Emit.OpCodes.Call, dawson); 489 return; 490 } 491 case OpCodes.Erf: { 492 CompileInstructions(il, state, ds); 493 il.Emit(System.Reflection.Emit.OpCodes.Call, erf); 494 return; 495 } 496 case OpCodes.ExponentialIntegralEi: { 497 CompileInstructions(il, state, ds); 498 il.Emit(System.Reflection.Emit.OpCodes.Call, expIntegralEi); 499 return; 500 } 501 case OpCodes.FresnelCosineIntegral: { 502 CompileInstructions(il, state, ds); 503 il.Emit(System.Reflection.Emit.OpCodes.Call, fresnelCosIntegral); 504 return; 505 } 506 case OpCodes.FresnelSineIntegral: { 507 CompileInstructions(il, state, ds); 508 il.Emit(System.Reflection.Emit.OpCodes.Call, fresnelSinIntegral); 509 return; 510 } 511 case OpCodes.Gamma: { 512 CompileInstructions(il, state, ds); 513 il.Emit(System.Reflection.Emit.OpCodes.Call, gamma); 514 return; 515 } 516 case OpCodes.HyperbolicCosineIntegral: { 517 CompileInstructions(il, state, ds); 518 il.Emit(System.Reflection.Emit.OpCodes.Call, hypCosIntegral); 519 return; 520 } 521 case OpCodes.HyperbolicSineIntegral: { 522 CompileInstructions(il, state, ds); 523 il.Emit(System.Reflection.Emit.OpCodes.Call, hypSinIntegral); 524 return; 525 } 526 case OpCodes.Norm: { 527 CompileInstructions(il, state, ds); 528 il.Emit(System.Reflection.Emit.OpCodes.Call, norm); 529 return; 530 } 531 case OpCodes.Psi: { 532 CompileInstructions(il, state, ds); 533 il.Emit(System.Reflection.Emit.OpCodes.Call, psi); 534 return; 535 } 536 case OpCodes.SineIntegral: { 537 CompileInstructions(il, state, ds); 538 il.Emit(System.Reflection.Emit.OpCodes.Call, sinIntegral); 357 539 return; 358 540 } … … 538 720 } 539 721 case OpCodes.Call: { 540 throw new NotSupportedException("Automatically defined functions are not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter. Either turn of ADFs or change the interpeter."); 722 throw new NotSupportedException( 723 "Automatically defined functions are not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter. Either turn of ADFs or change the interpeter."); 541 724 } 542 725 case OpCodes.Arg: { 543 throw new NotSupportedException("Automatically defined functions are not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter. Either turn of ADFs or change the interpeter."); 726 throw new NotSupportedException( 727 "Automatically defined functions are not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter. Either turn of ADFs or change the interpeter."); 544 728 } 545 729 case OpCodes.Variable: { … … 580 764 LaggedVariableTreeNode varNode = (LaggedVariableTreeNode)currentInstr.dynamicNode; 581 765 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array 582 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0); // load correct column of the current variable 766 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0); 767 // load correct column of the current variable 583 768 il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref); 584 769 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, varNode.Lag); // lag … … 611 796 //to determine the relative amounts of the true and false branch see http://en.wikipedia.org/wiki/Logistic_function 612 797 case OpCodes.VariableCondition: { 613 throw new NotSupportedException("Interpretation of symbol " + currentInstr.dynamicNode.Symbol.Name + " is not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter"); 614 } 615 default: throw new NotSupportedException("Interpretation of symbol " + currentInstr.dynamicNode.Symbol.Name + " is not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter"); 798 throw new NotSupportedException("Interpretation of symbol " + currentInstr.dynamicNode.Symbol.Name + 799 " is not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter"); 800 } 801 default: 802 throw new NotSupportedException("Interpretation of symbol " + currentInstr.dynamicNode.Symbol.Name + 803 " is not supported by the SymbolicDataAnalysisTreeILEmittingInterpreter"); 616 804 } 617 805 } … … 623 811 throw new NotSupportedException("Symbol: " + treeNode.Symbol); 624 812 } 813 814 public static double AiryA(double x) { 815 if (double.IsNaN(x)) return double.NaN; 816 double ai, aip, bi, bip; 817 alglib.airy(x, out ai, out aip, out bi, out bip); 818 return ai; 819 } 820 821 public static double AiryB(double x) { 822 if (double.IsNaN(x)) return double.NaN; 823 double ai, aip, bi, bip; 824 alglib.airy(x, out ai, out aip, out bi, out bip); 825 return bi; 826 } 827 public static double Dawson(double x) { 828 if (double.IsNaN(x)) return double.NaN; 829 return alglib.dawsonintegral(x); 830 } 831 832 public static double Gamma(double x) { 833 if (double.IsNaN(x)) return double.NaN; 834 return alglib.gammafunction(x); 835 } 836 837 public static double Psi(double x) { 838 if (double.IsNaN(x)) return double.NaN; 839 else if (x.IsAlmost(0.0)) return double.NaN; 840 else if ((Math.Floor(x) - x).IsAlmost(0.0)) return double.NaN; 841 return alglib.psi(x); 842 } 843 844 public static double ExpIntegralEi(double x) { 845 if (double.IsNaN(x)) return double.NaN; 846 return alglib.exponentialintegralei(x); 847 } 848 849 public static double SinIntegral(double x) { 850 if (double.IsNaN(x)) return double.NaN; 851 double si, ci; 852 alglib.sinecosineintegrals(x, out si, out ci); 853 return si; 854 } 855 856 public static double CosIntegral(double x) { 857 if (double.IsNaN(x)) return double.NaN; 858 double si, ci; 859 alglib.sinecosineintegrals(x, out si, out ci); 860 return ci; 861 } 862 863 public static double HypSinIntegral(double x) { 864 if (double.IsNaN(x)) return double.NaN; 865 double shi, chi; 866 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 867 return chi; 868 } 869 870 public static double HypCosIntegral(double x) { 871 if (double.IsNaN(x)) return double.NaN; 872 double shi, chi; 873 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 874 return chi; 875 } 876 877 public static double FresnelCosIntegral(double x) { 878 if (double.IsNaN(x)) return double.NaN; 879 double c = 0, s = 0; 880 alglib.fresnelintegral(x, ref c, ref s); 881 return c; 882 } 883 884 public static double FresnelSinIntegral(double x) { 885 if (double.IsNaN(x)) return double.NaN; 886 double c = 0, s = 0; 887 alglib.fresnelintegral(x, ref c, ref s); 888 return s; 889 } 890 891 public static double Norm(double x) { 892 if (double.IsNaN(x)) return double.NaN; 893 return alglib.normaldistribution(x); 894 } 895 896 public static double Erf(double x) { 897 if (double.IsNaN(x)) return double.NaN; 898 return alglib.errorfunction(x); 899 } 900 901 public static double Bessel(double x) { 902 if (double.IsNaN(x)) return double.NaN; 903 return alglib.besseli0(x); 904 } 905 625 906 } 626 907 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r7707 r7708 371 371 if (double.IsNaN(x)) return double.NaN; 372 372 else if (x.IsAlmost(0.0)) return double.NaN; 373 else if ((Math.Floor(x) - x).IsAlmost( -1.0)) return double.NaN;373 else if ((Math.Floor(x) - x).IsAlmost(0)) return double.NaN; 374 374 return alglib.psi(x); 375 375 }
Note: See TracChangeset
for help on using the changeset viewer.