MATH-707
Removed "Real" from class names in package "o.a.c.m.analysis.solvers". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1234784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cd57ad4c3d
commit
a04a6c16c6
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math.analysis.integration;
|
||||
|
||||
import org.apache.commons.math.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolverUtils;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MaxCountExceededException;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
|
@ -226,7 +226,7 @@ public abstract class UnivariateRealIntegratorImpl implements UnivariateRealInte
|
|||
|
||||
// Checks.
|
||||
MathUtils.checkNotNull(f);
|
||||
UnivariateRealSolverUtils.verifyInterval(lower, upper);
|
||||
UnivariateSolverUtils.verifyInterval(lower, upper);
|
||||
|
||||
// Reset.
|
||||
this.min = lower;
|
||||
|
|
|
@ -27,9 +27,9 @@ import org.apache.commons.math.analysis.UnivariateFunction;
|
|||
* @version $Id$
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class AbstractDifferentiableUnivariateRealSolver
|
||||
extends BaseAbstractUnivariateRealSolver<DifferentiableUnivariateFunction>
|
||||
implements DifferentiableUnivariateRealSolver {
|
||||
public abstract class AbstractDifferentiableUnivariateSolver
|
||||
extends BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction>
|
||||
implements DifferentiableUnivariateSolver {
|
||||
/** Derivative of the function to solve. */
|
||||
private UnivariateFunction functionDerivative;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public abstract class AbstractDifferentiableUnivariateRealSolver
|
|||
*
|
||||
* @param absoluteAccuracy Maximum absolute error.
|
||||
*/
|
||||
protected AbstractDifferentiableUnivariateRealSolver(final double absoluteAccuracy) {
|
||||
protected AbstractDifferentiableUnivariateSolver(final double absoluteAccuracy) {
|
||||
super(absoluteAccuracy);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public abstract class AbstractDifferentiableUnivariateRealSolver
|
|||
* @param absoluteAccuracy Maximum absolute error.
|
||||
* @param functionValueAccuracy Maximum function value error.
|
||||
*/
|
||||
protected AbstractDifferentiableUnivariateRealSolver(final double relativeAccuracy,
|
||||
protected AbstractDifferentiableUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy);
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
|
|||
* @since 3.0
|
||||
*/
|
||||
public abstract class AbstractPolynomialSolver
|
||||
extends BaseAbstractUnivariateRealSolver<PolynomialFunction>
|
||||
extends BaseAbstractUnivariateSolver<PolynomialFunction>
|
||||
implements PolynomialSolver {
|
||||
/** Function. */
|
||||
private PolynomialFunction polynomialFunction;
|
||||
|
|
|
@ -25,15 +25,15 @@ import org.apache.commons.math.analysis.UnivariateFunction;
|
|||
* @version $Id$
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class AbstractUnivariateRealSolver
|
||||
extends BaseAbstractUnivariateRealSolver<UnivariateFunction>
|
||||
implements UnivariateRealSolver {
|
||||
public abstract class AbstractUnivariateSolver
|
||||
extends BaseAbstractUnivariateSolver<UnivariateFunction>
|
||||
implements UnivariateSolver {
|
||||
/**
|
||||
* Construct a solver with given absolute accuracy.
|
||||
*
|
||||
* @param absoluteAccuracy Maximum absolute error.
|
||||
*/
|
||||
protected AbstractUnivariateRealSolver(final double absoluteAccuracy) {
|
||||
protected AbstractUnivariateSolver(final double absoluteAccuracy) {
|
||||
super(absoluteAccuracy);
|
||||
}
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ public abstract class AbstractUnivariateRealSolver
|
|||
* @param relativeAccuracy Maximum relative error.
|
||||
* @param absoluteAccuracy Maximum absolute error.
|
||||
*/
|
||||
protected AbstractUnivariateRealSolver(final double relativeAccuracy,
|
||||
protected AbstractUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy) {
|
||||
super(relativeAccuracy, absoluteAccuracy);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public abstract class AbstractUnivariateRealSolver
|
|||
* @param absoluteAccuracy Maximum absolute error.
|
||||
* @param functionValueAccuracy Maximum function value error.
|
||||
*/
|
||||
protected AbstractUnivariateRealSolver(final double relativeAccuracy,
|
||||
protected AbstractUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy);
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
|
||||
/** The kinds of solutions that a {@link BracketedUnivariateRealSolver
|
||||
/** The kinds of solutions that a {@link BracketedUnivariateSolver
|
||||
* (bracketed univariate real) root-finding algorithm} may accept as solutions.
|
||||
* This basically controls whether or not under-approximations and
|
||||
* over-approximations are allowed.
|
||||
|
@ -34,7 +34,7 @@ package org.apache.commons.math.analysis.solvers;
|
|||
* may be necessary to guarantee that a solution is returned that lies on a
|
||||
* specific side the solution.</p>
|
||||
*
|
||||
* @see BracketedUnivariateRealSolver
|
||||
* @see BracketedUnivariateSolver
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
*/
|
||||
|
|
|
@ -33,8 +33,8 @@ import org.apache.commons.math.util.MathUtils;
|
|||
* @version $Id$
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFunction>
|
||||
implements BaseUnivariateRealSolver<FUNC> {
|
||||
public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFunction>
|
||||
implements BaseUnivariateSolver<FUNC> {
|
||||
/** Default relative accuracy. */
|
||||
private static final double DEFAULT_RELATIVE_ACCURACY = 1e-14;
|
||||
/** Default function value accuracy. */
|
||||
|
@ -61,7 +61,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
*
|
||||
* @param absoluteAccuracy Maximum absolute error.
|
||||
*/
|
||||
protected BaseAbstractUnivariateRealSolver(final double absoluteAccuracy) {
|
||||
protected BaseAbstractUnivariateSolver(final double absoluteAccuracy) {
|
||||
this(DEFAULT_RELATIVE_ACCURACY,
|
||||
absoluteAccuracy,
|
||||
DEFAULT_FUNCTION_VALUE_ACCURACY);
|
||||
|
@ -73,7 +73,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
* @param relativeAccuracy Maximum relative error.
|
||||
* @param absoluteAccuracy Maximum absolute error.
|
||||
*/
|
||||
protected BaseAbstractUnivariateRealSolver(final double relativeAccuracy,
|
||||
protected BaseAbstractUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy) {
|
||||
this(relativeAccuracy,
|
||||
absoluteAccuracy,
|
||||
|
@ -87,7 +87,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
* @param absoluteAccuracy Maximum absolute error.
|
||||
* @param functionValueAccuracy Maximum function value error.
|
||||
*/
|
||||
protected BaseAbstractUnivariateRealSolver(final double relativeAccuracy,
|
||||
protected BaseAbstractUnivariateSolver(final double relativeAccuracy,
|
||||
final double absoluteAccuracy,
|
||||
final double functionValueAccuracy) {
|
||||
this.absoluteAccuracy = absoluteAccuracy;
|
||||
|
@ -223,7 +223,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
*/
|
||||
protected boolean isBracketing(final double lower,
|
||||
final double upper) {
|
||||
return UnivariateRealSolverUtils.isBracketing(function, lower, upper);
|
||||
return UnivariateSolverUtils.isBracketing(function, lower, upper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,7 +237,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
protected boolean isSequence(final double start,
|
||||
final double mid,
|
||||
final double end) {
|
||||
return UnivariateRealSolverUtils.isSequence(start, mid, end);
|
||||
return UnivariateSolverUtils.isSequence(start, mid, end);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +250,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
*/
|
||||
protected void verifyInterval(final double lower,
|
||||
final double upper) {
|
||||
UnivariateRealSolverUtils.verifyInterval(lower, upper);
|
||||
UnivariateSolverUtils.verifyInterval(lower, upper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,7 +265,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
protected void verifySequence(final double lower,
|
||||
final double initial,
|
||||
final double upper) {
|
||||
UnivariateRealSolverUtils.verifySequence(lower, initial, upper);
|
||||
UnivariateSolverUtils.verifySequence(lower, initial, upper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -279,7 +279,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
*/
|
||||
protected void verifyBracketing(final double lower,
|
||||
final double upper) {
|
||||
UnivariateRealSolverUtils.verifyBracketing(function, lower, upper);
|
||||
UnivariateSolverUtils.verifyBracketing(function, lower, upper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,7 +287,7 @@ public abstract class BaseAbstractUnivariateRealSolver<FUNC extends UnivariateFu
|
|||
* Method {@link #computeObjectiveValue(double)} calls this method internally.
|
||||
* It is provided for subclasses that do not exclusively use
|
||||
* {@code computeObjectiveValue} to solve the function.
|
||||
* See e.g. {@link AbstractDifferentiableUnivariateRealSolver}.
|
||||
* See e.g. {@link AbstractDifferentiableUnivariateSolver}.
|
||||
*/
|
||||
protected void incrementEvaluationCount() {
|
||||
try {
|
|
@ -47,8 +47,8 @@ import org.apache.commons.math.exception.MathInternalError;
|
|||
* @version $Id$
|
||||
*/
|
||||
public abstract class BaseSecantSolver
|
||||
extends AbstractUnivariateRealSolver
|
||||
implements BracketedUnivariateRealSolver<UnivariateFunction> {
|
||||
extends AbstractUnivariateSolver
|
||||
implements BracketedUnivariateSolver<UnivariateFunction> {
|
||||
|
||||
/** Default absolute accuracy. */
|
||||
protected static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
|
|
@ -25,17 +25,17 @@ import org.apache.commons.math.analysis.UnivariateFunction;
|
|||
*
|
||||
* This class is not intended for use outside of the Apache Commons Math
|
||||
* library, regular user should rely on more specific interfaces like
|
||||
* {@link UnivariateRealSolver}, {@link PolynomialSolver} or {@link
|
||||
* DifferentiableUnivariateRealSolver}.
|
||||
* {@link UnivariateSolver}, {@link PolynomialSolver} or {@link
|
||||
* DifferentiableUnivariateSolver}.
|
||||
* @param <FUNC> Type of function to solve.
|
||||
*
|
||||
* @version $Id$
|
||||
* @since 3.0
|
||||
* @see UnivariateRealSolver
|
||||
* @see UnivariateSolver
|
||||
* @see PolynomialSolver
|
||||
* @see DifferentiableUnivariateRealSolver
|
||||
* @see DifferentiableUnivariateSolver
|
||||
*/
|
||||
public interface BaseUnivariateRealSolver<FUNC extends UnivariateFunction> {
|
||||
public interface BaseUnivariateSolver<FUNC extends UnivariateFunction> {
|
||||
/**
|
||||
* Get the maximum number of function evaluations.
|
||||
*
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BisectionSolver extends AbstractUnivariateRealSolver {
|
||||
public class BisectionSolver extends AbstractUnivariateSolver {
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class BisectionSolver extends AbstractUnivariateRealSolver {
|
|||
double fmin;
|
||||
|
||||
while (true) {
|
||||
m = UnivariateRealSolverUtils.midpoint(min, max);
|
||||
m = UnivariateSolverUtils.midpoint(min, max);
|
||||
fmin = computeObjectiveValue(min);
|
||||
fm = computeObjectiveValue(m);
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class BisectionSolver extends AbstractUnivariateRealSolver {
|
|||
}
|
||||
|
||||
if (FastMath.abs(max - min) <= absoluteAccuracy) {
|
||||
m = UnivariateRealSolverUtils.midpoint(min, max);
|
||||
m = UnivariateSolverUtils.midpoint(min, max);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.analysis.solvers;
|
|||
|
||||
import org.apache.commons.math.analysis.UnivariateFunction;
|
||||
|
||||
/** Interface for {@link UnivariateRealSolver (univariate real) root-finding
|
||||
/** Interface for {@link UnivariateSolver (univariate real) root-finding
|
||||
* algorithms} that maintain a bracketed solution. There are several advantages
|
||||
* to having such root-finding algorithms:
|
||||
* <ul>
|
||||
|
@ -44,8 +44,8 @@ import org.apache.commons.math.analysis.UnivariateFunction;
|
|||
* @since 3.0
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface BracketedUnivariateRealSolver<FUNC extends UnivariateFunction>
|
||||
extends BaseUnivariateRealSolver<FUNC> {
|
||||
public interface BracketedUnivariateSolver<FUNC extends UnivariateFunction>
|
||||
extends BaseUnivariateSolver<FUNC> {
|
||||
|
||||
/**
|
||||
* Solve for a zero in the given interval.
|
|
@ -41,8 +41,8 @@ import org.apache.commons.math.util.Precision;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class BracketingNthOrderBrentSolver
|
||||
extends AbstractUnivariateRealSolver
|
||||
implements BracketedUnivariateRealSolver<UnivariateFunction> {
|
||||
extends AbstractUnivariateSolver
|
||||
implements BracketedUnivariateSolver<UnivariateFunction> {
|
||||
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.commons.math.util.Precision;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BrentSolver extends AbstractUnivariateRealSolver {
|
||||
public class BrentSolver extends AbstractUnivariateSolver {
|
||||
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
|
|
@ -25,5 +25,5 @@ import org.apache.commons.math.analysis.DifferentiableUnivariateFunction;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface DifferentiableUnivariateRealSolver
|
||||
extends BaseUnivariateRealSolver<DifferentiableUnivariateFunction> {}
|
||||
public interface DifferentiableUnivariateSolver
|
||||
extends BaseUnivariateSolver<DifferentiableUnivariateFunction> {}
|
|
@ -44,7 +44,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
* @since 1.2
|
||||
* @see MullerSolver2
|
||||
*/
|
||||
public class MullerSolver extends AbstractUnivariateRealSolver {
|
||||
public class MullerSolver extends AbstractUnivariateSolver {
|
||||
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
* @since 1.2
|
||||
* @see MullerSolver
|
||||
*/
|
||||
public class MullerSolver2 extends AbstractUnivariateRealSolver {
|
||||
public class MullerSolver2 extends AbstractUnivariateSolver {
|
||||
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class NewtonSolver extends AbstractDifferentiableUnivariateRealSolver {
|
||||
public class NewtonSolver extends AbstractDifferentiableUnivariateSolver {
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class NewtonSolver extends AbstractDifferentiableUnivariateRealSolver {
|
|||
@Override
|
||||
public double solve(int maxEval, final DifferentiableUnivariateFunction f,
|
||||
final double min, final double max) {
|
||||
return super.solve(maxEval, f, UnivariateRealSolverUtils.midpoint(min, max));
|
||||
return super.solve(maxEval, f, UnivariateSolverUtils.midpoint(min, max));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,4 +26,4 @@ import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
|
|||
* @since 3.0
|
||||
*/
|
||||
public interface PolynomialSolver
|
||||
extends BaseUnivariateRealSolver<PolynomialFunction> {}
|
||||
extends BaseUnivariateSolver<PolynomialFunction> {}
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
* @version $Id$
|
||||
* @since 1.2
|
||||
*/
|
||||
public class RiddersSolver extends AbstractUnivariateRealSolver {
|
||||
public class RiddersSolver extends AbstractUnivariateSolver {
|
||||
/** Default absolute accuracy. */
|
||||
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SecantSolver extends AbstractUnivariateRealSolver {
|
||||
public class SecantSolver extends AbstractUnivariateSolver {
|
||||
|
||||
/** Default absolute accuracy. */
|
||||
protected static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
||||
|
|
|
@ -25,5 +25,5 @@ import org.apache.commons.math.analysis.UnivariateFunction;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface UnivariateRealSolver
|
||||
extends BaseUnivariateRealSolver<UnivariateFunction> {}
|
||||
public interface UnivariateSolver
|
||||
extends BaseUnivariateSolver<UnivariateFunction> {}
|
|
@ -25,15 +25,15 @@ import org.apache.commons.math.exception.util.LocalizedFormats;
|
|||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
/**
|
||||
* Utility routines for {@link UnivariateRealSolver} objects.
|
||||
* Utility routines for {@link UnivariateSolver} objects.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class UnivariateRealSolverUtils {
|
||||
public class UnivariateSolverUtils {
|
||||
/**
|
||||
* Class contains only static methods.
|
||||
*/
|
||||
private UnivariateRealSolverUtils() {}
|
||||
private UnivariateSolverUtils() {}
|
||||
|
||||
/**
|
||||
* Convenience method to find a zero of a univariate real function. A default
|
||||
|
@ -50,7 +50,7 @@ public class UnivariateRealSolverUtils {
|
|||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
final UnivariateRealSolver solver = new BrentSolver();
|
||||
final UnivariateSolver solver = new BrentSolver();
|
||||
return solver.solve(Integer.MAX_VALUE, function, x0, x1);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class UnivariateRealSolverUtils {
|
|||
if (function == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FUNCTION);
|
||||
}
|
||||
final UnivariateRealSolver solver = new BrentSolver(absoluteAccuracy);
|
||||
final UnivariateSolver solver = new BrentSolver(absoluteAccuracy);
|
||||
return solver.solve(Integer.MAX_VALUE, function, x0, x1);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class UnivariateRealSolverUtils {
|
|||
* @return a root approximation, on the specified side of the exact root
|
||||
*/
|
||||
public static double forceSide(final int maxEval, final UnivariateFunction f,
|
||||
final BracketedUnivariateRealSolver<UnivariateFunction> bracketing,
|
||||
final BracketedUnivariateSolver<UnivariateFunction> bracketing,
|
||||
final double baseRoot, final double min, final double max,
|
||||
final AllowedSolution allowedSolution) {
|
||||
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.distribution;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolverUtils;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
|
@ -153,7 +153,7 @@ implements RealDistribution, Serializable {
|
|||
}
|
||||
};
|
||||
|
||||
double x = UnivariateRealSolverUtils.solve(toSolve,
|
||||
double x = UnivariateSolverUtils.solve(toSolve,
|
||||
lowerBound,
|
||||
upperBound,
|
||||
getSolverAbsoluteAccuracy());
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.SortedSet;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.math.analysis.solvers.BracketingNthOrderBrentSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolver;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
|
@ -135,7 +135,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
final double maxCheckInterval,
|
||||
final double convergence,
|
||||
final int maxIterationCount,
|
||||
final UnivariateRealSolver solver) {
|
||||
final UnivariateSolver solver) {
|
||||
eventsStates.add(new EventState(handler, maxCheckInterval, convergence,
|
||||
maxIterationCount, solver));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.ode;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolver;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public interface ODEIntegrator {
|
|||
void clearStepHandlers();
|
||||
|
||||
/** Add an event handler to the integrator.
|
||||
* Uses a default {@link UnivariateRealSolver}
|
||||
* Uses a default {@link UnivariateSolver}
|
||||
* with an absolute accuracy equal to the given convergence threshold,
|
||||
* as root-finding algorithm to detect the state events.
|
||||
* @param handler event handler
|
||||
|
@ -95,7 +95,7 @@ public interface ODEIntegrator {
|
|||
*/
|
||||
void addEventHandler(EventHandler handler, double maxCheckInterval,
|
||||
double convergence, int maxIterationCount,
|
||||
UnivariateRealSolver solver);
|
||||
UnivariateSolver solver);
|
||||
|
||||
/** Get all the event handlers that have been added to the integrator.
|
||||
* @return an unmodifiable collection of the added events handlers
|
||||
|
|
|
@ -19,10 +19,10 @@ package org.apache.commons.math.ode.events;
|
|||
|
||||
import org.apache.commons.math.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math.analysis.solvers.AllowedSolution;
|
||||
import org.apache.commons.math.analysis.solvers.BracketedUnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.BracketedUnivariateSolver;
|
||||
import org.apache.commons.math.analysis.solvers.PegasusSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolverUtils;
|
||||
import org.apache.commons.math.exception.ConvergenceException;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
@ -85,7 +85,7 @@ public class EventState {
|
|||
private EventHandler.Action nextAction;
|
||||
|
||||
/** Root-finding algorithm to use to detect state events. */
|
||||
private final UnivariateRealSolver solver;
|
||||
private final UnivariateSolver solver;
|
||||
|
||||
/** Simple constructor.
|
||||
* @param handler event handler
|
||||
|
@ -99,7 +99,7 @@ public class EventState {
|
|||
*/
|
||||
public EventState(final EventHandler handler, final double maxCheckInterval,
|
||||
final double convergence, final int maxIterationCount,
|
||||
final UnivariateRealSolver solver) {
|
||||
final UnivariateSolver solver) {
|
||||
this.handler = handler;
|
||||
this.maxCheckInterval = maxCheckInterval;
|
||||
this.convergence = FastMath.abs(convergence);
|
||||
|
@ -222,10 +222,10 @@ public class EventState {
|
|||
|
||||
// find the event time making sure we select a solution just at or past the exact root
|
||||
final double root;
|
||||
if (solver instanceof BracketedUnivariateRealSolver<?>) {
|
||||
if (solver instanceof BracketedUnivariateSolver<?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
BracketedUnivariateRealSolver<UnivariateFunction> bracketing =
|
||||
(BracketedUnivariateRealSolver<UnivariateFunction>) solver;
|
||||
BracketedUnivariateSolver<UnivariateFunction> bracketing =
|
||||
(BracketedUnivariateSolver<UnivariateFunction>) solver;
|
||||
root = forward ?
|
||||
bracketing.solve(maxIterationCount, f, ta, tb, AllowedSolution.RIGHT_SIDE) :
|
||||
bracketing.solve(maxIterationCount, f, tb, ta, AllowedSolution.LEFT_SIDE);
|
||||
|
@ -234,12 +234,12 @@ public class EventState {
|
|||
solver.solve(maxIterationCount, f, ta, tb) :
|
||||
solver.solve(maxIterationCount, f, tb, ta);
|
||||
final int remainingEval = maxIterationCount - solver.getEvaluations();
|
||||
BracketedUnivariateRealSolver<UnivariateFunction> bracketing =
|
||||
BracketedUnivariateSolver<UnivariateFunction> bracketing =
|
||||
new PegasusSolver(solver.getRelativeAccuracy(), solver.getAbsoluteAccuracy());
|
||||
root = forward ?
|
||||
UnivariateRealSolverUtils.forceSide(remainingEval, f, bracketing,
|
||||
UnivariateSolverUtils.forceSide(remainingEval, f, bracketing,
|
||||
baseRoot, ta, tb, AllowedSolution.RIGHT_SIDE) :
|
||||
UnivariateRealSolverUtils.forceSide(remainingEval, f, bracketing,
|
||||
UnivariateSolverUtils.forceSide(remainingEval, f, bracketing,
|
||||
baseRoot, tb, ta, AllowedSolution.LEFT_SIDE);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolver;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.ode.ExpandableStatefulODE;
|
||||
|
@ -348,7 +348,7 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
final double maxCheckInterval,
|
||||
final double convergence,
|
||||
final int maxIterationCount,
|
||||
final UnivariateRealSolver solver) {
|
||||
final UnivariateSolver solver) {
|
||||
super.addEventHandler(function, maxCheckInterval, convergence,
|
||||
maxIterationCount, solver);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.commons.math.optimization.general;
|
|||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math.analysis.solvers.BrentSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateSolver;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.RealPointValuePair;
|
||||
|
@ -47,7 +47,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
/** Preconditioner (may be null). */
|
||||
private final Preconditioner preconditioner;
|
||||
/** solver to use in the line search (may be null). */
|
||||
private final UnivariateRealSolver solver;
|
||||
private final UnivariateSolver solver;
|
||||
/** Initial step used to bracket the optimum in line search. */
|
||||
private double initialStep;
|
||||
/** Current point. */
|
||||
|
@ -96,7 +96,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
*/
|
||||
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula,
|
||||
ConvergenceChecker<RealPointValuePair> checker,
|
||||
final UnivariateRealSolver lineSearchSolver) {
|
||||
final UnivariateSolver lineSearchSolver) {
|
||||
this(updateFormula,
|
||||
checker,
|
||||
lineSearchSolver,
|
||||
|
@ -113,7 +113,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
*/
|
||||
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula,
|
||||
ConvergenceChecker<RealPointValuePair> checker,
|
||||
final UnivariateRealSolver lineSearchSolver,
|
||||
final UnivariateSolver lineSearchSolver,
|
||||
final Preconditioner preconditioner) {
|
||||
super(checker);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
/** Returns the solver to use to perform the tests.
|
||||
* @return the solver to use to perform the tests
|
||||
*/
|
||||
protected abstract UnivariateRealSolver getSolver();
|
||||
protected abstract UnivariateSolver getSolver();
|
||||
|
||||
/** Returns the expected number of evaluations for the
|
||||
* {@link #testQuinticZero} unit test. A value of {@code -1} indicates that
|
||||
|
@ -53,7 +53,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
// still converge quadratically.
|
||||
UnivariateFunction f = new SinFunction();
|
||||
double result;
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
|
||||
result = solver.solve(100, f, 3, 4);
|
||||
//System.out.println(
|
||||
|
@ -79,7 +79,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
// the solvers.
|
||||
UnivariateFunction f = new QuinticFunction();
|
||||
double result;
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
double atol = solver.getAbsoluteAccuracy();
|
||||
int[] counts = getQuinticEvalCounts();
|
||||
|
||||
|
@ -117,7 +117,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
@Test
|
||||
public void testRootEndpoints() {
|
||||
UnivariateFunction f = new XMinus5Function();
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
|
||||
// End-point is root. This should be a special case in the solver, and
|
||||
// the initial end-point should be returned exactly.
|
||||
|
@ -137,7 +137,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
@Test
|
||||
public void testBadEndpoints() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
try { // bad interval
|
||||
solver.solve(100, f, 1, -1);
|
||||
Assert.fail("Expecting NumberIsTooLargeException - bad interval");
|
||||
|
@ -161,7 +161,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
@Test
|
||||
public void testSolutionLeftSide() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
double left = -1.5;
|
||||
double right = 0.05;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
|
@ -180,7 +180,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
@Test
|
||||
public void testSolutionRightSide() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
double left = -1.5;
|
||||
double right = 0.05;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
|
@ -198,7 +198,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
@Test
|
||||
public void testSolutionBelowSide() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
double left = -1.5;
|
||||
double right = 0.05;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
|
@ -217,7 +217,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
@Test
|
||||
public void testSolutionAboveSide() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = getSolver();
|
||||
UnivariateSolver solver = getSolver();
|
||||
double left = -1.5;
|
||||
double right = 0.05;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
|
@ -233,12 +233,12 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
}
|
||||
}
|
||||
|
||||
private double getSolution(UnivariateRealSolver solver, int maxEval, UnivariateFunction f,
|
||||
private double getSolution(UnivariateSolver solver, int maxEval, UnivariateFunction f,
|
||||
double left, double right, AllowedSolution allowedSolution) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
BracketedUnivariateRealSolver<UnivariateFunction> bracketing =
|
||||
(BracketedUnivariateRealSolver<UnivariateFunction>) solver;
|
||||
BracketedUnivariateSolver<UnivariateFunction> bracketing =
|
||||
(BracketedUnivariateSolver<UnivariateFunction>) solver;
|
||||
return bracketing.solve(100, f, left, right, allowedSolution);
|
||||
} catch (ClassCastException cce) {
|
||||
double baseRoot = solver.solve(maxEval, f, left, right);
|
||||
|
@ -249,7 +249,7 @@ public abstract class BaseSecantSolverAbstractTest {
|
|||
PegasusSolver bracketing =
|
||||
new PegasusSolver(solver.getRelativeAccuracy(), solver.getAbsoluteAccuracy(),
|
||||
solver.getFunctionValueAccuracy());
|
||||
return UnivariateRealSolverUtils.forceSide(maxEval - solver.getEvaluations(),
|
||||
return UnivariateSolverUtils.forceSide(maxEval - solver.getEvaluations(),
|
||||
f, bracketing, baseRoot, left, right,
|
||||
allowedSolution);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.junit.Test;
|
|||
public final class BracketingNthOrderBrentSolverTest extends BaseSecantSolverAbstractTest {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected UnivariateRealSolver getSolver() {
|
||||
protected UnivariateSolver getSolver() {
|
||||
return new BracketingNthOrderBrentSolver();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class BrentSolverTest {
|
|||
// still converge quadratically.
|
||||
UnivariateFunction f = new SinFunction();
|
||||
double result;
|
||||
UnivariateRealSolver solver = new BrentSolver();
|
||||
UnivariateSolver solver = new BrentSolver();
|
||||
// Somewhat benign interval. The function is monotone.
|
||||
result = solver.solve(100, f, 3, 4);
|
||||
// System.out.println(
|
||||
|
@ -73,7 +73,7 @@ public final class BrentSolverTest {
|
|||
UnivariateFunction f = new QuinticFunction();
|
||||
double result;
|
||||
// Brent-Dekker solver.
|
||||
UnivariateRealSolver solver = new BrentSolver();
|
||||
UnivariateSolver solver = new BrentSolver();
|
||||
// Symmetric bracket around 0. Test whether solvers can handle hitting
|
||||
// the root in the first iteration.
|
||||
result = solver.solve(100, f, -0.2, 0.2);
|
||||
|
|
|
@ -25,7 +25,7 @@ package org.apache.commons.math.analysis.solvers;
|
|||
public final class IllinoisSolverTest extends BaseSecantSolverAbstractTest {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected UnivariateRealSolver getSolver() {
|
||||
protected UnivariateSolver getSolver() {
|
||||
return new IllinoisSolver();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class MullerSolver2Test {
|
|||
@Test
|
||||
public void testSinFunction() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver2();
|
||||
UnivariateSolver solver = new MullerSolver2();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = 3.0; max = 4.0; expected = FastMath.PI;
|
||||
|
@ -68,7 +68,7 @@ public final class MullerSolver2Test {
|
|||
@Test
|
||||
public void testQuinticFunction() {
|
||||
UnivariateFunction f = new QuinticFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver2();
|
||||
UnivariateSolver solver = new MullerSolver2();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -0.4; max = 0.2; expected = 0.0;
|
||||
|
@ -98,7 +98,7 @@ public final class MullerSolver2Test {
|
|||
@Test
|
||||
public void testExpm1Function() {
|
||||
UnivariateFunction f = new Expm1Function();
|
||||
UnivariateRealSolver solver = new MullerSolver2();
|
||||
UnivariateSolver solver = new MullerSolver2();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -1.0; max = 2.0; expected = 0.0;
|
||||
|
@ -126,7 +126,7 @@ public final class MullerSolver2Test {
|
|||
@Test
|
||||
public void testParameters() throws Exception {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver2();
|
||||
UnivariateSolver solver = new MullerSolver2();
|
||||
|
||||
try {
|
||||
// bad interval
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class MullerSolverTest {
|
|||
@Test
|
||||
public void testSinFunction() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver();
|
||||
UnivariateSolver solver = new MullerSolver();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = 3.0; max = 4.0; expected = FastMath.PI;
|
||||
|
@ -68,7 +68,7 @@ public final class MullerSolverTest {
|
|||
@Test
|
||||
public void testQuinticFunction() {
|
||||
UnivariateFunction f = new QuinticFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver();
|
||||
UnivariateSolver solver = new MullerSolver();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -0.4; max = 0.2; expected = 0.0;
|
||||
|
@ -100,7 +100,7 @@ public final class MullerSolverTest {
|
|||
@Test
|
||||
public void testExpm1Function() {
|
||||
UnivariateFunction f = new Expm1Function();
|
||||
UnivariateRealSolver solver = new MullerSolver();
|
||||
UnivariateSolver solver = new MullerSolver();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -1.0; max = 2.0; expected = 0.0;
|
||||
|
@ -128,7 +128,7 @@ public final class MullerSolverTest {
|
|||
@Test
|
||||
public void testParameters() throws Exception {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new MullerSolver();
|
||||
UnivariateSolver solver = new MullerSolver();
|
||||
|
||||
try {
|
||||
// bad interval
|
||||
|
|
|
@ -25,7 +25,7 @@ package org.apache.commons.math.analysis.solvers;
|
|||
public final class PegasusSolverTest extends BaseSecantSolverAbstractTest {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected UnivariateRealSolver getSolver() {
|
||||
protected UnivariateSolver getSolver() {
|
||||
return new PegasusSolver();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.Assert;
|
|||
public final class RegulaFalsiSolverTest extends BaseSecantSolverAbstractTest {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected UnivariateRealSolver getSolver() {
|
||||
protected UnivariateSolver getSolver() {
|
||||
return new RegulaFalsiSolver();
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public final class RegulaFalsiSolverTest extends BaseSecantSolverAbstractTest {
|
|||
}
|
||||
};
|
||||
|
||||
final UnivariateRealSolver solver = new RegulaFalsiSolver();
|
||||
final UnivariateSolver solver = new RegulaFalsiSolver();
|
||||
final double root = solver.solve(3624, f, 1, 10);
|
||||
Assert.assertEquals(3.4341896575482003, root, 1e-15);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class RiddersSolverTest {
|
|||
@Test
|
||||
public void testSinFunction() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new RiddersSolver();
|
||||
UnivariateSolver solver = new RiddersSolver();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = 3.0; max = 4.0; expected = FastMath.PI;
|
||||
|
@ -66,7 +66,7 @@ public final class RiddersSolverTest {
|
|||
@Test
|
||||
public void testQuinticFunction() {
|
||||
UnivariateFunction f = new QuinticFunction();
|
||||
UnivariateRealSolver solver = new RiddersSolver();
|
||||
UnivariateSolver solver = new RiddersSolver();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -0.4; max = 0.2; expected = 0.0;
|
||||
|
@ -94,7 +94,7 @@ public final class RiddersSolverTest {
|
|||
@Test
|
||||
public void testExpm1Function() {
|
||||
UnivariateFunction f = new Expm1Function();
|
||||
UnivariateRealSolver solver = new RiddersSolver();
|
||||
UnivariateSolver solver = new RiddersSolver();
|
||||
double min, max, expected, result, tolerance;
|
||||
|
||||
min = -1.0; max = 2.0; expected = 0.0;
|
||||
|
@ -122,7 +122,7 @@ public final class RiddersSolverTest {
|
|||
@Test
|
||||
public void testParameters() {
|
||||
UnivariateFunction f = new SinFunction();
|
||||
UnivariateRealSolver solver = new RiddersSolver();
|
||||
UnivariateSolver solver = new RiddersSolver();
|
||||
|
||||
try {
|
||||
// bad interval
|
||||
|
|
|
@ -25,7 +25,7 @@ package org.apache.commons.math.analysis.solvers;
|
|||
public final class SecantSolverTest extends BaseSecantSolverAbstractTest {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected UnivariateRealSolver getSolver() {
|
||||
protected UnivariateSolver getSolver() {
|
||||
return new SecantSolver();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,25 +28,25 @@ import org.junit.Test;
|
|||
/**
|
||||
* @version $Id$
|
||||
*/
|
||||
public class UnivariateRealSolverUtilsTest {
|
||||
public class UnivariateSolverUtilsTest {
|
||||
|
||||
protected UnivariateFunction sin = new SinFunction();
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testSolveNull() {
|
||||
UnivariateRealSolverUtils.solve(null, 0.0, 4.0);
|
||||
UnivariateSolverUtils.solve(null, 0.0, 4.0);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testSolveBadEndpoints() {
|
||||
double root = UnivariateRealSolverUtils.solve(sin, 4.0, -0.1, 1e-6);
|
||||
double root = UnivariateSolverUtils.solve(sin, 4.0, -0.1, 1e-6);
|
||||
System.out.println("root=" + root);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSolveBadAccuracy() {
|
||||
try { // bad accuracy
|
||||
UnivariateRealSolverUtils.solve(sin, 0.0, 4.0, 0.0);
|
||||
UnivariateSolverUtils.solve(sin, 0.0, 4.0, 0.0);
|
||||
// Assert.fail("Expecting MathIllegalArgumentException"); // TODO needs rework since convergence behaviour was changed
|
||||
} catch (MathIllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -55,32 +55,32 @@ public class UnivariateRealSolverUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testSolveSin() {
|
||||
double x = UnivariateRealSolverUtils.solve(sin, 1.0, 4.0);
|
||||
double x = UnivariateSolverUtils.solve(sin, 1.0, 4.0);
|
||||
Assert.assertEquals(FastMath.PI, x, 1.0e-4);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testSolveAccuracyNull() {
|
||||
double accuracy = 1.0e-6;
|
||||
UnivariateRealSolverUtils.solve(null, 0.0, 4.0, accuracy);
|
||||
UnivariateSolverUtils.solve(null, 0.0, 4.0, accuracy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSolveAccuracySin() {
|
||||
double accuracy = 1.0e-6;
|
||||
double x = UnivariateRealSolverUtils.solve(sin, 1.0,
|
||||
double x = UnivariateSolverUtils.solve(sin, 1.0,
|
||||
4.0, accuracy);
|
||||
Assert.assertEquals(FastMath.PI, x, accuracy);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testSolveNoRoot() {
|
||||
UnivariateRealSolverUtils.solve(sin, 1.0, 1.5);
|
||||
UnivariateSolverUtils.solve(sin, 1.0, 1.5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBracketSin() {
|
||||
double[] result = UnivariateRealSolverUtils.bracket(sin,
|
||||
double[] result = UnivariateSolverUtils.bracket(sin,
|
||||
0.0, -2.0, 2.0);
|
||||
Assert.assertTrue(sin.value(result[0]) < 0);
|
||||
Assert.assertTrue(sin.value(result[1]) > 0);
|
||||
|
@ -88,31 +88,31 @@ public class UnivariateRealSolverUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testBracketEndpointRoot() {
|
||||
double[] result = UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0);
|
||||
double[] result = UnivariateSolverUtils.bracket(sin, 1.5, 0, 2.0);
|
||||
Assert.assertEquals(0.0, sin.value(result[0]), 1.0e-15);
|
||||
Assert.assertTrue(sin.value(result[1]) > 0);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testNullFunction() {
|
||||
UnivariateRealSolverUtils.bracket(null, 1.5, 0, 2.0);
|
||||
UnivariateSolverUtils.bracket(null, 1.5, 0, 2.0);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testBadInitial() {
|
||||
UnivariateRealSolverUtils.bracket(sin, 2.5, 0, 2.0);
|
||||
UnivariateSolverUtils.bracket(sin, 2.5, 0, 2.0);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testBadEndpoints() {
|
||||
// endpoints not valid
|
||||
UnivariateRealSolverUtils.bracket(sin, 1.5, 2.0, 1.0);
|
||||
UnivariateSolverUtils.bracket(sin, 1.5, 2.0, 1.0);
|
||||
}
|
||||
|
||||
@Test(expected=MathIllegalArgumentException.class)
|
||||
public void testBadMaximumIterations() {
|
||||
// bad maximum iterations
|
||||
UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0, 0);
|
||||
UnivariateSolverUtils.bracket(sin, 1.5, 0, 2.0, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -120,27 +120,27 @@ public class UnivariateRealSolverUtilsTest {
|
|||
UnivariateFunction f = new QuinticFunction();
|
||||
double result;
|
||||
// Static solve method
|
||||
result = UnivariateRealSolverUtils.solve(f, -0.2, 0.2);
|
||||
result = UnivariateSolverUtils.solve(f, -0.2, 0.2);
|
||||
Assert.assertEquals(result, 0, 1E-8);
|
||||
result = UnivariateRealSolverUtils.solve(f, -0.1, 0.3);
|
||||
result = UnivariateSolverUtils.solve(f, -0.1, 0.3);
|
||||
Assert.assertEquals(result, 0, 1E-8);
|
||||
result = UnivariateRealSolverUtils.solve(f, -0.3, 0.45);
|
||||
result = UnivariateSolverUtils.solve(f, -0.3, 0.45);
|
||||
Assert.assertEquals(result, 0, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.3, 0.7);
|
||||
result = UnivariateSolverUtils.solve(f, 0.3, 0.7);
|
||||
Assert.assertEquals(result, 0.5, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.2, 0.6);
|
||||
result = UnivariateSolverUtils.solve(f, 0.2, 0.6);
|
||||
Assert.assertEquals(result, 0.5, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.05, 0.95);
|
||||
result = UnivariateSolverUtils.solve(f, 0.05, 0.95);
|
||||
Assert.assertEquals(result, 0.5, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.85, 1.25);
|
||||
result = UnivariateSolverUtils.solve(f, 0.85, 1.25);
|
||||
Assert.assertEquals(result, 1.0, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.8, 1.2);
|
||||
result = UnivariateSolverUtils.solve(f, 0.8, 1.2);
|
||||
Assert.assertEquals(result, 1.0, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.85, 1.75);
|
||||
result = UnivariateSolverUtils.solve(f, 0.85, 1.75);
|
||||
Assert.assertEquals(result, 1.0, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.55, 1.45);
|
||||
result = UnivariateSolverUtils.solve(f, 0.55, 1.45);
|
||||
Assert.assertEquals(result, 1.0, 1E-6);
|
||||
result = UnivariateRealSolverUtils.solve(f, 0.85, 5);
|
||||
result = UnivariateSolverUtils.solve(f, 0.85, 5);
|
||||
Assert.assertEquals(result, 1.0, 1E-6);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue