From b22a3333bc1cb4cbd6f9c44fff395f889c73cd4d Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Wed, 29 Apr 2020 11:18:20 +0200 Subject: [PATCH] Root Finding: drop redundant argument checking In cases where we merely redirect to another function which does the same range checking already. --- src/Numerics/RootFinding/Bisection.cs | 12 +----------- src/Numerics/RootFinding/Brent.cs | 7 +------ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Numerics/RootFinding/Bisection.cs b/src/Numerics/RootFinding/Bisection.cs index 6a7b3acb..d0faa3f5 100644 --- a/src/Numerics/RootFinding/Bisection.cs +++ b/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 /// public static double FindRootExpand(Func 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 /// public static double FindRoot(Func 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)) { diff --git a/src/Numerics/RootFinding/Brent.cs b/src/Numerics/RootFinding/Brent.cs index 74ab28a5..fd9bb31e 100644 --- a/src/Numerics/RootFinding/Brent.cs +++ b/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 /// public static double FindRoot(Func 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)) {