Changeset 8123 for trunk/sources
- Timestamp:
- 06/26/12 14:17:10 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r7708 r8123 837 837 public static double Psi(double x) { 838 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; 839 else if (x <= 0 && (Math.Floor(x) - x).IsAlmost(0)) return double.NaN; 841 840 return alglib.psi(x); 842 841 } … … 865 864 double shi, chi; 866 865 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 867 return chi;866 return shi; 868 867 } 869 868 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r7708 r8123 198 198 { typeof(Norm), OpCodes.Norm}, 199 199 { typeof(Erf), OpCodes.Erf}, 200 { typeof(Bessel), OpCodes.Bessel} 200 { typeof(Bessel), OpCodes.Bessel} 201 201 }; 202 202 … … 370 370 var x = Evaluate(dataset, ref row, state); 371 371 if (double.IsNaN(x)) return double.NaN; 372 else if (x.IsAlmost(0.0)) return double.NaN; 373 else if ((Math.Floor(x) - x).IsAlmost(0)) return double.NaN; 372 else if (x <= 0 && (Math.Floor(x) - x).IsAlmost(0)) return double.NaN; 374 373 return alglib.psi(x); 375 374 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r7926 r8123 365 365 Evaluate(interpreter, ds, "(lag -1.0 (* (lagVariable 1.0 a 1) (lagVariable 1.0 b 2)))", 1, ds.GetDoubleValue("A", 1) * ds.GetDoubleValue("B", 2)); 366 366 Evaluate(interpreter, ds, "(lag -2.0 3.0)", 1, 3.0); 367 368 { 369 // special functions 370 Action<double> checkAiry = (x) => { 371 double ai, aip, bi, bip; 372 alglib.airy(x, out ai, out aip, out bi, out bip); 373 Evaluate(interpreter, ds, "(airya " + x + ")", 0, ai); 374 Evaluate(interpreter, ds, "(airyb " + x + ")", 0, bi); 375 }; 376 377 Action<double> checkBessel = (x) => { 378 Evaluate(interpreter, ds, "(bessel " + x + ")", 0, alglib.besseli0(x)); 379 }; 380 381 Action<double> checkSinCosIntegrals = (x) => { 382 double si, ci; 383 alglib.sinecosineintegrals(x, out si, out ci); 384 Evaluate(interpreter, ds, "(cosint " + x + ")", 0, ci); 385 Evaluate(interpreter, ds, "(sinint " + x + ")", 0, si); 386 }; 387 Action<double> checkHypSinCosIntegrals = (x) => { 388 double shi, chi; 389 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 390 Evaluate(interpreter, ds, "(hypcosint " + x + ")", 0, chi); 391 Evaluate(interpreter, ds, "(hypsinint " + x + ")", 0, shi); 392 }; 393 Action<double> checkFresnelSinCosIntegrals = (x) => { 394 double c = 0, s = 0; 395 alglib.fresnelintegral(x, ref c, ref s); 396 Evaluate(interpreter, ds, "(fresnelcosint " + x + ")", 0, c); 397 Evaluate(interpreter, ds, "(fresnelsinint " + x + ")", 0, s); 398 }; 399 Action<double> checkNormErf = (x) => { 400 Evaluate(interpreter, ds, "(norm " + x + ")", 0, alglib.normaldistribution(x)); 401 Evaluate(interpreter, ds, "(erf " + x + ")", 0, alglib.errorfunction(x)); 402 }; 403 404 Action<double> checkGamma = (x) => { 405 Evaluate(interpreter, ds, "(gamma " + x + ")", 0, alglib.gammafunction(x)); 406 }; 407 Action<double> checkPsi = (x) => { 408 try { 409 Evaluate(interpreter, ds, "(psi " + x + ")", 0, alglib.psi(x)); 410 } 411 catch (alglib.alglibexception) { // ignore cases where alglib throws an exception 412 } 413 }; 414 Action<double> checkDawson = (x) => { 415 Evaluate(interpreter, ds, "(dawson " + x + ")", 0, alglib.dawsonintegral(x)); 416 }; 417 Action<double> checkExpInt = (x) => { 418 Evaluate(interpreter, ds, "(expint " + x + ")", 0, alglib.exponentialintegralei(x)); 419 }; 420 421 422 423 foreach (var e in new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }) { 424 checkAiry(e); 425 checkBessel(e); 426 checkSinCosIntegrals(e); 427 checkGamma(e); 428 checkExpInt(e); 429 checkDawson(e); 430 checkPsi(e); 431 checkNormErf(e); 432 checkFresnelSinCosIntegrals(e); 433 checkHypSinCosIntegrals(e); 434 } 435 } 367 436 } 368 437 -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionImporter.cs
r7915 r8123 49 49 {"COS", new Cosine()}, 50 50 {"TAN", new Tangent()}, 51 {"AIRYA", new AiryA()}, 52 {"AIRYB", new AiryB()}, 53 {"BESSEL", new Bessel()}, 54 {"COSINT", new CosineIntegral()}, 55 {"SININT", new SineIntegral()}, 56 {"HYPCOSINT", new HyperbolicCosineIntegral()}, 57 {"HYPSININT", new HyperbolicSineIntegral()}, 58 {"FRESNELSININT", new FresnelSineIntegral()}, 59 {"FRESNELCOSINT", new FresnelCosineIntegral()}, 60 {"NORM", new Norm()}, 61 {"ERF", new Erf()}, 62 {"GAMMA", new Gamma()}, 63 {"PSI", new Psi()}, 64 {"DAWSON", new Dawson()}, 65 {"EXPINT", new ExponentialIntegralEi()}, 51 66 {"MEAN", new Average()}, 52 67 {"IF", new IfThenElse()},
Note: See TracChangeset
for help on using the changeset viewer.