MATH-854
Populate "throws" clause. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1379560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
86f09b3e1f
commit
0af91ecfbe
|
@ -19,6 +19,7 @@ package org.apache.commons.math3.analysis.solvers;
|
|||
|
||||
import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
|
||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* Provide a default implementation for several functions useful to generic
|
||||
|
@ -52,8 +53,8 @@ public abstract class AbstractDifferentiableUnivariateSolver
|
|||
* @param functionValueAccuracy Maximum function value error.
|
||||
*/
|
||||
protected AbstractDifferentiableUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy);
|
||||
}
|
||||
|
||||
|
@ -65,7 +66,8 @@ public abstract class AbstractDifferentiableUnivariateSolver
|
|||
* @throws org.apache.commons.math3.exception.TooManyEvaluationsException
|
||||
* if the maximal number of evaluations is exceeded.
|
||||
*/
|
||||
protected double computeDerivativeObjectiveValue(double point) {
|
||||
protected double computeDerivativeObjectiveValue(double point)
|
||||
throws TooManyEvaluationsException {
|
||||
incrementEvaluationCount();
|
||||
return functionDerivative.value(point);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public abstract class AbstractUnivariateSolver
|
|||
* @param absoluteAccuracy Maximum absolute error.
|
||||
*/
|
||||
protected AbstractUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy) {
|
||||
final double absoluteAccuracy) {
|
||||
super(relativeAccuracy, absoluteAccuracy);
|
||||
}
|
||||
/**
|
||||
|
@ -54,8 +54,8 @@ public abstract class AbstractUnivariateSolver
|
|||
* @param functionValueAccuracy Maximum function value error.
|
||||
*/
|
||||
protected AbstractUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.apache.commons.math3.analysis.UnivariateFunction;
|
|||
import org.apache.commons.math3.exception.MaxCountExceededException;
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math3.exception.NullArgumentException;
|
||||
import org.apache.commons.math3.util.Incrementor;
|
||||
import org.apache.commons.math3.util.MathUtils;
|
||||
|
||||
|
@ -182,7 +184,9 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double solve(int maxEval, FUNC f, double min, double max, double startValue) {
|
||||
public double solve(int maxEval, FUNC f, double min, double max, double startValue)
|
||||
throws TooManyEvaluationsException,
|
||||
NoBracketingException {
|
||||
// Initialization.
|
||||
setup(maxEval, f, min, max, startValue);
|
||||
|
||||
|
@ -196,7 +200,9 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double solve(int maxEval, FUNC f, double startValue) {
|
||||
public double solve(int maxEval, FUNC f, double startValue)
|
||||
throws TooManyEvaluationsException,
|
||||
NoBracketingException {
|
||||
return solve(maxEval, f, Double.NaN, Double.NaN, startValue);
|
||||
}
|
||||
|
||||
|
@ -245,11 +251,11 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
*
|
||||
* @param lower Lower endpoint.
|
||||
* @param upper Upper endpoint.
|
||||
* @throws org.apache.commons.math3.exception.NumberIsTooLargeException
|
||||
* if {@code lower >= upper}.
|
||||
* @throws NumberIsTooLargeException if {@code lower >= upper}.
|
||||
*/
|
||||
protected void verifyInterval(final double lower,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NumberIsTooLargeException {
|
||||
UnivariateSolverUtils.verifyInterval(lower, upper);
|
||||
}
|
||||
|
||||
|
@ -259,12 +265,13 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
* @param lower Lower endpoint.
|
||||
* @param initial Initial value.
|
||||
* @param upper Upper endpoint.
|
||||
* @throws org.apache.commons.math3.exception.NumberIsTooLargeException
|
||||
* if {@code lower >= initial} or {@code initial >= upper}.
|
||||
* @throws NumberIsTooLargeException if {@code lower >= initial} or
|
||||
* {@code initial >= upper}.
|
||||
*/
|
||||
protected void verifySequence(final double lower,
|
||||
final double initial,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NumberIsTooLargeException {
|
||||
UnivariateSolverUtils.verifySequence(lower, initial, upper);
|
||||
}
|
||||
|
||||
|
@ -274,11 +281,14 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
*
|
||||
* @param lower Lower endpoint.
|
||||
* @param upper Upper endpoint.
|
||||
* @throws org.apache.commons.math3.exception.NoBracketingException if
|
||||
* the function has the same sign at the endpoints.
|
||||
* @throws NullArgumentException if the function has not been set.
|
||||
* @throws NoBracketingException if the function has the same sign at
|
||||
* the endpoints.
|
||||
*/
|
||||
protected void verifyBracketing(final double lower,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NullArgumentException,
|
||||
NoBracketingException {
|
||||
UnivariateSolverUtils.verifyBracketing(function, lower, upper);
|
||||
}
|
||||
|
||||
|
@ -289,7 +299,8 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
* {@code computeObjectiveValue} to solve the function.
|
||||
* See e.g. {@link AbstractUnivariateDifferentiableSolver}.
|
||||
*/
|
||||
protected void incrementEvaluationCount() {
|
||||
protected void incrementEvaluationCount()
|
||||
throws TooManyEvaluationsException {
|
||||
try {
|
||||
evaluations.incrementCount();
|
||||
} catch (MaxCountExceededException e) {
|
||||
|
|
|
@ -125,9 +125,16 @@ public abstract class BaseSecantSolver
|
|||
return solve(maxEval, f, min, max, startValue, AllowedSolution.ANY_SIDE);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws ConvergenceException if the algorithm failed due to finite
|
||||
* precision.
|
||||
*/
|
||||
@Override
|
||||
protected final double doSolve() {
|
||||
protected final double doSolve()
|
||||
throws ConvergenceException,
|
||||
MathInternalError {
|
||||
// Get initial solution
|
||||
double x0 = getMin();
|
||||
double x1 = getMax();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.commons.math3.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/Bisection.html">
|
||||
|
@ -59,7 +60,8 @@ public class BisectionSolver extends AbstractUnivariateSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException {
|
||||
double min = getMin();
|
||||
double max = getMax();
|
||||
verifyInterval(min, max);
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.apache.commons.math3.analysis.UnivariateFunction;
|
|||
import org.apache.commons.math3.exception.MathInternalError;
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.util.Precision;
|
||||
|
||||
|
@ -140,8 +142,10 @@ public class BracketingNthOrderBrentSolver
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException,
|
||||
NumberIsTooLargeException,
|
||||
NoBracketingException {
|
||||
// prepare arrays with the first points
|
||||
final double[] x = new double[maximalOrder + 1];
|
||||
final double[] y = new double[maximalOrder + 1];
|
||||
|
@ -224,7 +228,7 @@ public class BracketingNthOrderBrentSolver
|
|||
return (yA < 0) ? xB : xA;
|
||||
default :
|
||||
// this should never happen
|
||||
throw new MathInternalError(null);
|
||||
throw new MathInternalError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +391,10 @@ public class BracketingNthOrderBrentSolver
|
|||
|
||||
/** {@inheritDoc} */
|
||||
public double solve(int maxEval, UnivariateFunction f, double min,
|
||||
double max, AllowedSolution allowedSolution) {
|
||||
double max, AllowedSolution allowedSolution)
|
||||
throws TooManyEvaluationsException,
|
||||
NumberIsTooLargeException,
|
||||
NoBracketingException {
|
||||
this.allowed = allowedSolution;
|
||||
return super.solve(maxEval, f, min, max);
|
||||
}
|
||||
|
@ -395,7 +402,10 @@ public class BracketingNthOrderBrentSolver
|
|||
/** {@inheritDoc} */
|
||||
public double solve(int maxEval, UnivariateFunction f, double min,
|
||||
double max, double startValue,
|
||||
AllowedSolution allowedSolution) {
|
||||
AllowedSolution allowedSolution)
|
||||
throws TooManyEvaluationsException,
|
||||
NumberIsTooLargeException,
|
||||
NoBracketingException {
|
||||
this.allowed = allowedSolution;
|
||||
return super.solve(maxEval, f, min, max, startValue);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.commons.math3.analysis.solvers;
|
|||
|
||||
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.util.Precision;
|
||||
|
||||
|
@ -79,7 +81,10 @@ public class BrentSolver extends AbstractUnivariateSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws NoBracketingException,
|
||||
TooManyEvaluationsException,
|
||||
NumberIsTooLargeException {
|
||||
double min = getMin();
|
||||
double max = getMax();
|
||||
final double initial = getStartValue();
|
||||
|
|
|
@ -22,6 +22,8 @@ import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
|
|||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.NullArgumentException;
|
||||
import org.apache.commons.math3.exception.NoDataException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
||||
|
@ -87,7 +89,10 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double doSolve() {
|
||||
public double doSolve()
|
||||
throws TooManyEvaluationsException,
|
||||
NumberIsTooLargeException,
|
||||
NoBracketingException {
|
||||
final double min = getMin();
|
||||
final double max = getMax();
|
||||
final double initial = getStartValue();
|
||||
|
@ -185,7 +190,10 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
* @throws NoDataException if the {@code coefficients} array is empty.
|
||||
*/
|
||||
public Complex[] solveAllComplex(double[] coefficients,
|
||||
double initial) {
|
||||
double initial)
|
||||
throws NullArgumentException,
|
||||
NoDataException,
|
||||
TooManyEvaluationsException {
|
||||
setup(Integer.MAX_VALUE,
|
||||
new PolynomialFunction(coefficients),
|
||||
Double.NEGATIVE_INFINITY,
|
||||
|
@ -211,7 +219,10 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
* @throws NoDataException if the {@code coefficients} array is empty.
|
||||
*/
|
||||
public Complex solveComplex(double[] coefficients,
|
||||
double initial) {
|
||||
double initial)
|
||||
throws NullArgumentException,
|
||||
NoDataException,
|
||||
TooManyEvaluationsException {
|
||||
setup(Integer.MAX_VALUE,
|
||||
new PolynomialFunction(coefficients),
|
||||
Double.NEGATIVE_INFINITY,
|
||||
|
@ -256,7 +267,10 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
* {@code null}.
|
||||
* @throws NoDataException if the {@code coefficients} array is empty.
|
||||
*/
|
||||
public Complex[] solveAll(Complex coefficients[], Complex initial) {
|
||||
public Complex[] solveAll(Complex coefficients[], Complex initial)
|
||||
throws NullArgumentException,
|
||||
NoDataException,
|
||||
TooManyEvaluationsException {
|
||||
if (coefficients == null) {
|
||||
throw new NullArgumentException();
|
||||
}
|
||||
|
@ -302,7 +316,10 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
* {@code null}.
|
||||
* @throws NoDataException if the {@code coefficients} array is empty.
|
||||
*/
|
||||
public Complex solve(Complex coefficients[], Complex initial) {
|
||||
public Complex solve(Complex coefficients[], Complex initial)
|
||||
throws NullArgumentException,
|
||||
NoDataException,
|
||||
TooManyEvaluationsException {
|
||||
if (coefficients == null) {
|
||||
throw new NullArgumentException();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
package org.apache.commons.math3.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* This class implements the <a href="http://mathworld.wolfram.com/MullersMethod.html">
|
||||
|
@ -78,7 +81,10 @@ public class MullerSolver extends AbstractUnivariateSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException,
|
||||
NumberIsTooLargeException,
|
||||
NoBracketingException {
|
||||
final double min = getMin();
|
||||
final double max = getMax();
|
||||
final double initial = getStartValue();
|
||||
|
@ -120,7 +126,8 @@ public class MullerSolver extends AbstractUnivariateSolver {
|
|||
* @return the point at which the function value is zero.
|
||||
*/
|
||||
private double solve(double min, double max,
|
||||
double fMin, double fMax) {
|
||||
double fMin, double fMax)
|
||||
throws TooManyEvaluationsException {
|
||||
final double relativeAccuracy = getRelativeAccuracy();
|
||||
final double absoluteAccuracy = getAbsoluteAccuracy();
|
||||
final double functionValueAccuracy = getFunctionValueAccuracy();
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
package org.apache.commons.math3.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
||||
/**
|
||||
|
@ -79,7 +81,10 @@ public class MullerSolver2 extends AbstractUnivariateSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException,
|
||||
NumberIsTooLargeException,
|
||||
NoBracketingException {
|
||||
final double min = getMin();
|
||||
final double max = getMax();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.commons.math3.analysis.solvers;
|
|||
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiable;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
|
||||
|
@ -63,7 +64,8 @@ public class NewtonRaphsonSolver extends AbstractUnivariateDifferentiableSolver
|
|||
*/
|
||||
@Override
|
||||
public double solve(int maxEval, final UnivariateDifferentiable f,
|
||||
final double min, final double max) {
|
||||
final double min, final double max)
|
||||
throws TooManyEvaluationsException {
|
||||
return super.solve(maxEval, f, UnivariateSolverUtils.midpoint(min, max));
|
||||
}
|
||||
|
||||
|
@ -71,7 +73,8 @@ public class NewtonRaphsonSolver extends AbstractUnivariateDifferentiableSolver
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException {
|
||||
final double startValue = getStartValue();
|
||||
final double absoluteAccuracy = getAbsoluteAccuracy();
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math3.analysis.solvers;
|
|||
|
||||
import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
|
||||
|
@ -64,7 +65,8 @@ public class NewtonSolver extends AbstractDifferentiableUnivariateSolver {
|
|||
*/
|
||||
@Override
|
||||
public double solve(int maxEval, final DifferentiableUnivariateFunction f,
|
||||
final double min, final double max) {
|
||||
final double min, final double max)
|
||||
throws TooManyEvaluationsException {
|
||||
return super.solve(maxEval, f, UnivariateSolverUtils.midpoint(min, max));
|
||||
}
|
||||
|
||||
|
@ -72,7 +74,8 @@ public class NewtonSolver extends AbstractDifferentiableUnivariateSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException {
|
||||
final double startValue = getStartValue();
|
||||
final double absoluteAccuracy = getAbsoluteAccuracy();
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
package org.apache.commons.math3.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/RiddersMethod.html">
|
||||
|
@ -63,7 +65,9 @@ public class RiddersSolver extends AbstractUnivariateSolver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected double doSolve() {
|
||||
protected double doSolve()
|
||||
throws TooManyEvaluationsException,
|
||||
NoBracketingException {
|
||||
double min = getMin();
|
||||
double max = getMax();
|
||||
// [x1, x2] is the bracketing interval in each iteration
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
package org.apache.commons.math3.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.exception.NoBracketingException;
|
||||
import org.apache.commons.math3.exception.TooManyEvaluationsException;
|
||||
|
||||
/**
|
||||
* Implements the <em>Secant</em> method for root-finding (approximating a
|
||||
|
@ -70,7 +72,9 @@ public class SecantSolver extends AbstractUnivariateSolver {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final double doSolve() {
|
||||
protected final double doSolve()
|
||||
throws TooManyEvaluationsException,
|
||||
NoBracketingException {
|
||||
// Get initial solution
|
||||
double x0 = getMin();
|
||||
double x1 = getMax();
|
||||
|
|
|
@ -46,7 +46,8 @@ public class UnivariateSolverUtils {
|
|||
* @throws IllegalArgumentException if f is null or the endpoints do not
|
||||
* specify a valid interval.
|
||||
*/
|
||||
public static double solve(UnivariateFunction function, double x0, double x1) {
|
||||
public static double solve(UnivariateFunction function, double x0, double x1)
|
||||
throws NullArgumentException {
|
||||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
|
@ -69,7 +70,8 @@ public class UnivariateSolverUtils {
|
|||
*/
|
||||
public static double solve(UnivariateFunction function,
|
||||
double x0, double x1,
|
||||
double absoluteAccuracy) {
|
||||
double absoluteAccuracy)
|
||||
throws NullArgumentException {
|
||||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
|
@ -94,7 +96,8 @@ public class UnivariateSolverUtils {
|
|||
public static double forceSide(final int maxEval, final UnivariateFunction f,
|
||||
final BracketedUnivariateSolver<UnivariateFunction> bracketing,
|
||||
final double baseRoot, final double min, final double max,
|
||||
final AllowedSolution allowedSolution) {
|
||||
final AllowedSolution allowedSolution)
|
||||
throws NoBracketingException {
|
||||
|
||||
if (allowedSolution == AllowedSolution.ANY_SIDE) {
|
||||
// no further bracketing required
|
||||
|
@ -203,7 +206,10 @@ public class UnivariateSolverUtils {
|
|||
*/
|
||||
public static double[] bracket(UnivariateFunction function,
|
||||
double initial,
|
||||
double lowerBound, double upperBound) {
|
||||
double lowerBound, double upperBound)
|
||||
throws NullArgumentException,
|
||||
NotStrictlyPositiveException,
|
||||
NoBracketingException {
|
||||
return bracket(function, initial, lowerBound, upperBound, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -242,7 +248,10 @@ public class UnivariateSolverUtils {
|
|||
public static double[] bracket(UnivariateFunction function,
|
||||
double initial,
|
||||
double lowerBound, double upperBound,
|
||||
int maximumIterations) {
|
||||
int maximumIterations)
|
||||
throws NullArgumentException,
|
||||
NotStrictlyPositiveException,
|
||||
NoBracketingException {
|
||||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
|
@ -301,7 +310,8 @@ public class UnivariateSolverUtils {
|
|||
*/
|
||||
public static boolean isBracketing(UnivariateFunction function,
|
||||
final double lower,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NullArgumentException {
|
||||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
|
@ -332,7 +342,8 @@ public class UnivariateSolverUtils {
|
|||
* @throws NumberIsTooLargeException if {@code lower >= upper}.
|
||||
*/
|
||||
public static void verifyInterval(final double lower,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NumberIsTooLargeException {
|
||||
if (lower >= upper) {
|
||||
throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL,
|
||||
lower, upper, false);
|
||||
|
@ -350,7 +361,8 @@ public class UnivariateSolverUtils {
|
|||
*/
|
||||
public static void verifySequence(final double lower,
|
||||
final double initial,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NumberIsTooLargeException {
|
||||
verifyInterval(lower, initial);
|
||||
verifyInterval(initial, upper);
|
||||
}
|
||||
|
@ -367,7 +379,9 @@ public class UnivariateSolverUtils {
|
|||
*/
|
||||
public static void verifyBracketing(UnivariateFunction function,
|
||||
final double lower,
|
||||
final double upper) {
|
||||
final double upper)
|
||||
throws NullArgumentException,
|
||||
NoBracketingException {
|
||||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue