MATH-438
Removed deprecated methods. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1034896 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09e1c64fe9
commit
6a50b4cebc
|
@ -31,20 +31,6 @@ import org.apache.commons.math.util.FastMath;
|
|||
*/
|
||||
public class BisectionSolver extends UnivariateRealSolverImpl {
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
*
|
||||
* @param f function to solve.
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public BisectionSolver(UnivariateRealFunction f) {
|
||||
super(f, 100, 1E-6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver.
|
||||
*
|
||||
|
@ -53,20 +39,6 @@ public class BisectionSolver extends UnivariateRealSolverImpl {
|
|||
super(100, 1E-6);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(double min, double max, double initial)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(double min, double max)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double solve(final UnivariateRealFunction f, double min, double max, double initial)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
|
|
|
@ -48,20 +48,6 @@ public class BrentSolver extends UnivariateRealSolverImpl {
|
|||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 7694577816772532779L;
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
*
|
||||
* @param f function to solve.
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public BrentSolver(UnivariateRealFunction f) {
|
||||
super(f, DEFAULT_MAXIMUM_ITERATIONS, DEFAULT_ABSOLUTE_ACCURACY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver with default properties.
|
||||
*/
|
||||
|
@ -90,20 +76,6 @@ public class BrentSolver extends UnivariateRealSolverImpl {
|
|||
super(maximumIterations, absoluteAccuracy);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(double min, double max)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(double min, double max, double initial)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
return solve(f, min, max, initial);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a zero in the given interval with an initial guess.
|
||||
* <p>Throws <code>IllegalArgumentException</code> if the values of the
|
||||
|
|
|
@ -40,64 +40,11 @@ import org.apache.commons.math.util.FastMath;
|
|||
*/
|
||||
public class LaguerreSolver extends UnivariateRealSolverImpl {
|
||||
|
||||
/** polynomial function to solve.
|
||||
* @deprecated as of 2.0 the function is not stored anymore in the instance
|
||||
*/
|
||||
@Deprecated
|
||||
private final PolynomialFunction p;
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
*
|
||||
* @param f function to solve
|
||||
* @throws IllegalArgumentException if function is not polynomial
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public LaguerreSolver(UnivariateRealFunction f) throws
|
||||
IllegalArgumentException {
|
||||
super(f, 100, 1E-6);
|
||||
if (f instanceof PolynomialFunction) {
|
||||
p = (PolynomialFunction) f;
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.FUNCTION_NOT_POLYNOMIAL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver.
|
||||
*/
|
||||
public LaguerreSolver() {
|
||||
super(100, 1E-6);
|
||||
p = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the polynomial function.
|
||||
*
|
||||
* @return a fresh copy of the polynomial function
|
||||
* @deprecated as of 2.0 the function is not stored anymore within the instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public PolynomialFunction getPolynomialFunction() {
|
||||
return new PolynomialFunction(p.getCoefficients());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(p, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max, final double initial)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(p, min, max, initial);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,20 +38,6 @@ import org.apache.commons.math.util.MathUtils;
|
|||
*/
|
||||
public class MullerSolver extends UnivariateRealSolverImpl {
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
*
|
||||
* @param f function to solve
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public MullerSolver(UnivariateRealFunction f) {
|
||||
super(f, 100, 1E-6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver.
|
||||
*/
|
||||
|
@ -59,20 +45,6 @@ public class MullerSolver extends UnivariateRealSolverImpl {
|
|||
super(100, 1E-6);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max, final double initial)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(f, min, max, initial);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a real root in the given interval with initial value.
|
||||
* <p>
|
||||
|
@ -217,39 +189,6 @@ public class MullerSolver extends UnivariateRealSolverImpl {
|
|||
throw new MaxIterationsExceededException(maximalIterationCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a real root in the given interval.
|
||||
* <p>
|
||||
* solve2() differs from solve() in the way it avoids complex operations.
|
||||
* Except for the initial [min, max], solve2() does not require bracketing
|
||||
* condition, e.g. f(x0), f(x1), f(x2) can have the same sign. If complex
|
||||
* number arises in the computation, we simply use its modulus as real
|
||||
* approximation.</p>
|
||||
* <p>
|
||||
* Because the interval may not be bracketing, bisection alternative is
|
||||
* not applicable here. However in practice our treatment usually works
|
||||
* well, especially near real zeros where the imaginary part of complex
|
||||
* approximation is often negligible.</p>
|
||||
* <p>
|
||||
* The formulas here do not use divided differences directly.</p>
|
||||
*
|
||||
* @param min the lower bound for the interval
|
||||
* @param max the upper bound for the interval
|
||||
* @return the point at which the function value is zero
|
||||
* @throws MaxIterationsExceededException if the maximum iteration count is exceeded
|
||||
* or the solver detects convergence problems otherwise
|
||||
* @throws FunctionEvaluationException if an error occurs evaluating the
|
||||
* function
|
||||
* @throws IllegalArgumentException if any parameters are invalid
|
||||
* @deprecated replaced by {@link #solve2(UnivariateRealFunction, double, double)}
|
||||
* since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public double solve2(final double min, final double max)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
return solve2(f, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a real root in the given interval.
|
||||
* <p>
|
||||
|
|
|
@ -35,19 +35,6 @@ import org.apache.commons.math.util.FastMath;
|
|||
*/
|
||||
public class NewtonSolver extends UnivariateRealSolverImpl {
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
* @param f function to solve.
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public NewtonSolver(DifferentiableUnivariateRealFunction f) {
|
||||
super(f, 100, 1E-6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver.
|
||||
*/
|
||||
|
@ -55,21 +42,6 @@ public class NewtonSolver extends UnivariateRealSolverImpl {
|
|||
super(100, 1E-6);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max)
|
||||
throws MaxIterationsExceededException,
|
||||
FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max, final double startValue)
|
||||
throws MaxIterationsExceededException, FunctionEvaluationException {
|
||||
return solve(f, min, max, startValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a zero near the midpoint of <code>min</code> and <code>max</code>.
|
||||
*
|
||||
|
|
|
@ -37,20 +37,6 @@ import org.apache.commons.math.util.MathUtils;
|
|||
*/
|
||||
public class RiddersSolver extends UnivariateRealSolverImpl {
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
*
|
||||
* @param f function to solve
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public RiddersSolver(UnivariateRealFunction f) {
|
||||
super(f, 100, 1E-6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver.
|
||||
*/
|
||||
|
@ -58,20 +44,6 @@ public class RiddersSolver extends UnivariateRealSolverImpl {
|
|||
super(100, 1E-6);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max, final double initial)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(f, min, max, initial);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a root in the given interval with initial value.
|
||||
* <p>
|
||||
|
|
|
@ -43,19 +43,6 @@ import org.apache.commons.math.util.FastMath;
|
|||
*/
|
||||
public class SecantSolver extends UnivariateRealSolverImpl {
|
||||
|
||||
/**
|
||||
* Construct a solver for the given function.
|
||||
* @param f function to solve.
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
public SecantSolver(UnivariateRealFunction f) {
|
||||
super(f, 100, 1E-6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver.
|
||||
*/
|
||||
|
@ -63,20 +50,6 @@ public class SecantSolver extends UnivariateRealSolverImpl {
|
|||
super(100, 1E-6);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(f, min, max);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Deprecated
|
||||
public double solve(final double min, final double max, final double initial)
|
||||
throws ConvergenceException, FunctionEvaluationException {
|
||||
return solve(f, min, max, initial);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a zero in the given interval.
|
||||
*
|
||||
|
|
|
@ -58,28 +58,6 @@ public interface UnivariateRealSolver extends ConvergingAlgorithm {
|
|||
*/
|
||||
void resetFunctionValueAccuracy();
|
||||
|
||||
/**
|
||||
* Solve for a zero root in the given interval.
|
||||
* <p>A solver may require that the interval brackets a single zero root.
|
||||
* Solvers that do require bracketing should be able to handle the case
|
||||
* where one of the endpoints is itself a root.</p>
|
||||
*
|
||||
* @param min the lower bound for the interval.
|
||||
* @param max the upper bound for the interval.
|
||||
* @return a value where the function is zero
|
||||
* @throws ConvergenceException if the maximum iteration count is exceeded
|
||||
* or the solver detects convergence problems otherwise.
|
||||
* @throws FunctionEvaluationException if an error occurs evaluating the
|
||||
* function
|
||||
* @throws IllegalArgumentException if min > max or the endpoints do not
|
||||
* satisfy the requirements specified by the solver
|
||||
* @deprecated replaced by {@link #solve(UnivariateRealFunction, double, double)}
|
||||
* since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
double solve(double min, double max) throws ConvergenceException,
|
||||
FunctionEvaluationException;
|
||||
|
||||
/**
|
||||
* Solve for a zero root in the given interval.
|
||||
* <p>A solver may require that the interval brackets a single zero root.
|
||||
|
@ -102,29 +80,6 @@ public interface UnivariateRealSolver extends ConvergingAlgorithm {
|
|||
throws ConvergenceException,
|
||||
FunctionEvaluationException;
|
||||
|
||||
/**
|
||||
* Solve for a zero in the given interval, start at startValue.
|
||||
* <p>A solver may require that the interval brackets a single zero root.
|
||||
* Solvers that do require bracketing should be able to handle the case
|
||||
* where one of the endpoints is itself a root.</p>
|
||||
*
|
||||
* @param min the lower bound for the interval.
|
||||
* @param max the upper bound for the interval.
|
||||
* @param startValue the start value to use
|
||||
* @return a value where the function is zero
|
||||
* @throws ConvergenceException if the maximum iteration count is exceeded
|
||||
* or the solver detects convergence problems otherwise.
|
||||
* @throws FunctionEvaluationException if an error occurs evaluating the
|
||||
* function
|
||||
* @throws IllegalArgumentException if min > max or the arguments do not
|
||||
* satisfy the requirements specified by the solver
|
||||
* @deprecated replaced by {@link #solve(UnivariateRealFunction, double, double, double)}
|
||||
* since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
double solve(double min, double max, double startValue)
|
||||
throws ConvergenceException, FunctionEvaluationException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Solve for a zero in the given interval, start at startValue.
|
||||
* <p>A solver may require that the interval brackets a single zero root.
|
||||
|
|
|
@ -48,40 +48,6 @@ public abstract class UnivariateRealSolverImpl
|
|||
/** Value of the function at the last computed result. */
|
||||
protected double functionValue;
|
||||
|
||||
/** The function to solve.
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method. */
|
||||
@Deprecated
|
||||
protected UnivariateRealFunction f;
|
||||
|
||||
/**
|
||||
* Construct a solver with given iteration count and accuracy.
|
||||
*
|
||||
* @param f the function to solve.
|
||||
* @param defaultAbsoluteAccuracy maximum absolute error
|
||||
* @param defaultMaximalIterationCount maximum number of iterations
|
||||
* @throws IllegalArgumentException if f is null or the
|
||||
* defaultAbsoluteAccuracy is not valid
|
||||
* @deprecated as of 2.0 the function to solve is passed as an argument
|
||||
* to the {@link #solve(UnivariateRealFunction, double, double)} or
|
||||
* {@link UnivariateRealSolverImpl#solve(UnivariateRealFunction, double, double, double)}
|
||||
* method.
|
||||
*/
|
||||
@Deprecated
|
||||
protected UnivariateRealSolverImpl(final UnivariateRealFunction f,
|
||||
final int defaultMaximalIterationCount,
|
||||
final double defaultAbsoluteAccuracy) {
|
||||
super(defaultMaximalIterationCount, defaultAbsoluteAccuracy);
|
||||
if (f == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
this.f = f;
|
||||
this.defaultFunctionValueAccuracy = 1.0e-15;
|
||||
this.functionValueAccuracy = defaultFunctionValueAccuracy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a solver with given iteration count and accuracy.
|
||||
*
|
||||
|
|
|
@ -29,19 +29,6 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public final class BisectionSolverTest extends TestCase {
|
||||
|
||||
@Deprecated
|
||||
public void testDeprecated() throws MathException {
|
||||
UnivariateRealFunction f = new SinFunction();
|
||||
double result;
|
||||
|
||||
UnivariateRealSolver solver = new BisectionSolver(f);
|
||||
result = solver.solve(3, 4);
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
|
||||
result = solver.solve(1, 4);
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
}
|
||||
|
||||
public void testSinZero() throws MathException {
|
||||
UnivariateRealFunction f = new SinFunction();
|
||||
double result;
|
||||
|
|
|
@ -42,44 +42,6 @@ public final class BrentSolverTest extends TestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void testDeprecated() throws MathException {
|
||||
// The sinus function is behaved well around the root at #pi. The second
|
||||
// order derivative is zero, which means linar approximating methods will
|
||||
// still converge quadratically.
|
||||
UnivariateRealFunction f = new SinFunction();
|
||||
double result;
|
||||
UnivariateRealSolver solver = new BrentSolver(f);
|
||||
// Somewhat benign interval. The function is monotone.
|
||||
result = solver.solve(3, 4);
|
||||
//System.out.println(
|
||||
// "Root: " + result + " Iterations: " + solver.getIterationCount());
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
// 4 iterations on i586 JDK 1.4.1.
|
||||
assertTrue(solver.getIterationCount() <= 5);
|
||||
// Larger and somewhat less benign interval. The function is grows first.
|
||||
result = solver.solve(1, 4);
|
||||
//System.out.println(
|
||||
// "Root: " + result + " Iterations: " + solver.getIterationCount());
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
// 5 iterations on i586 JDK 1.4.1.
|
||||
assertTrue(solver.getIterationCount() <= 6);
|
||||
solver = new SecantSolver(f);
|
||||
result = solver.solve(3, 4);
|
||||
//System.out.println(
|
||||
// "Root: " + result + " Iterations: " + solver.getIterationCount());
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
// 4 iterations on i586 JDK 1.4.1.
|
||||
assertTrue(solver.getIterationCount() <= 5);
|
||||
result = solver.solve(1, 4);
|
||||
//System.out.println(
|
||||
// "Root: " + result + " Iterations: " + solver.getIterationCount());
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
// 5 iterations on i586 JDK 1.4.1.
|
||||
assertTrue(solver.getIterationCount() <= 6);
|
||||
assertEquals(result, solver.getResult(), 0);
|
||||
}
|
||||
|
||||
public void testSinZero() throws MathException {
|
||||
// The sinus function is behaved well around the root at #pi. The second
|
||||
// order derivative is zero, which means linar approximating methods will
|
||||
|
|
|
@ -37,25 +37,6 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public final class LaguerreSolverTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test deprecated APIs.
|
||||
*/
|
||||
@Deprecated
|
||||
public void testDeprecated() throws MathException {
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
// p(x) = 4x - 1
|
||||
double coefficients[] = { -1.0, 4.0 };
|
||||
PolynomialFunction f = new PolynomialFunction(coefficients);
|
||||
UnivariateRealSolver solver = new LaguerreSolver(f);
|
||||
|
||||
min = 0.0; max = 1.0; expected = 0.25;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of solver for the linear function.
|
||||
*/
|
||||
|
|
|
@ -40,56 +40,6 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public final class MullerSolverTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test deprecated APIs.
|
||||
*/
|
||||
@Deprecated
|
||||
public void testDeprecated() throws MathException {
|
||||
UnivariateRealFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver(f);
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = 3.0; max = 4.0; expected = FastMath.PI;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
|
||||
min = -1.0; max = 1.5; expected = 0.0;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deprecated APIs.
|
||||
*/
|
||||
@Deprecated
|
||||
public void testDeprecated2() throws MathException {
|
||||
UnivariateRealFunction f = new QuinticFunction();
|
||||
MullerSolver solver = new MullerSolver(f);
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -0.4; max = 0.2; expected = 0.0;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve2(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
|
||||
min = 0.75; max = 1.5; expected = 1.0;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve2(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
|
||||
min = -0.9; max = -0.2; expected = -0.5;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve2(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of solver for the sine function.
|
||||
*/
|
||||
|
|
|
@ -30,16 +30,18 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public final class NewtonSolverTest extends TestCase {
|
||||
|
||||
@Deprecated
|
||||
public void testDeprecated() throws MathException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testSinZero() throws MathException {
|
||||
DifferentiableUnivariateRealFunction f = new SinFunction();
|
||||
double result;
|
||||
|
||||
UnivariateRealSolver solver = new NewtonSolver(f);
|
||||
result = solver.solve(3, 4);
|
||||
UnivariateRealSolver solver = new NewtonSolver();
|
||||
result = solver.solve(f, 3, 4);
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
|
||||
result = solver.solve(1, 4);
|
||||
result = solver.solve(f, 1, 4);
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
|
||||
assertEquals(result, solver.getResult(), 0);
|
||||
|
@ -47,24 +49,6 @@ public final class NewtonSolverTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testSinZero() throws MathException {
|
||||
DifferentiableUnivariateRealFunction f = new SinFunction();
|
||||
double result;
|
||||
|
||||
UnivariateRealSolver solver = new NewtonSolver();
|
||||
result = solver.solve(f, 3, 4);
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
|
||||
result = solver.solve(f, 1, 4);
|
||||
assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
|
||||
|
||||
assertEquals(result, solver.getResult(), 0);
|
||||
assertTrue(solver.getIterationCount() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testQuinticZero() throws MathException {
|
||||
|
|
|
@ -38,28 +38,6 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public final class RiddersSolverTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test the deprecated APIs.
|
||||
*/
|
||||
@Deprecated
|
||||
public void testDeprecated() throws MathException {
|
||||
UnivariateRealFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new RiddersSolver(f);
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = 3.0; max = 4.0; expected = FastMath.PI;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
|
||||
min = -1.0; max = 1.5; expected = 0.0;
|
||||
tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
|
||||
FastMath.abs(expected * solver.getRelativeAccuracy()));
|
||||
result = solver.solve(min, max);
|
||||
assertEquals(expected, result, tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of solver for the sine function.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue