Browse Source

Root Finding: drop redundant argument checking

In cases where we merely redirect to another function which does the same range checking already.
uap-experimental
Christoph Ruegg 6 years ago
parent
commit
b22a3333bc
  1. 12
      src/Numerics/RootFinding/Bisection.cs
  2. 7
      src/Numerics/RootFinding/Brent.cs

12
src/Numerics/RootFinding/Bisection.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2013 Math.NET
// Copyright (c) 2009-2020 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -49,11 +49,6 @@ namespace MathNet.Numerics.RootFinding
/// <exception cref="NonConvergenceException"></exception>
public static double FindRootExpand(Func<double, double> f, double guessLowerBound, double guessUpperBound, double accuracy = 1e-8, int maxIterations = 100, double expandFactor = 1.6, int maxExpandIteratons = 100)
{
if (accuracy <= 0)
{
throw new ArgumentOutOfRangeException(nameof(accuracy), "Must be greater than zero.");
}
ZeroCrossingBracketing.ExpandReduce(f, ref guessLowerBound, ref guessUpperBound, expandFactor, maxExpandIteratons, maxExpandIteratons*10);
return FindRoot(f, guessLowerBound, guessUpperBound, accuracy, maxIterations);
}
@ -68,11 +63,6 @@ namespace MathNet.Numerics.RootFinding
/// <exception cref="NonConvergenceException"></exception>
public static double FindRoot(Func<double, double> f, double lowerBound, double upperBound, double accuracy = 1e-14, int maxIterations = 100)
{
if (accuracy <= 0)
{
throw new ArgumentOutOfRangeException(nameof(accuracy), "Must be greater than zero.");
}
double root;
if (TryFindRoot(f, lowerBound, upperBound, accuracy, maxIterations, out root))
{

7
src/Numerics/RootFinding/Brent.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2014 Math.NET
// Copyright (c) 2009-2020 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -64,11 +64,6 @@ namespace MathNet.Numerics.RootFinding
/// <exception cref="NonConvergenceException"></exception>
public static double FindRoot(Func<double, double> f, double lowerBound, double upperBound, double accuracy = 1e-8, int maxIterations = 100)
{
if (accuracy <= 0)
{
throw new ArgumentOutOfRangeException(nameof(accuracy), "Must be greater than zero.");
}
double root;
if (TryFindRoot(f, lowerBound, upperBound, accuracy, maxIterations, out root))
{

Loading…
Cancel
Save