split the analysis package into several sub-packages
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@735449 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d326b9e467
commit
1e3c634cb9
|
@ -26,12 +26,12 @@
|
|||
<!-- the following equality tests are part of the reference algorithms -->
|
||||
<!-- which already know about limited precision of the double numbers -->
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.analysis.BrentSolver" />
|
||||
<Class name="org.apache.commons.math.analysis.solvers.BrentSolver" />
|
||||
<Method name="solve" params="org.apache.commons.math.analysis.UnivariateRealFunction,double,double,double,double,double,double" returns="double" />
|
||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.analysis.MullerSolver" />
|
||||
<Class name="org.apache.commons.math.analysis.solvers.MullerSolver" />
|
||||
<Or>
|
||||
<Method name="solve" params="org.apache.commons.math.analysis.UnivariateRealFunction,double,double" returns="double" />
|
||||
<Method name="solve2" params="org.apache.commons.math.analysis.UnivariateRealFunction,double,double" returns="double" />
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.integration;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/RombergIntegration.html">
|
|
@ -14,10 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.integration;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/SimpsonsRule.html">
|
|
@ -14,10 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.integration;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/TrapezoidalRule.html">
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.integration;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
|
@ -14,11 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.integration;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Provide a default implementation for several generic functions.
|
|
@ -0,0 +1,22 @@
|
|||
<html>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- $Revision$ $Date$ -->
|
||||
<body>
|
||||
Numerical integration (quadrature) algorithms for univariate real functions.
|
||||
</body>
|
||||
</html>
|
|
@ -14,11 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.interpolation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.DuplicateSampleAbscissaException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm;
|
||||
import org.apache.commons.math.analysis.polynomials.PolynomialFunctionNewtonForm;
|
||||
|
||||
/**
|
||||
* Implements the <a href="
|
|
@ -14,10 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.interpolation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/NevillesAlgorithm.html">
|
|
@ -14,7 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.interpolation;
|
||||
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
|
||||
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
|
||||
|
||||
/**
|
||||
* Computes a natural (also known as "free", "unclamped") cubic spline interpolation for the data set.
|
|
@ -14,9 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.interpolation;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Interface representing a univariate real interpolating function.
|
|
@ -0,0 +1,22 @@
|
|||
<html>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- $Revision$ $Date$ -->
|
||||
<body>
|
||||
Univariate real functions interpolation algorithms.
|
||||
</body>
|
||||
</html>
|
|
@ -17,6 +17,7 @@
|
|||
-->
|
||||
<!-- $Revision$ $Date$ -->
|
||||
<body>
|
||||
Implementations of common numerical analysis procedures, including root finding and function interpolation.
|
||||
Parent package for common numerical analysis procedures, including root finding, minimization,
|
||||
function interpolation and integration.
|
||||
</body>
|
||||
</html>
|
|
@ -14,10 +14,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.polynomials;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Immutable representation of a real polynomial function with real coefficients.
|
||||
* <p>
|
|
@ -14,13 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.polynomials;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.DuplicateSampleAbscissaException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements the representation of a real polynomial function in
|
||||
|
@ -67,8 +68,8 @@ public class PolynomialFunctionLagrangeForm implements UnivariateRealFunction,
|
|||
* @param y function values at interpolating points
|
||||
* @throws IllegalArgumentException if input arrays are not valid
|
||||
*/
|
||||
PolynomialFunctionLagrangeForm(double x[], double y[]) throws
|
||||
IllegalArgumentException {
|
||||
public PolynomialFunctionLagrangeForm(double x[], double y[])
|
||||
throws IllegalArgumentException {
|
||||
|
||||
verifyInterpolationArray(x, y);
|
||||
this.x = new double[x.length];
|
||||
|
@ -290,7 +291,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateRealFunction,
|
|||
* @see #evaluate(double[], double[], double)
|
||||
* @see #computeCoefficients()
|
||||
*/
|
||||
protected static void verifyInterpolationArray(double x[], double y[]) throws
|
||||
public static void verifyInterpolationArray(double x[], double y[]) throws
|
||||
IllegalArgumentException {
|
||||
|
||||
if (x.length < 2 || y.length < 2) {
|
|
@ -14,10 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.polynomials;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.interpolation.DividedDifferenceInterpolator;
|
||||
|
||||
/**
|
||||
* Implements the representation of a real polynomial function in
|
||||
|
@ -68,8 +70,8 @@ public class PolynomialFunctionNewtonForm implements UnivariateRealFunction,
|
|||
* @param c the centers
|
||||
* @throws IllegalArgumentException if input arrays are not valid
|
||||
*/
|
||||
PolynomialFunctionNewtonForm(double a[], double c[]) throws
|
||||
IllegalArgumentException {
|
||||
public PolynomialFunctionNewtonForm(double a[], double c[])
|
||||
throws IllegalArgumentException {
|
||||
|
||||
verifyInputArray(a, c);
|
||||
this.a = new double[a.length];
|
|
@ -14,12 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.polynomials;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.ArgumentOutsideDomainException;
|
||||
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Represents a polynomial spline function.
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- $Revision$ $Date$ -->
|
||||
<body>
|
||||
Univariate real polynomials implementations, seen as differentiable
|
||||
univariate real functions.
|
||||
</body>
|
||||
</html>
|
|
@ -14,10 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/Bisection.html">
|
||||
|
@ -25,7 +26,7 @@ import org.apache.commons.math.MaxIterationsExceededException;
|
|||
* <p>
|
||||
* The function should be continuous but not necessarily smooth.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
*/
|
||||
public class BisectionSolver extends UnivariateRealSolverImpl {
|
||||
|
|
@ -14,11 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/BrentsMethod.html">
|
|
@ -14,12 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
|
||||
import org.apache.commons.math.complex.Complex;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +33,7 @@ import org.apache.commons.math.complex.Complex;
|
|||
* Laguerre's method is global in the sense that it can start with any initial
|
||||
* approximation and be able to solve all roots from that point.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
* @since 1.2
|
||||
*/
|
||||
public class LaguerreSolver extends UnivariateRealSolverImpl {
|
|
@ -14,11 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +32,7 @@ import org.apache.commons.math.util.MathUtils;
|
|||
* restrict ourselves to real functions. Methods solve() and solve2() find
|
||||
* real zeros, using different ways to bypass complex arithmetics.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 729291 $ $Date: 2008-12-24 11:47:53 +0100 (mer., 24 déc. 2008) $
|
||||
* @since 1.2
|
||||
*/
|
||||
public class MullerSolver extends UnivariateRealSolverImpl {
|
|
@ -15,11 +15,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
|
||||
|
@ -27,7 +29,7 @@ import org.apache.commons.math.MaxIterationsExceededException;
|
|||
* <p>
|
||||
* The function should be continuous but not necessarily smooth.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 729291 $ $Date: 2008-12-24 11:47:53 +0100 (mer., 24 déc. 2008) $
|
||||
*/
|
||||
public class NewtonSolver extends UnivariateRealSolverImpl {
|
||||
|
|
@ -14,11 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +31,7 @@ import org.apache.commons.math.util.MathUtils;
|
|||
* <p>
|
||||
* The function should be continuous but not necessarily smooth.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
* @since 1.2
|
||||
*/
|
||||
public class RiddersSolver extends UnivariateRealSolverImpl {
|
|
@ -14,13 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MaxIterationsExceededException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -37,7 +38,7 @@ import org.apache.commons.math.MaxIterationsExceededException;
|
|||
* <p>
|
||||
* The function is assumed to be continuous but not necessarily smooth.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
*/
|
||||
public class SecantSolver extends UnivariateRealSolverImpl implements Serializable {
|
||||
|
|
@ -14,10 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,7 +26,7 @@ import org.apache.commons.math.FunctionEvaluationException;
|
|||
* <p>
|
||||
* Implementations will search for only one zero in the given interval.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (Sun, 07 Dec 2008) $
|
||||
*/
|
||||
public interface UnivariateRealSolver {
|
||||
|
||||
|
@ -235,6 +236,15 @@ public interface UnivariateRealSolver {
|
|||
*/
|
||||
double getResult();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Get the number of iterations in the last run of the solver.
|
||||
* <p>
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
/**
|
||||
* Abstract factory class used to create {@link UnivariateRealSolver} instances.
|
||||
|
@ -35,7 +35,7 @@ package org.apache.commons.math.analysis;
|
|||
* BrentSolver solver = factory.newBrentSolver();
|
||||
* </pre>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
*/
|
||||
public abstract class UnivariateRealSolverFactory {
|
||||
/**
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
/**
|
||||
* A concrete {@link UnivariateRealSolverFactory}. This is the default solver factory
|
||||
|
@ -22,7 +22,7 @@ package org.apache.commons.math.analysis;
|
|||
* <p>
|
||||
* The default solver returned by this factory is a {@link BrentSolver}.</p>
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
*/
|
||||
public class UnivariateRealSolverFactoryImpl extends UnivariateRealSolverFactory {
|
||||
|
|
@ -15,18 +15,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Provide a default implementation for several functions useful to generic
|
||||
* solvers.
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (Sun, 07 Dec 2008) $
|
||||
*/
|
||||
public abstract class UnivariateRealSolverImpl implements UnivariateRealSolver,
|
||||
Serializable {
|
||||
|
@ -64,6 +65,9 @@ public abstract class UnivariateRealSolverImpl implements UnivariateRealSolver,
|
|||
/** The last computed root. */
|
||||
protected double result;
|
||||
|
||||
/** Value of the function at the last computed result. */
|
||||
protected double functionValue;
|
||||
|
||||
// Mainly for test framework.
|
||||
/** The last iteration count. */
|
||||
protected int iterationCount;
|
||||
|
@ -145,6 +149,20 @@ public abstract class UnivariateRealSolverImpl implements UnivariateRealSolver,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the value of the function at the last computed result.
|
||||
*
|
||||
* @return the function value at the last result.
|
||||
* @throws IllegalStateException if no value has been computed.
|
||||
*/
|
||||
public double getFunctionValue() {
|
||||
if (resultComputed) {
|
||||
return functionValue;
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalStateException("no result available", null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the last iteration count.
|
||||
*
|
||||
|
@ -172,6 +190,20 @@ public abstract class UnivariateRealSolverImpl implements UnivariateRealSolver,
|
|||
this.resultComputed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function for implementations.
|
||||
*
|
||||
* @param x the result to set
|
||||
* @param fx the result to set
|
||||
* @param iterationCount the iteration count to set
|
||||
*/
|
||||
protected final void setResult(double x, double fx, int iterationCount) {
|
||||
this.result = x;
|
||||
this.functionValue = fx;
|
||||
this.iterationCount = iterationCount;
|
||||
this.resultComputed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function for implementations.
|
||||
*/
|
|
@ -14,15 +14,16 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.analysis;
|
||||
package org.apache.commons.math.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
|
||||
/**
|
||||
* Utility routines for {@link UnivariateRealSolver} objects.
|
||||
*
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision: 724191 $ $Date: 2008-12-07 21:24:10 +0100 (dim., 07 déc. 2008) $
|
||||
*/
|
||||
public class UnivariateRealSolverUtils {
|
||||
/**
|
|
@ -0,0 +1,22 @@
|
|||
<html>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- $Revision$ $Date$ -->
|
||||
<body>
|
||||
Root finding algorithms, for univariate real functions.
|
||||
</body>
|
||||
</html>
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math.ConvergenceException;
|
|||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.UnivariateRealSolverUtils;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
|
||||
|
||||
/**
|
||||
* Base class for continuous distributions. Default implementations are
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.io.Serializable;
|
|||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.FunctionEvaluationException;
|
||||
import org.apache.commons.math.analysis.BrentSolver;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.solvers.BrentSolver;
|
||||
import org.apache.commons.math.ode.DerivativeException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
</properties>
|
||||
<body>
|
||||
<release version="2.0" date="TBD" description="TBD">
|
||||
<action dev="luc" type="update" >
|
||||
The analysis package has been reorganized with several sub-packages.
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-238" due-to="Chritian Semrau">
|
||||
Fixed an error in gcd computation for large values.
|
||||
</action>
|
||||
|
|
|
@ -27,34 +27,36 @@
|
|||
<section name="4 Numerical Analysis">
|
||||
<subsection name="4.1 Overview" href="overview">
|
||||
<p>
|
||||
The analysis package provides numerical root-finding and interpolation
|
||||
implementations for real-valued functions of one real variable.
|
||||
The analysis package is the parent package for algorithms dealing with
|
||||
real-valued functions of one real variable. It contains dedicated sub-packages
|
||||
providing numerical root-finding, integration, and interpolation. It also
|
||||
contains a polynomials sub-package that considers polynomials with real
|
||||
coefficients as differentiable real functions.
|
||||
</p>
|
||||
<p>
|
||||
Possible future additions may include numerical differentiation,
|
||||
integration and optimization.
|
||||
Possible future additions may include numerical differentiation.
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name="4.2 Root-finding" href="rootfinding">
|
||||
<p>
|
||||
A <a href="../apidocs/org/apache/commons/math/analysis/UnivariateRealSolver.html">
|
||||
org.apache.commons.math.analysis.UnivariateRealSolver.</a>
|
||||
provides the means to find roots of univariate real-valued functions.
|
||||
A <a href="../apidocs/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.html">
|
||||
org.apache.commons.math.analysis.solvers.UnivariateRealSolver.</a>
|
||||
provides the means to find roots of <a href="../apidocs/org/apache/commons/math/analysis/UnivariateRealFunction.html">univariate real-valued functions</a>.
|
||||
A root is the value where the function takes the value 0. Commons-Math
|
||||
includes implementations of the following root-finding algorithms: <ul>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/BisectionSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/BisectionSolver.html">
|
||||
Bisection</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/BrentSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/BrentSolver.html">
|
||||
Brent-Dekker</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/NewtonSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/NewtonSolver.html">
|
||||
Newton's Method</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/SecantSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/SecantSolver.html">
|
||||
Secant Method</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/MullerSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/MullerSolver.html">
|
||||
Muller's Method</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/LaguerreSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/LaguerreSolver.html">
|
||||
Laguerre's Method</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/RidderSolver.html">
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/solvers/RidderSolver.html">
|
||||
Ridder's Method</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
|
@ -84,7 +86,7 @@
|
|||
<p>
|
||||
In order to use the root-finding features, first a solver object must
|
||||
be created. It is encouraged that all solver object creation occurs
|
||||
via the <code>org.apache.commons.math.analysis.UnivariateRealSolverFactory</code>
|
||||
via the <code>org.apache.commons.math.analysis.solvers.UnivariateRealSolverFactory</code>
|
||||
class. <code>UnivariateRealSolverFactory</code> is a simple factory
|
||||
used to create all of the solver objects supported by Commons-Math.
|
||||
The typical usage of <code>UnivariateRealSolverFactory</code>
|
||||
|
@ -237,26 +239,31 @@ double c = solver.solve(function, 1.0, 5.0);</source>
|
|||
</subsection>
|
||||
<subsection name="4.3 Interpolation" href="interpolation">
|
||||
<p>
|
||||
A <a href="../apidocs/org/apache/commons/math/analysis/UnivariateRealInterpolator.html">
|
||||
org.apache.commons.math.analysis.UnivariateRealInterpolator</a>
|
||||
A <a href="../apidocs/org/apache/commons/math/analysis/interpolation/UnivariateRealInterpolator.html">
|
||||
org.apache.commons.math.analysis.interpolation.UnivariateRealInterpolator</a>
|
||||
is used to find a univariate real-valued function <code>f</code> which
|
||||
for a given set of ordered pairs
|
||||
(<code>x<sub>i</sub></code>,<code>y<sub>i</sub></code>) yields
|
||||
<code>f(x<sub>i</sub>)=y<sub>i</sub></code> to the best accuracy possible.
|
||||
Currently, only an interpolator for generating natural cubic splines is available. There is
|
||||
no interpolator factory, mainly because the interpolation algorithm is more determined
|
||||
by the kind of the interpolated function rather than the set of points to interpolate.
|
||||
<code>f(x<sub>i</sub>)=y<sub>i</sub></code> to the best accuracy possible. The result
|
||||
is provided as an object implementing the <a
|
||||
href="../apidocs/org/apache/commons/math/analysis/UnivariateRealFunction.html">
|
||||
org.apache.commons.math.analysis.UnivariateRealFunction</a> interface. It can therefore
|
||||
be evaluated at any point, including point not belonging to the original set.
|
||||
Currently, only an interpolator for generating natural cubic splines and a polynomial
|
||||
interpolator are available. There is no interpolator factory, mainly because the
|
||||
interpolation algorithm is more determined by the kind of the interpolated function
|
||||
rather than the set of points to interpolate.
|
||||
There aren't currently any accuracy controls either, as interpolation
|
||||
accuracy is in general determined by the algorithm.
|
||||
</p>
|
||||
<p>Typical usage:</p>
|
||||
<source>double x[] = { 0.0, 1.0, 2.0 };
|
||||
double y[] = { 1.0, -1.0, 2.0);
|
||||
UnivariateRealInterpolator interpolator = SplineInterpolator();
|
||||
UnivariateRealFunction function = interpolator.interpolate();
|
||||
double x=0.5;
|
||||
double y=function.evaluate(x);
|
||||
System.out println("f("+x+")="+y);</source>
|
||||
UnivariateRealInterpolator interpolator = new SplineInterpolator();
|
||||
UnivariateRealFunction function = interpolator.interpolate(x, y);
|
||||
double interpolationX = 0.5;
|
||||
double interpolatedY = function.evaluate(x);
|
||||
System.out println("f(" + interpolationX + ") = " + interpolatedY);</source>
|
||||
<p>
|
||||
A natural cubic spline is a function consisting of a polynomial of
|
||||
third degree for each subinterval determined by the x-coordinates of the
|
||||
|
@ -268,6 +275,40 @@ System.out println("f("+x+")="+y);</source>
|
|||
evaluate the function for values outside the range
|
||||
<code>x<sub>0</sub></code>..<code>x<sub>N</sub></code>.
|
||||
</p>
|
||||
<p>
|
||||
The polynomial function returned by the Neville's algorithm is a single
|
||||
polynomial guaranteed to pass exactly through the interpolation points.
|
||||
The degree of the polynomial is the number of points minus 1 (i.e. the
|
||||
interpolation polynomial for a three points set will be a quadratic
|
||||
polynomial). Despite the fact the interpolating polynomials is a perfect
|
||||
approximation of a function at interpolation points, it may be a loose
|
||||
approximation between the points. Due to <a
|
||||
href="http://en.wikipedia.org/wiki/Runge's_phenomenon">Runge's phenomenom</a>
|
||||
the error can get worse as the degree of the polynomial increases, so
|
||||
adding more points does not always lead to a better interpolation.
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name="4.4 Integration" href="integration">
|
||||
<p>
|
||||
A <a href="../apidocs/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.html">
|
||||
org.apache.commons.math.analysis.integration.UnivariateRealIntegrator.</a>
|
||||
provides the means to numerically integrate <a href="../apidocs/org/apache/commons/math/analysis/UnivariateRealFunction.html">univariate real-valued functions</a>.
|
||||
Commons-Math includes implementations of the following integration algorithms: <ul>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/integration/RombergIntegrator.html">
|
||||
Romberg's method</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/integration/SimpsonIntegrator.html">
|
||||
Simpson's</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.html">
|
||||
trapezoid method</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name="4.5 Polynomials" href="polynomials">
|
||||
<p>
|
||||
The <a href="../apidocs/org/apache/commons/math/analysis/polynomials/package.html">
|
||||
org.apache.commons.math.analysis.polynomials</a> package provides real coefficients
|
||||
polynomials.
|
||||
</p>
|
||||
</subsection>
|
||||
</section>
|
||||
</body>
|
||||
|
|
|
@ -60,12 +60,15 @@
|
|||
<li><a href="linear.html#3.2 Real matrices">3.2 Real matrices</a></li>
|
||||
<li><a href="linear.html#3.3 Real vectors">3.3 Real vectors</a></li>
|
||||
<li><a href="linear.html#3.4 Solving linear systems">3.4 Solving linear systems</a></li>
|
||||
<li><a href="linear.html#3.5 Eigenvalues/eigenvectors and singular values/singular vectors">3.5 Eigenvalues/eigenvectors and singular values/singular vectors</a></li>
|
||||
</ul></li>
|
||||
<li><a href="analysis.html">4. Numerical Analysis</a>
|
||||
<ul>
|
||||
<li><a href="analysis.html#4.1 Overview">4.1 Overview</a></li>
|
||||
<li><a href="analysis.html#4.2 Root-finding">4.2 Root-finding</a></li>
|
||||
<li><a href="analysis.html#4.3 Interpolation">4.3 Interpolation</a></li>
|
||||
<li><a href="analysis.html#4.4 Integration">4.4 Integration</a></li>
|
||||
<li><a href="analysis.html#4.5 Polynomials">4.5 Polynomials</a></li>
|
||||
</ul></li>
|
||||
<li><a href="special.html">5. Special Functions</a>
|
||||
<ul>
|
||||
|
@ -78,8 +81,9 @@
|
|||
<ul>
|
||||
<li><a href="utilities.html#6.1 Overview">6.1 Overview</a></li>
|
||||
<li><a href="utilities.html#6.2 Double array utilities">6.2 Double array utilities</a></li>
|
||||
<li><a href="utilities.html#6.3 Continued Fractions">6.3 Continued Fractions</a></li>
|
||||
<li><a href="utilities.html#6.4 binomial coefficients, factorials and other common math functions">6.4 binomial coefficients, factorials and other common math functions</a></li>
|
||||
<li><a href="utilities.html#6.3 int/double hash map">6.3 int/double hash map</a></li>
|
||||
<li><a href="utilities.html#6.4 Continued Fractions">6.4 Continued Fractions</a></li>
|
||||
<li><a href="utilities.html#6.5 binomial coefficients, factorials and other common math functions">6.5 binomial coefficients, factorials and other common math functions</a></li>
|
||||
</ul></li>
|
||||
<li><a href="complex.html">7. Complex Numbers</a>
|
||||
<ul>
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
Commons Math is divided into fourteen subpackages, based on functionality provided.
|
||||
<ol>
|
||||
<li><a href="stat.html">org.apache.commons.math.stat</a> - statistics, statistical tests</li>
|
||||
<li><a href="analysis.html">org.apache.commons.math.analysis</a> - rootfinding and interpolation</li>
|
||||
<li><a href="analysis.html">org.apache.commons.math.analysis</a> - rootfinding, integration, interpolation, polynomials</li>
|
||||
<li><a href="random.html">org.apache.commons.math.random</a> - random numbers, strings and data generation</li>
|
||||
<li><a href="special.html">org.apache.commons.math.special</a> - special functions (Gamma, Beta) </li>
|
||||
<li><a href="linear.html">org.apache.commons.math.linear</a> - matrices, solving linear systems </li>
|
||||
|
|
Loading…
Reference in New Issue