Author: erans
Date: Fri Aug 31 19:40:30 2012
New Revision: 1379560
URL: http://svn.apache.org/viewvc?rev=1379560&view=rev
Log:
MATH-854
Populate "throws" clause.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BisectionSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonRaphsonSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/RiddersSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/SecantSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
Fri Aug 31 19:40:30 2012
@@ -19,6 +19,7 @@ package org.apache.commons.math3.analysi
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 AbstractDifferenti
* @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 AbstractDifferenti
* @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);
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateSolver.java
Fri Aug 31 19:40:30 2012
@@ -43,7 +43,7 @@ public abstract class AbstractUnivariate
* @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 AbstractUnivariate
* @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);
}
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
Fri Aug 31 19:40:30 2012
@@ -21,6 +21,8 @@ import org.apache.commons.math3.analysis
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 BaseAbstractUnivar
}
/** {@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 BaseAbstractUnivar
}
/** {@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 BaseAbstractUnivar
*
* @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 BaseAbstractUnivar
* @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 BaseAbstractUnivar
*
* @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 BaseAbstractUnivar
* {@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) {
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java
Fri Aug 31 19:40:30 2012
@@ -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();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BisectionSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BisectionSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BisectionSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BisectionSolver.java
Fri Aug 31 19:40:30 2012
@@ -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 Abs
* {@inheritDoc}
*/
@Override
- protected double doSolve() {
+ protected double doSolve()
+ throws TooManyEvaluationsException {
double min = getMin();
double max = getMax();
verifyInterval(min, max);
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java
Fri Aug 31 19:40:30 2012
@@ -21,6 +21,8 @@ import org.apache.commons.math3.analysis
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 BracketingNthOrderBrentSolv
* {@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 BracketingNthOrderBrentSolv
return (yA < 0) ? xB : xA;
default :
// this should never happen
- throw new MathInternalError(null);
+ throw new MathInternalError();
}
}
@@ -387,7 +391,10 @@ public class BracketingNthOrderBrentSolv
/** {@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 BracketingNthOrderBrentSolv
/** {@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);
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java
Fri Aug 31 19:40:30 2012
@@ -18,6 +18,8 @@ package org.apache.commons.math3.analysi
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 Abstrac
* {@inheritDoc}
*/
@Override
- protected double doSolve() {
+ protected double doSolve()
+ throws NoBracketingException,
+ TooManyEvaluationsException,
+ NumberIsTooLargeException {
double min = getMin();
double max = getMax();
final double initial = getStartValue();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java
Fri Aug 31 19:40:30 2012
@@ -22,6 +22,8 @@ import org.apache.commons.math3.analysis
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 Abst
* {@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 Abst
* @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 Abst
* @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 Abst
* {@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 Abst
* {@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();
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java
Fri Aug 31 19:40:30 2012
@@ -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 Abstra
* {@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 Abstra
* @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();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java
Fri Aug 31 19:40:30 2012
@@ -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 Abstr
* {@inheritDoc}
*/
@Override
- protected double doSolve() {
+ protected double doSolve()
+ throws TooManyEvaluationsException,
+ NumberIsTooLargeException,
+ NoBracketingException {
final double min = getMin();
final double max = getMax();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonRaphsonSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonRaphsonSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonRaphsonSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonRaphsonSolver.java
Fri Aug 31 19:40:30 2012
@@ -20,6 +20,7 @@ package org.apache.commons.math3.analysi
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
*/
@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
* {@inheritDoc}
*/
@Override
- protected double doSolve() {
+ protected double doSolve()
+ throws TooManyEvaluationsException {
final double startValue = getStartValue();
final double absoluteAccuracy = getAbsoluteAccuracy();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/NewtonSolver.java
Fri Aug 31 19:40:30 2012
@@ -19,6 +19,7 @@ package org.apache.commons.math3.analysi
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 Abstra
*/
@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 Abstra
* {@inheritDoc}
*/
@Override
- protected double doSolve() {
+ protected double doSolve()
+ throws TooManyEvaluationsException {
final double startValue = getStartValue();
final double absoluteAccuracy = getAbsoluteAccuracy();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/RiddersSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/RiddersSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/RiddersSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/RiddersSolver.java
Fri Aug 31 19:40:30 2012
@@ -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 Abstr
* {@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
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/SecantSolver.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/SecantSolver.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/SecantSolver.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/SecantSolver.java
Fri Aug 31 19:40:30 2012
@@ -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 Abstra
/** {@inheritDoc} */
@Override
- protected final double doSolve() {
+ protected final double doSolve()
+ throws TooManyEvaluationsException,
+ NoBracketingException {
// Get initial solution
double x0 = getMin();
double x1 = getMax();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java?rev=1379560&r1=1379559&r2=1379560&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
Fri Aug 31 19:40:30 2012
@@ -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);
}