You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2009/09/05 19:37:05 UTC
svn commit: r811685 [2/24] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/
src/main/java/org/apache/commons/math/analysis/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/anal...
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateRealFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateRealFunction.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateRealFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateRealFunction.java Sat Sep 5 17:36:48 2009
@@ -20,7 +20,7 @@
/**
* An interface representing a univariate real function.
- *
+ *
* @version $Revision$ $Date$
*/
public interface UnivariateRealFunction {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateVectorialFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateVectorialFunction.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateVectorialFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/UnivariateVectorialFunction.java Sat Sep 5 17:36:48 2009
@@ -20,7 +20,7 @@
/**
* An interface representing a univariate vectorial function.
- *
+ *
* @version $Revision$ $Date$
* @since 2.0
*/
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java Sat Sep 5 17:36:48 2009
@@ -163,7 +163,7 @@
public double integrate(final UnivariateRealFunction f,
final double min, final double max)
throws ConvergenceException, FunctionEvaluationException, IllegalArgumentException {
-
+
clearResult();
verifyInterval(min, max);
verifyIterationCount();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java Sat Sep 5 17:36:48 2009
@@ -30,7 +30,7 @@
* Romberg integration employs k successive refinements of the trapezoid
* rule to remove error terms less than order O(N^(-2k)). Simpson's rule
* is a special case of k = 2.</p>
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -38,7 +38,7 @@
/**
* Construct an integrator for the given function.
- *
+ *
* @param f function to integrate
* @deprecated as of 2.0 the integrand function is passed as an argument
* to the {@link #integrate(UnivariateRealFunction, double, double)}method.
@@ -66,7 +66,7 @@
public double integrate(final UnivariateRealFunction f,
final double min, final double max)
throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {
-
+
int i = 1, j, m = maximalIterationCount + 1;
// Array structure here can be improved for better space
// efficiency because only the lower triangle is used.
@@ -90,7 +90,7 @@
if (i >= minimalIterationCount) {
final double delta = Math.abs(s - olds);
final double rLimit =
- relativeAccuracy * (Math.abs(olds) + Math.abs(s)) * 0.5;
+ relativeAccuracy * (Math.abs(olds) + Math.abs(s)) * 0.5;
if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
setResult(s, i);
return result;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java Sat Sep 5 17:36:48 2009
@@ -29,7 +29,7 @@
* <p>
* This implementation employs basic trapezoid rule as building blocks to
* calculate the Simpson's rule of alternating 2/3 and 4/3.</p>
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -37,7 +37,7 @@
/**
* Construct an integrator for the given function.
- *
+ *
* @param f function to integrate
* @deprecated as of 2.0 the integrand function is passed as an argument
* to the {@link #integrate(UnivariateRealFunction, double, double)}method.
@@ -65,10 +65,10 @@
public double integrate(final UnivariateRealFunction f,
final double min, final double max)
throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {
-
+
int i = 1;
double s, olds, t, oldt;
-
+
clearResult();
verifyInterval(min, max);
verifyIterationCount();
@@ -88,7 +88,7 @@
if (i >= minimalIterationCount) {
final double delta = Math.abs(s - olds);
final double rLimit =
- relativeAccuracy * (Math.abs(olds) + Math.abs(s)) * 0.5;
+ relativeAccuracy * (Math.abs(olds) + Math.abs(s)) * 0.5;
if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
setResult(s, i);
return result;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java Sat Sep 5 17:36:48 2009
@@ -28,7 +28,7 @@
* chapter 3.
* <p>
* The function should be integrable.</p>
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -39,7 +39,7 @@
/**
* Construct an integrator for the given function.
- *
+ *
* @param f function to integrate
* @deprecated as of 2.0 the integrand function is passed as an argument
* to the {@link #integrate(UnivariateRealFunction, double, double)}method.
@@ -76,10 +76,10 @@
double stage(final UnivariateRealFunction f,
final double min, final double max, final int n)
throws FunctionEvaluationException {
-
+
long i, np;
double x, spacing, sum = 0;
-
+
if (n == 0) {
s = 0.5 * (max - min) * (f.value(min) + f.value(max));
return s;
@@ -108,10 +108,10 @@
public double integrate(final UnivariateRealFunction f,
final double min, final double max)
throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {
-
+
int i = 1;
double t, oldt;
-
+
clearResult();
verifyInterval(min, max);
verifyIterationCount();
@@ -122,7 +122,7 @@
if (i >= minimalIterationCount) {
final double delta = Math.abs(t - oldt);
final double rLimit =
- relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
+ relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
setResult(t, i);
return result;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.java Sat Sep 5 17:36:48 2009
@@ -23,7 +23,7 @@
/**
* Interface for univariate real integration algorithms.
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -45,7 +45,7 @@
/**
* Get the lower limit for the number of iterations.
- *
+ *
* @return the actual lower limit
*/
int getMinimalIterationCount();
@@ -54,14 +54,14 @@
* Reset the lower limit for the number of iterations to the default.
* <p>
* The default value is supplied by the implementation.</p>
- *
+ *
* @see #setMinimalIterationCount(int)
*/
void resetMinimalIterationCount();
/**
* Integrate the function in the given interval.
- *
+ *
* @param min the lower bound for the interval
* @param max the upper bound for the interval
* @return the value of integral
@@ -75,12 +75,12 @@
* since 2.0
*/
@Deprecated
- double integrate(double min, double max) throws ConvergenceException,
+ double integrate(double min, double max) throws ConvergenceException,
FunctionEvaluationException, IllegalArgumentException;
/**
* Integrate the function in the given interval.
- *
+ *
* @param f the integrand function
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -92,12 +92,12 @@
* @throws IllegalArgumentException if min > max or the endpoints do not
* satisfy the requirements specified by the integrator
*/
- double integrate(UnivariateRealFunction f, double min, double max) throws ConvergenceException,
+ double integrate(UnivariateRealFunction f, double min, double max) throws ConvergenceException,
FunctionEvaluationException, IllegalArgumentException;
/**
* Get the result of the last run of the integrator.
- *
+ *
* @return the last result
* @throws IllegalStateException if there is no result available, either
* because no result was yet computed or the last attempt failed
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java Sat Sep 5 17:36:48 2009
@@ -22,7 +22,7 @@
/**
* Provide a default implementation for several generic functions.
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -52,7 +52,7 @@
/**
* Construct an integrator with given iteration count and accuracy.
- *
+ *
* @param f the integrand function
* @param defaultMaximalIterationCount maximum number of iterations
* @throws IllegalArgumentException if f is null or the iteration
@@ -75,13 +75,13 @@
setRelativeAccuracy(1.0e-6);
this.defaultMinimalIterationCount = 3;
this.minimalIterationCount = defaultMinimalIterationCount;
-
+
verifyIterationCount();
}
/**
* Construct an integrator with given iteration count and accuracy.
- *
+ *
* @param defaultMaximalIterationCount maximum number of iterations
* @throws IllegalArgumentException if f is null or the iteration
* limits are not valid
@@ -94,13 +94,13 @@
setRelativeAccuracy(1.0e-6);
this.defaultMinimalIterationCount = 3;
this.minimalIterationCount = defaultMinimalIterationCount;
-
+
verifyIterationCount();
}
/**
* Access the last computed integral.
- *
+ *
* @return the last computed integral
* @throws IllegalStateException if no integral has been computed
*/
@@ -114,7 +114,7 @@
/**
* Convenience function for implementations.
- *
+ *
* @param newResult the result to set
* @param iterationCount the iteration count to set
*/
@@ -149,7 +149,7 @@
/**
* Verifies that the endpoints specify an interval.
- *
+ *
* @param lower lower endpoint
* @param upper upper endpoint
* @throws IllegalArgumentException if not interval
@@ -160,12 +160,12 @@
throw MathRuntimeException.createIllegalArgumentException(
"endpoints do not specify an interval: [{0}, {1}]",
lower, upper);
- }
+ }
}
/**
* Verifies that the upper and lower limits of iterations are valid.
- *
+ *
* @throws IllegalArgumentException if not valid
*/
protected void verifyIterationCount() throws IllegalArgumentException {
@@ -173,6 +173,6 @@
throw MathRuntimeException.createIllegalArgumentException(
"invalid iteration limits: min={0}, max={1}",
minimalIterationCount, maximalIterationCount);
- }
+ }
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/package.html?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/package.html (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/package.html Sat Sep 5 17:36:48 2009
@@ -19,4 +19,4 @@
<body>
Numerical integration (quadrature) algorithms for univariate real functions.
</body>
-</html>
\ No newline at end of file
+</html>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java Sat Sep 5 17:36:48 2009
@@ -81,7 +81,7 @@
/**
* Returns a copy of the divided difference array.
- * <p>
+ * <p>
* The divided difference array is defined recursively by <pre>
* f[x0] = f(x0)
* f[x0,x1,...,xk] = (f(x1,...,xk) - f(x0,...,x[k-1])) / (xk - x0)
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java Sat Sep 5 17:36:48 2009
@@ -281,7 +281,7 @@
// Recompute the robustness weights.
// Find the median residual.
- // An arraycopy and a sort are completely tractable here,
+ // An arraycopy and a sort are completely tractable here,
// because the preceding loop is a lot more expensive
System.arraycopy(residuals, 0, sortedResiduals, 0, n);
Arrays.sort(sortedResiduals);
@@ -328,7 +328,7 @@
}
/**
- * Compute the
+ * Compute the
* <a href="http://en.wikipedia.org/wiki/Local_regression#Weight_function">tricube</a>
* weight function
*
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java Sat Sep 5 17:36:48 2009
@@ -24,7 +24,7 @@
* Computes a natural (also known as "free", "unclamped") cubic spline interpolation for the data set.
* <p>
* The {@link #interpolate(double[], double[])} method returns a {@link PolynomialSplineFunction}
- * consisting of n cubic polynomials, defined over the subintervals determined by the x values,
+ * consisting of n cubic polynomials, defined over the subintervals determined by the x values,
* x[0] < x[i] ... < x[n]. The x values are referred to as "knot points."</p>
* <p>
* The value of the PolynomialSplineFunction at a point x that is greater than or equal to the smallest
@@ -34,13 +34,13 @@
* </p>
* <p>
* The interpolating polynomials satisfy: <ol>
- * <li>The value of the PolynomialSplineFunction at each of the input x values equals the
+ * <li>The value of the PolynomialSplineFunction at each of the input x values equals the
* corresponding y value.</li>
- * <li>Adjacent polynomials are equal through two derivatives at the knot points (i.e., adjacent polynomials
+ * <li>Adjacent polynomials are equal through two derivatives at the knot points (i.e., adjacent polynomials
* "match up" at the knot points, as do their first and second derivatives).</li>
* </ol></p>
* <p>
- * The cubic spline interpolation algorithm implemented is as described in R.L. Burden, J.D. Faires,
+ * The cubic spline interpolation algorithm implemented is as described in R.L. Burden, J.D. Faires,
* <u>Numerical Analysis</u>, 4th Ed., 1989, PWS-Kent, ISBN 0-53491-585-X, pp 126-131.
* </p>
*
@@ -48,7 +48,7 @@
*
*/
public class SplineInterpolator implements UnivariateRealInterpolator {
-
+
/**
* Computes an interpolating function for the data set.
* @param x the arguments for the interpolation points
@@ -60,15 +60,15 @@
throw MathRuntimeException.createIllegalArgumentException(
"dimension mismatch {0} != {1}", x.length, y.length);
}
-
+
if (x.length < 3) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} points are required, got only {1}", 3, x.length);
}
-
+
// Number of intervals. The number of data points is n + 1.
- int n = x.length - 1;
-
+ int n = x.length - 1;
+
for (int i = 0; i < n; i++) {
if (x[i] >= x[i + 1]) {
throw MathRuntimeException.createIllegalArgumentException(
@@ -76,13 +76,13 @@
i, i+1, x[i], x[i+1]);
}
}
-
+
// Differences between knot points
double h[] = new double[n];
for (int i = 0; i < n; i++) {
h[i] = x[i + 1] - x[i];
}
-
+
double mu[] = new double[n];
double z[] = new double[n + 1];
mu[0] = 0d;
@@ -94,21 +94,21 @@
z[i] = (3d * (y[i + 1] * h[i - 1] - y[i] * (x[i + 1] - x[i - 1])+ y[i - 1] * h[i]) /
(h[i - 1] * h[i]) - h[i - 1] * z[i - 1]) / g;
}
-
+
// cubic spline coefficients -- b is linear, c quadratic, d is cubic (original y's are constants)
double b[] = new double[n];
double c[] = new double[n + 1];
double d[] = new double[n];
-
+
z[n] = 0d;
c[n] = 0d;
-
+
for (int j = n -1; j >=0; j--) {
c[j] = z[j] - mu[j] * c[j + 1];
b[j] = (y[j + 1] - y[j]) / h[j] - h[j] * (c[j + 1] + 2d * c[j]) / 3d;
d[j] = (c[j + 1] - c[j]) / (3d * h[j]);
}
-
+
PolynomialFunction polynomials[] = new PolynomialFunction[n];
double coefficients[] = new double[4];
for (int i = 0; i < n; i++) {
@@ -118,7 +118,7 @@
coefficients[3] = d[i];
polynomials[i] = new PolynomialFunction(coefficients);
}
-
+
return new PolynomialSplineFunction(x, polynomials);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/UnivariateRealInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/UnivariateRealInterpolator.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/UnivariateRealInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/UnivariateRealInterpolator.java Sat Sep 5 17:36:48 2009
@@ -21,7 +21,7 @@
/**
* Interface representing a univariate real interpolating function.
- *
+ *
* @version $Revision$ $Date$
*/
public interface UnivariateRealInterpolator {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/package.html?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/package.html (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/package.html Sat Sep 5 17:36:48 2009
@@ -19,4 +19,4 @@
<body>
Univariate real functions interpolation algorithms.
</body>
-</html>
\ No newline at end of file
+</html>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/package.html?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/package.html (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/package.html Sat Sep 5 17:36:48 2009
@@ -30,4 +30,4 @@
or univariate, real vectorial or matrix valued, and they can be differentiable or not.
</p>
</body>
-</html>
\ No newline at end of file
+</html>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java Sat Sep 5 17:36:48 2009
@@ -37,10 +37,10 @@
* Serializtion identifier
*/
private static final long serialVersionUID = -7726511984200295583L;
-
+
/**
- * The coefficients of the polynomial, ordered by degree -- i.e.,
- * coefficients[0] is the constant term and coefficients[n] is the
+ * The coefficients of the polynomial, ordered by degree -- i.e.,
+ * coefficients[0] is the constant term and coefficients[n] is the
* coefficient of x^n where n is the degree of the polynomial.
*/
private final double coefficients[];
@@ -50,11 +50,11 @@
* of the coefficients array is the constant term. Higher degree
* coefficients follow in sequence. The degree of the resulting polynomial
* is the index of the last non-null element of the array, or 0 if all elements
- * are null.
+ * are null.
* <p>
* The constructor makes a copy of the input array and assigns the copy to
* the coefficients property.</p>
- *
+ *
* @param c polynomial coefficients
* @throws NullPointerException if c is null
* @throws IllegalArgumentException if c is empty
@@ -78,7 +78,7 @@
* The value returned is <br>
* <code>coefficients[n] * x^n + ... + coefficients[1] * x + coefficients[0]</code>
* </p>
- *
+ *
* @param x the argument for which the function value should be computed
* @return the value of the polynomial at the given point
* @see UnivariateRealFunction#value(double)
@@ -90,32 +90,32 @@
/**
* Returns the degree of the polynomial
- *
+ *
* @return the degree of the polynomial
*/
public int degree() {
return coefficients.length - 1;
}
-
+
/**
* Returns a copy of the coefficients array.
* <p>
* Changes made to the returned copy will not affect the coefficients of
* the polynomial.</p>
- *
+ *
* @return a fresh copy of the coefficients array
*/
public double[] getCoefficients() {
return coefficients.clone();
}
-
+
/**
* Uses Horner's Method to evaluate the polynomial with the given coefficients at
* the argument.
- *
+ *
* @param coefficients the coefficients of the polynomial to evaluate
* @param argument the input value
- * @return the value of the polynomial
+ * @return the value of the polynomial
* @throws IllegalArgumentException if coefficients is empty
* @throws NullPointerException if coefficients is null
*/
@@ -222,7 +222,7 @@
/**
* Returns the coefficients of the derivative of the polynomial with the given coefficients.
- *
+ *
* @param coefficients the coefficients of the polynomial to differentiate
* @return the coefficients of the derivative or null if coefficients has length 1.
* @throws IllegalArgumentException if coefficients is empty
@@ -242,19 +242,19 @@
}
return result;
}
-
+
/**
* Returns the derivative as a PolynomialRealFunction
- *
+ *
* @return the derivative polynomial
*/
public PolynomialFunction polynomialDerivative() {
return new PolynomialFunction(differentiate(coefficients));
}
-
+
/**
* Returns the derivative as a UnivariateRealFunction
- *
+ *
* @return the derivative function
*/
public UnivariateRealFunction derivative() {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java Sat Sep 5 17:36:48 2009
@@ -37,7 +37,7 @@
/**
* The coefficients of the polynomial, ordered by degree -- i.e.
- * coefficients[0] is the constant term and coefficients[n] is the
+ * coefficients[0] is the constant term and coefficients[n] is the
* coefficient of x^n where n is the degree of the polynomial.
*/
private double coefficients[];
@@ -57,7 +57,7 @@
* values. The order of interpolating points are not important.
* <p>
* The constructor makes copy of the input arrays and assigns them.</p>
- *
+ *
* @param x interpolating points
* @param y function values at interpolating points
* @throws IllegalArgumentException if input arrays are not valid
@@ -91,7 +91,7 @@
/**
* Returns the degree of the polynomial.
- *
+ *
* @return the degree of the polynomial
*/
public int degree() {
@@ -102,7 +102,7 @@
* Returns a copy of the interpolating points array.
* <p>
* Changes made to the returned copy will not affect the polynomial.</p>
- *
+ *
* @return a fresh copy of the interpolating points array
*/
public double[] getInterpolatingPoints() {
@@ -115,7 +115,7 @@
* Returns a copy of the interpolating values array.
* <p>
* Changes made to the returned copy will not affect the polynomial.</p>
- *
+ *
* @return a fresh copy of the interpolating values array
*/
public double[] getInterpolatingValues() {
@@ -128,7 +128,7 @@
* Returns a copy of the coefficients array.
* <p>
* Changes made to the returned copy will not affect the polynomial.</p>
- *
+ *
* @return a fresh copy of the coefficients array
*/
public double[] getCoefficients() {
@@ -141,7 +141,7 @@
}
/**
- * Evaluate the Lagrange polynomial using
+ * Evaluate the Lagrange polynomial using
* <a href="http://mathworld.wolfram.com/NevillesAlgorithm.html">
* Neville's Algorithm</a>. It takes O(N^2) time.
* <p>
@@ -276,7 +276,7 @@
* <p>
* The interpolating points must be distinct. However it is not
* verified here, it is checked in evaluate() and computeCoefficients().</p>
- *
+ *
* @param x the interpolating points array
* @param y the interpolating values array
* @throws IllegalArgumentException if not valid
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionNewtonForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionNewtonForm.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionNewtonForm.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionNewtonForm.java Sat Sep 5 17:36:48 2009
@@ -37,7 +37,7 @@
/**
* The coefficients of the polynomial, ordered by degree -- i.e.
- * coefficients[0] is the constant term and coefficients[n] is the
+ * coefficients[0] is the constant term and coefficients[n] is the
* coefficient of x^n where n is the degree of the polynomial.
*/
private double coefficients[];
@@ -60,7 +60,7 @@
* completely change, not just a permutation of old a[].
* <p>
* The constructor makes copy of the input arrays and assigns them.</p>
- *
+ *
* @param a the coefficients in Newton form formula
* @param c the centers
* @throws IllegalArgumentException if input arrays are not valid
@@ -90,7 +90,7 @@
/**
* Returns the degree of the polynomial.
- *
+ *
* @return the degree of the polynomial
*/
public int degree() {
@@ -101,7 +101,7 @@
* Returns a copy of coefficients in Newton form formula.
* <p>
* Changes made to the returned copy will not affect the polynomial.</p>
- *
+ *
* @return a fresh copy of coefficients in Newton form formula
*/
public double[] getNewtonCoefficients() {
@@ -114,7 +114,7 @@
* Returns a copy of the centers array.
* <p>
* Changes made to the returned copy will not affect the polynomial.</p>
- *
+ *
* @return a fresh copy of the centers array
*/
public double[] getCenters() {
@@ -127,7 +127,7 @@
* Returns a copy of the coefficients array.
* <p>
* Changes made to the returned copy will not affect the polynomial.</p>
- *
+ *
* @return a fresh copy of the coefficients array
*/
public double[] getCoefficients() {
@@ -193,7 +193,7 @@
* <p>
* The centers must be distinct for interpolation purposes, but not
* for general use. Thus it is not verified here.</p>
- *
+ *
* @param a the coefficients in Newton form formula
* @param c the centers
* @throws IllegalArgumentException if not valid
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java Sat Sep 5 17:36:48 2009
@@ -26,20 +26,20 @@
/**
* Represents a polynomial spline function.
* <p>
- * A <strong>polynomial spline function</strong> consists of a set of
- * <i>interpolating polynomials</i> and an ascending array of domain
+ * A <strong>polynomial spline function</strong> consists of a set of
+ * <i>interpolating polynomials</i> and an ascending array of domain
* <i>knot points</i>, determining the intervals over which the spline function
* is defined by the constituent polynomials. The polynomials are assumed to
* have been computed to match the values of another function at the knot
- * points. The value consistency constraints are not currently enforced by
+ * points. The value consistency constraints are not currently enforced by
* <code>PolynomialSplineFunction</code> itself, but are assumed to hold among
* the polynomials and knot points passed to the constructor.</p>
* <p>
* N.B.: The polynomials in the <code>polynomials</code> property must be
- * centered on the knot points to compute the spline function values.
+ * centered on the knot points to compute the spline function values.
* See below.</p>
* <p>
- * The domain of the polynomial spline function is
+ * The domain of the polynomial spline function is
* <code>[smallest knot, largest knot]</code>. Attempts to evaluate the
* function at values outside of this range generate IllegalArgumentExceptions.
* </p>
@@ -57,7 +57,7 @@
*
* @version $Revision$ $Date$
*/
-public class PolynomialSplineFunction
+public class PolynomialSplineFunction
implements DifferentiableUnivariateRealFunction {
/** Spline segment interval delimiters (knots). Size is n+1 for n segments. */
@@ -71,13 +71,13 @@
* knot segment to which x belongs.
*/
private PolynomialFunction polynomials[] = null;
-
- /**
+
+ /**
* Number of spline segments = number of polynomials
- * = number of partition points - 1
+ * = number of partition points - 1
*/
private int n = 0;
-
+
/**
* Construct a polynomial spline function with the given segment delimiters
@@ -85,14 +85,14 @@
* <p>
* The constructor copies both arrays and assigns the copies to the knots
* and polynomials properties, respectively.</p>
- *
+ *
* @param knots spline segment interval delimiters
* @param polynomials polynomial functions that make up the spline
* @throws NullPointerException if either of the input arrays is null
- * @throws IllegalArgumentException if knots has length less than 2,
+ * @throws IllegalArgumentException if knots has length less than 2,
* <code>polynomials.length != knots.length - 1 </code>, or the knots array
* is not strictly increasing.
- *
+ *
*/
public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[]) {
if (knots.length < 2) {
@@ -109,7 +109,7 @@
throw MathRuntimeException.createIllegalArgumentException(
"knot values must be strictly increasing");
}
-
+
this.n = knots.length -1;
this.knots = new double[n + 1];
System.arraycopy(knots, 0, this.knots, 0, n + 1);
@@ -125,7 +125,7 @@
* <p>
* See {@link PolynomialSplineFunction} for details on the algorithm for
* computing the value of the function.</p>
- *
+ *
* @param v the point for which the function value should be computed
* @return the value
* @throws ArgumentOutsideDomainException if v is outside of the domain of
@@ -148,7 +148,7 @@
}
return polynomials[i].value(v - knots[i]);
}
-
+
/**
* Returns the derivative of the polynomial spline function as a UnivariateRealFunction
* @return the derivative function
@@ -156,10 +156,10 @@
public UnivariateRealFunction derivative() {
return polynomialSplineDerivative();
}
-
+
/**
* Returns the derivative of the polynomial spline function as a PolynomialSplineFunction
- *
+ *
* @return the derivative function
*/
public PolynomialSplineFunction polynomialSplineDerivative() {
@@ -171,9 +171,9 @@
}
/**
- * Returns the number of spline segments = the number of polynomials
+ * Returns the number of spline segments = the number of polynomials
* = the number of knot points - 1.
- *
+ *
* @return the number of spline segments
*/
public int getN() {
@@ -185,7 +185,7 @@
* <p>
* Returns a fresh copy of the array. Changes made to the copy will
* not affect the polynomials property.</p>
- *
+ *
* @return the interpolating polynomials
*/
public PolynomialFunction[] getPolynomials() {
@@ -199,19 +199,19 @@
* <p>
* Returns a fresh copy of the array. Changes made to the copy
* will not affect the knots property.</p>
- *
+ *
* @return the knot points
*/
public double[] getKnots() {
double out[] = new double[n + 1];
System.arraycopy(knots, 0, out, 0, n + 1);
- return out;
+ return out;
}
/**
* Determines if the given array is ordered in a strictly increasing
* fashion.
- *
+ *
* @param x the array to examine.
* @return <code>true</code> if the elements in <code>x</code> are ordered
* in a stricly increasing manner. <code>false</code>, otherwise.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java Sat Sep 5 17:36:48 2009
@@ -22,7 +22,7 @@
/**
* A collection of static methods that operate on or return polynomials.
- *
+ *
* @version $Revision$ $Date$
* @since 2.0
*/
@@ -219,7 +219,7 @@
return new PolynomialFunction(a);
}
-
+
/** Compute polynomial coefficients up to a given degree.
* @param degree maximal degree
* @param maxDegree current maximal degree
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/package.html?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/package.html (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/package.html Sat Sep 5 17:36:48 2009
@@ -20,4 +20,4 @@
Univariate real polynomials implementations, seen as differentiable
univariate real functions.
</body>
-</html>
\ No newline at end of file
+</html>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java Sat Sep 5 17:36:48 2009
@@ -22,17 +22,17 @@
/**
* Implements the <a href="http://mathworld.wolfram.com/Bisection.html">
- * bisection algorithm</a> for finding zeros of univariate real functions.
+ * bisection algorithm</a> for finding zeros of univariate real functions.
* <p>
* The function should be continuous but not necessarily smooth.</p>
- *
+ *
* @version $Revision$ $Date$
*/
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
@@ -46,7 +46,7 @@
/**
* Construct a solver.
- *
+ *
*/
public BisectionSolver() {
super(100, 1E-6);
@@ -58,7 +58,7 @@
throws MaxIterationsExceededException, FunctionEvaluationException {
return solve(f, min, max);
}
-
+
/** {@inheritDoc} */
@Deprecated
public double solve(double min, double max)
@@ -75,13 +75,13 @@
/** {@inheritDoc} */
public double solve(final UnivariateRealFunction f, double min, double max)
throws MaxIterationsExceededException, FunctionEvaluationException {
-
+
clearResult();
verifyInterval(min,max);
double m;
double fm;
double fmin;
-
+
int i = 0;
while (i < maximalIterationCount) {
m = UnivariateRealSolverUtils.midpoint(min, max);
@@ -103,7 +103,7 @@
}
++i;
}
-
+
throw new MaxIterationsExceededException(maximalIterationCount);
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java Sat Sep 5 17:36:48 2009
@@ -27,17 +27,17 @@
* Brent algorithm</a> for finding zeros of real univariate functions.
* <p>
* The function should be continuous but not necessarily smooth.</p>
- *
+ *
* @version $Revision:670469 $ $Date:2008-06-23 10:01:38 +0200 (lun., 23 juin 2008) $
*/
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
@@ -76,7 +76,7 @@
* function at the three points have the same sign (note that it is
* allowed to have endpoints with the same sign if the initial point has
* opposite sign function-wise).</p>
- *
+ *
* @param f function to solve.
* @param min the lower bound for the interval.
* @param max the upper bound for the interval.
@@ -84,7 +84,7 @@
* initial point is known).
* @return the value where the function is zero
* @throws MaxIterationsExceededException the maximum iteration count
- * is exceeded
+ * is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating
* the function
* @throws IllegalArgumentException if initial is not between min and max
@@ -132,37 +132,37 @@
return solve(f, min, yMin, max, yMax, initial, yInitial);
}
-
+
/**
* Find a zero in the given interval.
* <p>
* Requires that the values of the function at the endpoints have opposite
* signs. An <code>IllegalArgumentException</code> is thrown if this is not
* the case.</p>
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval.
* @param max the upper bound for the interval.
* @return the value where the function is zero
* @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
- * function
+ * function
* @throws IllegalArgumentException if min is not less than max or the
* signs of the values of the function at the endpoints are not opposites
*/
public double solve(final UnivariateRealFunction f,
final double min, final double max)
- throws MaxIterationsExceededException,
+ throws MaxIterationsExceededException,
FunctionEvaluationException {
-
+
clearResult();
verifyInterval(min, max);
-
+
double ret = Double.NaN;
-
+
double yMin = f.value(min);
double yMax = f.value(max);
-
+
// Verify bracketing
double sign = yMin * yMax;
if (sign > 0) {
@@ -178,7 +178,7 @@
throw MathRuntimeException.createIllegalArgumentException(
"function values at endpoints do not have different signs. " +
"Endpoints: [{0}, {1}], Values: [{2}, {3}]",
- min, max, yMin, yMax);
+ min, max, yMin, yMax);
}
} else if (sign < 0){
// solve using only the first endpoint as initial guess
@@ -194,7 +194,7 @@
return ret;
}
-
+
/**
* Find a zero starting search according to the three provided points.
* @param f the function to solve
@@ -210,7 +210,7 @@
* @throws MaxIterationsExceededException if the maximum iteration count
* is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating
- * the function
+ * the function
*/
private double solve(final UnivariateRealFunction f,
double x0, double y0,
@@ -286,7 +286,7 @@
delta = p / p1;
}
}
- // Save old X1, Y1
+ // Save old X1, Y1
x0 = x1;
y0 = y1;
// Compute new X1, Y1
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java Sat Sep 5 17:36:48 2009
@@ -73,7 +73,7 @@
/**
* 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.
*/
@@ -100,7 +100,7 @@
* Find a real root in the given interval with initial value.
* <p>
* Requires bracketing condition.</p>
- *
+ *
* @param f function to solve (must be polynomial)
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -147,7 +147,7 @@
* @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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public double solve(final UnivariateRealFunction f,
@@ -192,7 +192,7 @@
/**
* Returns true iff the given complex root is actually a real zero
* in the given interval, within the solver tolerance level.
- *
+ *
* @param min the lower bound for the interval
* @param max the upper bound for the interval
* @param z the complex root
@@ -208,14 +208,14 @@
/**
* Find all complex roots for the polynomial with the given coefficients,
* starting from the given initial value.
- *
+ *
* @param coefficients the polynomial coefficients array
* @param initial the start value to use
* @return the point at which the function value 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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public Complex[] solveAll(double coefficients[], double initial) throws
@@ -232,14 +232,14 @@
/**
* Find all complex roots for the polynomial with the given coefficients,
* starting from the given initial value.
- *
+ *
* @param coefficients the polynomial coefficients array
* @param initial the start value to use
* @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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public Complex[] solveAll(Complex coefficients[], Complex initial) throws
@@ -281,14 +281,14 @@
/**
* Find a complex root for the polynomial with the given coefficients,
* starting from the given initial value.
- *
+ *
* @param coefficients the polynomial coefficients array
* @param initial the start value to use
* @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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public Complex solve(Complex coefficients[], Complex initial) throws
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java Sat Sep 5 17:36:48 2009
@@ -39,7 +39,7 @@
/**
* 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
@@ -76,7 +76,7 @@
* Find a real root in the given interval with initial value.
* <p>
* Requires bracketing condition.</p>
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -120,7 +120,7 @@
* bisection as a safety backup if it performs very poorly.</p>
* <p>
* The formulas here use divided differences directly.</p>
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -128,7 +128,7 @@
* @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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public double solve(final UnivariateRealFunction f,
@@ -228,14 +228,14 @@
* 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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
* @deprecated replaced by {@link #solve2(UnivariateRealFunction, double, double)}
* since 2.0
@@ -261,7 +261,7 @@
* approximation is often negligible.</p>
* <p>
* The formulas here do not use divided differences directly.</p>
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -269,7 +269,7 @@
* @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
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public double solve2(final UnivariateRealFunction f,
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java Sat Sep 5 17:36:48 2009
@@ -25,14 +25,14 @@
/**
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
- * Newton's Method</a> for finding zeros of real univariate functions.
- * <p>
+ * Newton's Method</a> for finding zeros of real univariate functions.
+ * <p>
* The function should be continuous but not necessarily smooth.</p>
*
* @version $Revision$ $Date$
*/
public class NewtonSolver extends UnivariateRealSolverImpl {
-
+
/**
* Construct a solver for the given function.
* @param f function to solve.
@@ -56,7 +56,7 @@
/** {@inheritDoc} */
@Deprecated
public double solve(final double min, final double max)
- throws MaxIterationsExceededException,
+ throws MaxIterationsExceededException,
FunctionEvaluationException {
return solve(f, min, max);
}
@@ -70,12 +70,12 @@
/**
* Find a zero near the midpoint of <code>min</code> and <code>max</code>.
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval
* @param max the upper bound for the interval
* @return the value where the function is zero
- * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
+ * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
* function or derivative
* @throws IllegalArgumentException if min is not less than max
@@ -88,13 +88,13 @@
/**
* Find a zero near the value <code>startValue</code>.
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval (ignored).
* @param max the upper bound for the interval (ignored).
* @param startValue the start value to use.
* @return the value where the function is zero
- * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
+ * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
* function or derivative
* @throws IllegalArgumentException if startValue is not between min and max or
@@ -132,5 +132,5 @@
throw MathRuntimeException.createIllegalArgumentException("function is not differentiable");
}
}
-
+
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java Sat Sep 5 17:36:48 2009
@@ -30,7 +30,7 @@
* Systems, 26 (1979), 979 - 980.
* <p>
* The function should be continuous but not necessarily smooth.</p>
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -38,7 +38,7 @@
/**
* 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
@@ -75,7 +75,7 @@
* Find a root in the given interval with initial value.
* <p>
* Requires bracketing condition.</p>
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -108,14 +108,14 @@
* Find a root in the given interval.
* <p>
* Requires bracketing condition.</p>
- *
+ *
* @param f the function to solve
* @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
* @throws FunctionEvaluationException if an error occurs evaluating the
- * function
+ * function
* @throws IllegalArgumentException if any parameters are invalid
*/
public double solve(final UnivariateRealFunction f,
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java Sat Sep 5 17:36:48 2009
@@ -24,23 +24,23 @@
/**
- * Implements a modified version of the
+ * Implements a modified version of the
* <a href="http://mathworld.wolfram.com/SecantMethod.html">secant method</a>
- * for approximating a zero of a real univariate function.
+ * for approximating a zero of a real univariate function.
* <p>
* The algorithm is modified to maintain bracketing of a root by successive
* approximations. Because of forced bracketing, convergence may be slower than
* the unrestricted secant algorithm. However, this implementation should in
- * general outperform the
+ * general outperform the
* <a href="http://mathworld.wolfram.com/MethodofFalsePosition.html">
* regula falsi method.</a></p>
* <p>
* The function is assumed to be continuous but not necessarily smooth.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class SecantSolver extends UnivariateRealSolverImpl {
-
+
/**
* Construct a solver for the given function.
* @param f function to solve.
@@ -77,7 +77,7 @@
/**
* Find a zero in the given interval.
- *
+ *
* @param f the function to solve
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -85,7 +85,7 @@
* @return the value where the function is zero
* @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
- * function
+ * function
* @throws IllegalArgumentException if min is not less than max or the
* signs of the values of the function at the endpoints are not opposites
*/
@@ -94,7 +94,7 @@
throws MaxIterationsExceededException, FunctionEvaluationException {
return solve(f, min, max);
}
-
+
/**
* Find a zero in the given interval.
* @param f the function to solve
@@ -103,17 +103,17 @@
* @return the value where the function is zero
* @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
- * function
+ * function
* @throws IllegalArgumentException if min is not less than max or the
* signs of the values of the function at the endpoints are not opposites
*/
public double solve(final UnivariateRealFunction f,
final double min, final double max)
throws MaxIterationsExceededException, FunctionEvaluationException {
-
+
clearResult();
verifyInterval(min, max);
-
+
// Index 0 is the old approximation for the root.
// Index 1 is the last calculated approximation for the root.
// Index 2 is a bracket for the root with respect to x0.
@@ -123,15 +123,15 @@
double x1 = max;
double y0 = f.value(x0);
double y1 = f.value(x1);
-
+
// Verify bracketing
if (y0 * y1 >= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"function values at endpoints do not have different signs, " +
"endpoints: [{0}, {1}], values: [{2}, {3}]",
- min, max, y0, y1);
+ min, max, y0, y1);
}
-
+
double x2 = x0;
double y2 = y0;
double oldDelta = x2 - x1;
@@ -171,7 +171,7 @@
x1 = x1 + delta;
y1 = f.value(x1);
if ((y1 > 0) == (y2 > 0)) {
- // New bracket is (x0,x1).
+ // New bracket is (x0,x1).
x2 = x0;
y2 = y0;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java Sat Sep 5 17:36:48 2009
@@ -26,7 +26,7 @@
* Interface for (univariate real) rootfinding algorithms.
* <p>
* Implementations will search for only one zero in the given interval.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public interface UnivariateRealSolver extends ConvergingAlgorithm {
@@ -39,10 +39,10 @@
* <p>
* This is a safety guard and it shouldn't be necessary to change this in
* general.</p>
- *
+ *
* @param accuracy the accuracy.
* @throws IllegalArgumentException if the accuracy can't be achieved by
- * the solver or is otherwise deemed unreasonable.
+ * the solver or is otherwise deemed unreasonable.
*/
void setFunctionValueAccuracy(double accuracy);
@@ -63,7 +63,7 @@
* <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
@@ -77,7 +77,7 @@
* since 2.0
*/
@Deprecated
- double solve(double min, double max) throws ConvergenceException,
+ double solve(double min, double max) throws ConvergenceException,
FunctionEvaluationException;
/**
@@ -85,7 +85,7 @@
* <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 f the function to solve.
* @param min the lower bound for the interval.
* @param max the upper bound for the interval.
@@ -99,7 +99,7 @@
* @since 2.0
*/
double solve(UnivariateRealFunction f, double min, double max)
- throws ConvergenceException,
+ throws ConvergenceException,
FunctionEvaluationException;
/**
@@ -107,7 +107,7 @@
* <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
@@ -130,7 +130,7 @@
* <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 f the function to solve.
* @param min the lower bound for the interval.
* @param max the upper bound for the interval.
@@ -149,7 +149,7 @@
/**
* Get the result of the last run of the solver.
- *
+ *
* @return the last result.
* @throws IllegalStateException if there is no result available, either
* because no result was yet computed or the last attempt failed.
@@ -158,10 +158,10 @@
/**
* Get the result of the last run of the solver.
- *
+ *
* @return the value of the function at the last result.
* @throws IllegalStateException if there is no result available, either
* because no result was yet computed or the last attempt failed.
*/
double getFunctionValue();
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactory.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactory.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactory.java Sat Sep 5 17:36:48 2009
@@ -51,35 +51,35 @@
public static UnivariateRealSolverFactory newInstance() {
return new UnivariateRealSolverFactoryImpl();
}
-
+
/**
* Create a new {@link UnivariateRealSolver}. The
* actual solver returned is determined by the underlying factory.
* @return the new solver.
*/
public abstract UnivariateRealSolver newDefaultSolver();
-
+
/**
* Create a new {@link UnivariateRealSolver}. The
* solver is an implementation of the bisection method.
* @return the new solver.
*/
public abstract UnivariateRealSolver newBisectionSolver();
-
+
/**
* Create a new {@link UnivariateRealSolver}. The
* solver is an implementation of the Brent method.
* @return the new solver.
*/
public abstract UnivariateRealSolver newBrentSolver();
-
+
/**
* Create a new {@link UnivariateRealSolver}. The
* solver is an implementation of Newton's Method.
* @return the new solver.
*/
public abstract UnivariateRealSolver newNewtonSolver();
-
+
/**
* Create a new {@link UnivariateRealSolver}. The
* solver is an implementation of the secant method.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactoryImpl.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactoryImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactoryImpl.java Sat Sep 5 17:36:48 2009
@@ -25,7 +25,7 @@
* @version $Revision$ $Date$
*/
public class UnivariateRealSolverFactoryImpl extends UnivariateRealSolverFactory {
-
+
/**
* Default constructor.
*/
@@ -37,7 +37,7 @@
public UnivariateRealSolver newDefaultSolver() {
return newBrentSolver();
}
-
+
/** {@inheritDoc} */
@Override
public UnivariateRealSolver newBisectionSolver() {
@@ -49,13 +49,13 @@
public UnivariateRealSolver newBrentSolver() {
return new BrentSolver();
}
-
+
/** {@inheritDoc} */
@Override
public UnivariateRealSolver newNewtonSolver() {
return new NewtonSolver();
}
-
+
/** {@inheritDoc} */
@Override
public UnivariateRealSolver newSecantSolver() {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverImpl.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverImpl.java Sat Sep 5 17:36:48 2009
@@ -25,7 +25,7 @@
/**
* Provide a default implementation for several functions useful to generic
* solvers.
- *
+ *
* @version $Revision$ $Date$
*/
public abstract class UnivariateRealSolverImpl
@@ -56,11 +56,11 @@
/**
* 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
+ * @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
@@ -82,10 +82,10 @@
/**
* Construct a solver with given iteration count and accuracy.
- *
+ *
* @param defaultAbsoluteAccuracy maximum absolute error
* @param defaultMaximalIterationCount maximum number of iterations
- * @throws IllegalArgumentException if f is null or the
+ * @throws IllegalArgumentException if f is null or the
* defaultAbsoluteAccuracy is not valid
*/
protected UnivariateRealSolverImpl(final int defaultMaximalIterationCount,
@@ -133,7 +133,7 @@
/**
* Convenience function for implementations.
- *
+ *
* @param newResult the result to set
* @param iterationCount the iteration count to set
*/
@@ -145,7 +145,7 @@
/**
* Convenience function for implementations.
- *
+ *
* @param x the result to set
* @param fx the result to set
* @param iterationCount the iteration count to set
@@ -168,25 +168,25 @@
/**
* Returns true iff the function takes opposite signs at the endpoints.
- *
- * @param lower the lower endpoint
+ *
+ * @param lower the lower endpoint
* @param upper the upper endpoint
* @param function the function
* @return true if f(lower) * f(upper) < 0
- * @throws FunctionEvaluationException if an error occurs evaluating the
+ * @throws FunctionEvaluationException if an error occurs evaluating the
* function at the endpoints
*/
- protected boolean isBracketing(final double lower, final double upper,
+ protected boolean isBracketing(final double lower, final double upper,
final UnivariateRealFunction function)
throws FunctionEvaluationException {
final double f1 = function.value(lower);
final double f2 = function.value(upper);
return ((f1 > 0 && f2 < 0) || (f1 < 0 && f2 > 0));
}
-
+
/**
* Returns true if the arguments form a (strictly) increasing sequence
- *
+ *
* @param start first number
* @param mid second number
* @param end third number
@@ -195,11 +195,11 @@
protected boolean isSequence(final double start, final double mid, final double end) {
return (start < mid) && (mid < end);
}
-
+
/**
- * Verifies that the endpoints specify an interval,
+ * Verifies that the endpoints specify an interval,
* throws IllegalArgumentException if not
- *
+ *
* @param lower lower endpoint
* @param upper upper endpoint
* @throws IllegalArgumentException
@@ -209,13 +209,13 @@
throw MathRuntimeException.createIllegalArgumentException(
"endpoints do not specify an interval: [{0}, {1}]",
lower, upper);
- }
+ }
}
-
+
/**
* Verifies that <code>lower < initial < upper</code>
* throws IllegalArgumentException if not
- *
+ *
* @param lower lower endpoint
* @param initial initial value
* @param upper upper endpoint
@@ -226,30 +226,30 @@
throw MathRuntimeException.createIllegalArgumentException(
"invalid interval, initial value parameters: lower={0}, initial={1}, upper={2}",
lower, initial, upper);
- }
+ }
}
-
+
/**
* Verifies that the endpoints specify an interval and the function takes
* opposite signs at the enpoints, throws IllegalArgumentException if not
- *
+ *
* @param lower lower endpoint
* @param upper upper endpoint
* @param function function
* @throws IllegalArgumentException
- * @throws FunctionEvaluationException if an error occurs evaluating the
+ * @throws FunctionEvaluationException if an error occurs evaluating the
* function at the endpoints
*/
- protected void verifyBracketing(final double lower, final double upper,
+ protected void verifyBracketing(final double lower, final double upper,
final UnivariateRealFunction function)
throws FunctionEvaluationException {
-
+
verifyInterval(lower, upper);
if (!isBracketing(lower, upper, function)) {
throw MathRuntimeException.createIllegalArgumentException(
"function values at endpoints do not have different signs. " +
"Endpoints: [{0}, {1}], Values: [{2}, {3}]",
- lower, upper, function.value(lower), function.value(upper));
+ lower, upper, function.value(lower), function.value(upper));
}
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java Sat Sep 5 17:36:48 2009
@@ -23,7 +23,7 @@
/**
* Utility routines for {@link UnivariateRealSolver} objects.
- *
+ *
* @version $Revision$ $Date$
*/
public class UnivariateRealSolverUtils {
@@ -33,11 +33,11 @@
private UnivariateRealSolverUtils() {
super();
}
-
+
/**
* Convenience method to find a zero of a univariate real function. A default
- * solver is used.
- *
+ * solver is used.
+ *
* @param f the function.
* @param x0 the lower bound for the interval.
* @param x1 the upper bound for the interval.
@@ -56,8 +56,8 @@
/**
* Convenience method to find a zero of a univariate real function. A default
- * solver is used.
- *
+ * solver is used.
+ *
* @param f the function
* @param x0 the lower bound for the interval
* @param x1 the upper bound for the interval
@@ -66,14 +66,14 @@
* @throws ConvergenceException if the iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
* function
- * @throws IllegalArgumentException if f is null, the endpoints do not
+ * @throws IllegalArgumentException if f is null, the endpoints do not
* specify a valid interval, or the absoluteAccuracy is not valid for the
* default solver
*/
public static double solve(UnivariateRealFunction f, double x0, double x1,
- double absoluteAccuracy) throws ConvergenceException,
- FunctionEvaluationException {
-
+ double absoluteAccuracy) throws ConvergenceException,
+ FunctionEvaluationException {
+
setup(f);
UnivariateRealSolver solver = LazyHolder.FACTORY.newDefaultSolver();
solver.setAbsoluteAccuracy(absoluteAccuracy);
@@ -88,24 +88,24 @@
* If f is continuous on <code>[a,b],</code> this means that <code>a</code>
* and <code>b</code> bracket a root of f.
* <p>
- * The algorithm starts by setting
+ * The algorithm starts by setting
* <code>a := initial -1; b := initial +1,</code> examines the value of the
* function at <code>a</code> and <code>b</code> and keeps moving
- * the endpoints out by one unit each time through a loop that terminates
+ * the endpoints out by one unit each time through a loop that terminates
* when one of the following happens: <ul>
* <li> <code> f(a) * f(b) < 0 </code> -- success!</li>
- * <li> <code> a = lower </code> and <code> b = upper</code>
+ * <li> <code> a = lower </code> and <code> b = upper</code>
* -- ConvergenceException </li>
- * <li> <code> Integer.MAX_VALUE</code> iterations elapse
+ * <li> <code> Integer.MAX_VALUE</code> iterations elapse
* -- ConvergenceException </li>
* </ul></p>
* <p>
- * <strong>Note: </strong> this method can take
- * <code>Integer.MAX_VALUE</code> iterations to throw a
+ * <strong>Note: </strong> this method can take
+ * <code>Integer.MAX_VALUE</code> iterations to throw a
* <code>ConvergenceException.</code> Unless you are confident that there
* is a root between <code>lowerBound</code> and <code>upperBound</code>
- * near <code>initial,</code> it is better to use
- * {@link #bracket(UnivariateRealFunction, double, double, double, int)},
+ * near <code>initial,</code> it is better to use
+ * {@link #bracket(UnivariateRealFunction, double, double, double, int)},
* explicitly specifying the maximum number of iterations.</p>
*
* @param function the function
@@ -121,8 +121,8 @@
* @throws IllegalArgumentException if function is null, maximumIterations
* is not positive, or initial is not between lowerBound and upperBound
*/
- public static double[] bracket(UnivariateRealFunction function,
- double initial, double lowerBound, double upperBound)
+ public static double[] bracket(UnivariateRealFunction function,
+ double initial, double lowerBound, double upperBound)
throws ConvergenceException, FunctionEvaluationException {
return bracket( function, initial, lowerBound, upperBound,
Integer.MAX_VALUE ) ;
@@ -136,17 +136,17 @@
* If f is continuous on <code>[a,b],</code> this means that <code>a</code>
* and <code>b</code> bracket a root of f.
* <p>
- * The algorithm starts by setting
+ * The algorithm starts by setting
* <code>a := initial -1; b := initial +1,</code> examines the value of the
* function at <code>a</code> and <code>b</code> and keeps moving
- * the endpoints out by one unit each time through a loop that terminates
+ * the endpoints out by one unit each time through a loop that terminates
* when one of the following happens: <ul>
* <li> <code> f(a) * f(b) <= 0 </code> -- success!</li>
- * <li> <code> a = lower </code> and <code> b = upper</code>
+ * <li> <code> a = lower </code> and <code> b = upper</code>
* -- ConvergenceException </li>
- * <li> <code> maximumIterations</code> iterations elapse
+ * <li> <code> maximumIterations</code> iterations elapse
* -- ConvergenceException </li></ul></p>
- *
+ *
* @param function the function
* @param initial initial midpoint of interval being expanded to
* bracket a root
@@ -157,16 +157,16 @@
* @return a two element array holding {a, b}.
* @throws ConvergenceException if the algorithm fails to find a and b
* satisfying the desired conditions
- * @throws FunctionEvaluationException if an error occurs evaluating the
+ * @throws FunctionEvaluationException if an error occurs evaluating the
* function
* @throws IllegalArgumentException if function is null, maximumIterations
* is not positive, or initial is not between lowerBound and upperBound
*/
public static double[] bracket(UnivariateRealFunction function,
- double initial, double lowerBound, double upperBound,
- int maximumIterations) throws ConvergenceException,
+ double initial, double lowerBound, double upperBound,
+ int maximumIterations) throws ConvergenceException,
FunctionEvaluationException {
-
+
if (function == null) {
throw MathRuntimeException.createIllegalArgumentException("function is null");
}
@@ -184,17 +184,17 @@
double fa;
double fb;
int numIterations = 0 ;
-
+
do {
a = Math.max(a - 1.0, lowerBound);
b = Math.min(b + 1.0, upperBound);
fa = function.value(a);
-
+
fb = function.value(b);
numIterations++ ;
- } while ((fa * fb > 0.0) && (numIterations < maximumIterations) &&
+ } while ((fa * fb > 0.0) && (numIterations < maximumIterations) &&
((a > lowerBound) || (b < upperBound)));
-
+
if (fa * fb > 0.0 ) {
throw new ConvergenceException(
"number of iterations={0}, maximum iterations={1}, " +
@@ -203,21 +203,21 @@
numIterations, maximumIterations, initial,
lowerBound, upperBound, a, b, fa, fb);
}
-
+
return new double[]{a, b};
}
/**
* Compute the midpoint of two values.
- *
+ *
* @param a first value.
* @param b second value.
- * @return the midpoint.
+ * @return the midpoint.
*/
public static double midpoint(double a, double b) {
return (a + b) * .5;
}
-
+
/**
* Checks to see if f is null, throwing IllegalArgumentException if so.
* @param f input function