From c4e31af95f8056043fc95dfd647ff9c2a28f316a Mon Sep 17 00:00:00 2001 From: Jurgen Van Gael Date: Fri, 31 Jul 2009 01:25:38 +0800 Subject: [PATCH] Added Erf and Erfc unit test coverage. Signed-off-by: Christoph Ruegg --- .../SpecialFunctionsTest/ErfTests.cs | 15 +++++++++++++++ src/Managed/SpecialFunctions/Erf.cs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Managed.UnitTests/SpecialFunctionsTest/ErfTests.cs b/src/Managed.UnitTests/SpecialFunctionsTest/ErfTests.cs index 2ae1996e..d1ab0e05 100644 --- a/src/Managed.UnitTests/SpecialFunctionsTest/ErfTests.cs +++ b/src/Managed.UnitTests/SpecialFunctionsTest/ErfTests.cs @@ -35,7 +35,10 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionTests public class ErfTests { [Test] + [Row(double.NaN, double.NaN)] + [Row(-1.0, -0.84270079294971486934122063508260925929606699796630291)] [Row(0.0, 0.0)] + [Row(1e-15, 0.0000000000000011283791670955126615773132947717431253912942469337536)] [Row(0.1, 0.1124629160182848984047122510143040617233925185058162)] [Row(0.2, 0.22270258921047846617645303120925671669511570710081967)] [Row(0.3, 0.32862675945912741618961798531820303325847175931290341)] @@ -48,13 +51,17 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionTests [Row(3.0, 0.99997790950300141455862722387041767962015229291260075)] [Row(4.0, 0.99999998458274209971998114784032651311595142785474641)] [Row(5.0, 0.99999999999846254020557196514981165651461662110988195)] + [Row(6.0, 0.99999999999999997848026328750108688340664960081261537)] [Row(double.PositiveInfinity, 1.0)] + [Row(double.NegativeInfinity, -1.0)] public void ErfCanMatchLargePrecision(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.Erf(x), 15); } [Test] + [Row(double.NaN, double.NaN)] + [Row(-1.0, 1.8427007929497148693412206350826092592960669979663028)] [Row(0.0, 1.0)] [Row(0.1, 0.88753708398171510159528774898569593827660748149418343)] [Row(0.2, 0.77729741078952153382354696879074328330488429289918085)] @@ -68,7 +75,15 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionTests [Row(3.0, 0.00002209049699858544137277612958232037984770708739924966)] [Row(4.0, 0.000000015417257900280018852159673486884048572145253589191167)] [Row(5.0, 0.0000000000015374597944280348501883434853833788901180503147233804)] + [Row(6.0, 2.1519736712498913116593350399187384630477514061688559e-17)] + [Row(10.0, 2.0884875837625447570007862949577886115608181193211634e-45)] + [Row(15.0, 7.2129941724512066665650665586929271099340909298253858e-100)] + [Row(20.0, 5.3958656116079009289349991679053456040882726709236071e-176)] + [Row(30.0, 2.5646562037561116000333972775014471465488897227786155e-393)] + [Row(50.0, 2.0709207788416560484484478751657887929322509209953988e-1088)] + [Row(80.0, 2.3100265595063985852034904366341042118385080919280966e-2782)] [Row(double.PositiveInfinity, 0.0)] + [Row(double.NegativeInfinity, 2.0)] public void ErfcCanMatchLargePrecision(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.Erfc(x), 13); diff --git a/src/Managed/SpecialFunctions/Erf.cs b/src/Managed/SpecialFunctions/Erf.cs index 2bf84b9b..3f626fad 100644 --- a/src/Managed/SpecialFunctions/Erf.cs +++ b/src/Managed/SpecialFunctions/Erf.cs @@ -71,7 +71,7 @@ namespace MathNet.Numerics return -1; } - if (Double.IsNaN(x) || Double.IsNaN(x)) + if (Double.IsNaN(x)) { return Double.NaN; } @@ -105,7 +105,7 @@ namespace MathNet.Numerics return 2; } - if (Double.IsNaN(x) || Double.IsNaN(x)) + if (Double.IsNaN(x)) { return Double.NaN; }