Browse Source

RootFinding: s/FloatingPointRoots/RealRoots/

v2
Christoph Ruegg 14 years ago
parent
commit
72b86504fe
  1. 2
      src/Numerics/Numerics.csproj
  2. 2
      src/Numerics/RootFinding/RealRoots.cs
  3. 4
      src/Portable/Portable.csproj
  4. 4
      src/UnitTests/RootFindingTests/NewtonRaphsonTest.cs

2
src/Numerics/Numerics.csproj

@ -114,7 +114,7 @@
<Compile Include="RootFinding\Algorithms\ZeroCrossingBracketing.cs" /> <Compile Include="RootFinding\Algorithms\ZeroCrossingBracketing.cs" />
<Compile Include="RootFinding\Bracketing.cs" /> <Compile Include="RootFinding\Bracketing.cs" />
<Compile Include="RootFinding\Algorithms\Brent.cs" /> <Compile Include="RootFinding\Algorithms\Brent.cs" />
<Compile Include="RootFinding\FloatingPointRoots.cs" /> <Compile Include="RootFinding\RealRoots.cs" />
<Compile Include="RootFinding\Algorithms\Bisection.cs" /> <Compile Include="RootFinding\Algorithms\Bisection.cs" />
<Compile Include="SpecialFunctions\Evaluate.cs" /> <Compile Include="SpecialFunctions\Evaluate.cs" />
<Compile Include="SpecialFunctions\ModifiedStruve.cs" /> <Compile Include="SpecialFunctions\ModifiedStruve.cs" />

2
src/Numerics/RootFinding/FloatingPointRoots.cs → src/Numerics/RootFinding/RealRoots.cs

@ -33,7 +33,7 @@ using MathNet.Numerics.RootFinding.Algorithms;
namespace MathNet.Numerics.RootFinding namespace MathNet.Numerics.RootFinding
{ {
public static class FloatingPointRoots public static class RealRoots
{ {
public static double OfFunction(Func<double, double> f, double lowerBound, double upperBound, double accuracy = 1e-8) public static double OfFunction(Func<double, double> f, double lowerBound, double upperBound, double accuracy = 1e-8)
{ {

4
src/Portable/Portable.csproj

@ -999,8 +999,8 @@
<Compile Include="..\Numerics\RootFinding\Bracketing.cs"> <Compile Include="..\Numerics\RootFinding\Bracketing.cs">
<Link>RootFinding\Bracketing.cs</Link> <Link>RootFinding\Bracketing.cs</Link>
</Compile> </Compile>
<Compile Include="..\Numerics\RootFinding\FloatingPointRoots.cs"> <Compile Include="..\Numerics\RootFinding\RealRoots.cs">
<Link>RootFinding\FloatingPointRoots.cs</Link> <Link>RootFinding\RealRoots.cs</Link>
</Compile> </Compile>
<Compile Include="..\Numerics\SerializableAttribute.cs"> <Compile Include="..\Numerics\SerializableAttribute.cs">
<Link>SerializableAttribute.cs</Link> <Link>SerializableAttribute.cs</Link>

4
src/UnitTests/RootFindingTests/NewtonRaphsonTest.cs

@ -77,13 +77,13 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
Func<double, double> df1 = x => -1/(x*x - 4*x + 4); Func<double, double> df1 = x => -1/(x*x - 4*x + 4);
Assert.AreEqual(1.5, HybridNewtonRaphson.FindRoot(f1, df1, 1, 2, 1e-14, 100, 20)); Assert.AreEqual(1.5, HybridNewtonRaphson.FindRoot(f1, df1, 1, 2, 1e-14, 100, 20));
Assert.AreEqual(1.5, HybridNewtonRaphson.FindRoot(f1, df1, 1, 6, 1e-14, 100, 20)); Assert.AreEqual(1.5, HybridNewtonRaphson.FindRoot(f1, df1, 1, 6, 1e-14, 100, 20));
Assert.AreEqual(1.5, FloatingPointRoots.OfFunctionAndDerivative(f1, df1, 1, 6)); Assert.AreEqual(1.5, RealRoots.OfFunctionAndDerivative(f1, df1, 1, 6));
Func<double, double> f2 = x => -1/(x - 2) + 2; Func<double, double> f2 = x => -1/(x - 2) + 2;
Func<double, double> df2 = x => 1/(x*x - 4*x + 4); Func<double, double> df2 = x => 1/(x*x - 4*x + 4);
Assert.AreEqual(2.5, HybridNewtonRaphson.FindRoot(f2, df2, 2, 3, 1e-14, 100, 20)); Assert.AreEqual(2.5, HybridNewtonRaphson.FindRoot(f2, df2, 2, 3, 1e-14, 100, 20));
Assert.AreEqual(2.5, HybridNewtonRaphson.FindRoot(f2, df2, -2, 3, 1e-14, 100, 20)); Assert.AreEqual(2.5, HybridNewtonRaphson.FindRoot(f2, df2, -2, 3, 1e-14, 100, 20));
Assert.AreEqual(2.5, FloatingPointRoots.OfFunctionAndDerivative(f2, df2, -2, 3)); Assert.AreEqual(2.5, RealRoots.OfFunctionAndDerivative(f2, df2, -2, 3));
Func<double, double> f3 = x => 1/(x - 2) + x + 2; Func<double, double> f3 = x => 1/(x - 2) + x + 2;
Func<double, double> df3 = x => -1/(x*x - 4*x + 4) + 1; Func<double, double> df3 = x => -1/(x*x - 4*x + 4) + 1;

Loading…
Cancel
Save