Renamed "o.a.c.math.optimization.fitting.ParametricRealFunction" to
"o.a.c.math.analysis.ParametricUnivariateRealFunction". Modified all
affected files.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1071429 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2011-02-16 22:45:47 +00:00
parent 2686e1efd3
commit 3eabd1deeb
8 changed files with 25 additions and 17 deletions

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.commons.math.optimization.fitting;
package org.apache.commons.math.analysis;
/**
* An interface representing a real function that depends on one independent
@ -23,7 +23,7 @@ package org.apache.commons.math.optimization.fitting;
*
* @version $Revision$ $Date$
*/
public interface ParametricRealFunction {
public interface ParametricUnivariateRealFunction {
/**
* Compute the value of the function.
*
@ -31,7 +31,7 @@ public interface ParametricRealFunction {
* @param parameters Function parameters.
* @return the value.
*/
double value(double x, double[] parameters);
double value(double x, double ... parameters);
/**
* Compute the gradient of the function with respect to its parameters.
@ -40,5 +40,5 @@ public interface ParametricRealFunction {
* @param parameters Function parameters.
* @return the value.
*/
double[] gradient(double x, double[] parameters);
double[] gradient(double x, double ... parameters);
}

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
import org.apache.commons.math.analysis.ParametricUnivariateRealFunction;
import org.apache.commons.math.analysis.MultivariateMatrixFunction;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.VectorialPointValuePair;
@ -121,7 +122,7 @@ public class CurveFitter {
* @throws org.apache.commons.math.exception.MathUserException if the
* parametric function throws one.
*/
public double[] fit(final ParametricRealFunction f, final double[] initialGuess) {
public double[] fit(final ParametricUnivariateRealFunction f, final double[] initialGuess) {
return fit(Integer.MAX_VALUE, f, initialGuess);
}
@ -143,7 +144,7 @@ public class CurveFitter {
* @throws org.apache.commons.math.exception.MathUserException if the
* parametric function throws one.
*/
public double[] fit(int maxEval, final ParametricRealFunction f,
public double[] fit(int maxEval, final ParametricUnivariateRealFunction f,
final double[] initialGuess) {
// prepare least squares problem
double[] target = new double[observations.size()];
@ -168,12 +169,12 @@ public class CurveFitter {
private class TheoreticalValuesFunction
implements DifferentiableMultivariateVectorialFunction {
/** Function to fit. */
private final ParametricRealFunction f;
private final ParametricUnivariateRealFunction f;
/** Simple constructor.
* @param f function to fit.
*/
public TheoreticalValuesFunction(final ParametricRealFunction f) {
public TheoreticalValuesFunction(final ParametricUnivariateRealFunction f) {
this.f = f;
}

View File

@ -86,7 +86,7 @@ public class GaussianFitter {
/**
* Fits Gaussian function to the observed points.
* It will call the base class
* {@link CurveFitter#fit(ParametricRealFunction,double[]) fit} method.
* {@link CurveFitter#fit(ParametricUnivariateRealFunction,double[]) fit} method.
*
* @return the Gaussian function that best fits the observed points.
* @see CurveFitter

View File

@ -21,6 +21,7 @@ import org.apache.commons.math.exception.NumberIsTooSmallException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.analysis.ParametricUnivariateRealFunction;
import org.apache.commons.math.util.FastMath;
/** This class implements a curve fitting specialized for sinusoids.
@ -102,7 +103,7 @@ public class HarmonicFitter {
}
/** Parametric harmonic function. */
private static class ParametricHarmonicFunction implements ParametricRealFunction {
private static class ParametricHarmonicFunction implements ParametricUnivariateRealFunction {
/** {@inheritDoc} */
public double value(double x, double[] parameters) {

View File

@ -23,7 +23,7 @@ import org.apache.commons.math.exception.DimensionMismatchException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.exception.ZeroException;
import org.apache.commons.math.exception.NullArgumentException;
import org.apache.commons.math.optimization.fitting.ParametricRealFunction;
import org.apache.commons.math.analysis.ParametricUnivariateRealFunction;
/**
* A Gaussian function. Specifically:
@ -53,7 +53,7 @@ import org.apache.commons.math.optimization.fitting.ParametricRealFunction;
* @since 2.2
* @version $Revision$ $Date$
*/
public class ParametricGaussianFunction implements ParametricRealFunction, Serializable {
public class ParametricGaussianFunction implements ParametricUnivariateRealFunction, Serializable {
/** Serializable version Id. */
private static final long serialVersionUID = -3875578602503903233L;

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.optimization.fitting;
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math.analysis.ParametricUnivariateRealFunction;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
/** This class implements a curve fitting specialized for polynomials.
@ -80,7 +81,7 @@ public class PolynomialFitter {
/**
* Dedicated parametric polynomial class.
*/
private static class ParametricPolynomial implements ParametricRealFunction {
private static class ParametricPolynomial implements ParametricUnivariateRealFunction {
/** {@inheritDoc} */
public double[] gradient(double x, double[] parameters) {

View File

@ -52,6 +52,10 @@ The <action> type attribute can be add,update,fix,remove.
If the output is not quite correct, check for invisible trailing spaces!
-->
<release version="3.0" date="TBD" description="TBD">
<action dev="erans" type="fix" issue="MATH-513">
The interface "ParametricRealFunction" (in package "optimization.fitting") has
been renamed to "ParametricUnivariateRealFunction" and moved to package "analysis".
</action>
<action dev="sebb" type="fix" issue="MATH-505">
TestUtils is thread-hostile. Remove getters and setters, and make static variables final.
</action>

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.optimization.fitting;
import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer;
import org.apache.commons.math.analysis.ParametricUnivariateRealFunction;
import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@ -36,7 +37,7 @@ public class CurveFitterTest {
fitter.addObservedPoint(1.655d, 0.9474675497289684);
fitter.addObservedPoint(1.725d, 0.9013594835804194d);
ParametricRealFunction sif = new SimpleInverseFunction();
ParametricUnivariateRealFunction sif = new SimpleInverseFunction();
double[] initialguess1 = new double[1];
initialguess1[0] = 1.0d;
@ -60,7 +61,7 @@ public class CurveFitterTest {
fitter.addObservedPoint(1.655d, 0.9474675497289684);
fitter.addObservedPoint(1.725d, 0.9013594835804194d);
ParametricRealFunction sif = new SimpleInverseFunction();
ParametricUnivariateRealFunction sif = new SimpleInverseFunction();
double[] initialguess1 = new double[1];
initialguess1[0] = 1.0d;
@ -85,7 +86,7 @@ public class CurveFitterTest {
curveFitter.addObservedPoint(250, 45087);
curveFitter.addObservedPoint(500, 50683);
ParametricRealFunction f = new ParametricRealFunction() {
ParametricUnivariateRealFunction f = new ParametricUnivariateRealFunction() {
public double value(double x, double[] parameters) {
@ -136,7 +137,7 @@ public class CurveFitterTest {
}
private static class SimpleInverseFunction implements ParametricRealFunction {
private static class SimpleInverseFunction implements ParametricUnivariateRealFunction {
public double value(double x, double[] parameters) {
return parameters[0] / x + (parameters.length < 2 ? 0 : parameters[1]);