Author: luc Date: Thu Jul 16 15:09:02 2009 New Revision: 794709 URL: http://svn.apache.org/viewvc?rev=794709&view=rev Log: Changed the return type of the various interpolation algorithms to the specific implementation of UnivariateRealFunction each one uses (thanks to Gilles for reporting the problem and providing the patch)
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolator.java commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java commons/proper/math/trunk/src/site/xdoc/changes.xml Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java?rev=794709&r1=794708&r2=794709&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java Thu Jul 16 15:09:02 2009 @@ -19,7 +19,6 @@ 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; @@ -50,7 +49,7 @@ * @return a function which interpolates the data set * @throws DuplicateSampleAbscissaException if arguments are invalid */ - public UnivariateRealFunction interpolate(double x[], double y[]) throws + public PolynomialFunctionNewtonForm interpolate(double x[], double y[]) throws DuplicateSampleAbscissaException { /** @@ -76,9 +75,8 @@ } a = computeDividedDifference(x, y); - PolynomialFunctionNewtonForm p; - p = new PolynomialFunctionNewtonForm(a, c); - return p; + return new PolynomialFunctionNewtonForm(a, c); + } /** Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java?rev=794709&r1=794708&r2=794709&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java Thu Jul 16 15:09:02 2009 @@ -16,12 +16,12 @@ */ package org.apache.commons.math.analysis.interpolation; -import org.apache.commons.math.analysis.UnivariateRealFunction; -import org.apache.commons.math.MathException; - import java.io.Serializable; import java.util.Arrays; +import org.apache.commons.math.MathException; +import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; + /** * Implements the <a href="http://en.wikipedia.org/wiki/Local_regression"> * Local Regression Algorithm</a> (also Loess, Lowess) for interpolation of @@ -132,7 +132,7 @@ * <li> All arguments and values are finite real numbers</li> * </ul> */ - public final UnivariateRealFunction interpolate( + public final PolynomialSplineFunction interpolate( final double[] xval, final double[] yval) throws MathException { return new SplineInterpolator().interpolate(xval, smooth(xval, yval)); } Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolator.java?rev=794709&r1=794708&r2=794709&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolator.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolator.java Thu Jul 16 15:09:02 2009 @@ -17,8 +17,8 @@ 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; /** @@ -47,11 +47,8 @@ * @return a function which interpolates the data set * @throws MathException if arguments are invalid */ - public UnivariateRealFunction interpolate(double x[], double y[]) throws - MathException { - - PolynomialFunctionLagrangeForm p; - p = new PolynomialFunctionLagrangeForm(x, y); - return p; + public PolynomialFunctionLagrangeForm interpolate(double x[], double y[]) + throws MathException { + return new PolynomialFunctionLagrangeForm(x, y); } } Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java?rev=794709&r1=794708&r2=794709&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java Thu Jul 16 15:09:02 2009 @@ -17,7 +17,6 @@ package org.apache.commons.math.analysis.interpolation; import org.apache.commons.math.MathRuntimeException; -import org.apache.commons.math.analysis.UnivariateRealFunction; import org.apache.commons.math.analysis.polynomials.PolynomialFunction; import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; @@ -56,7 +55,7 @@ * @param y the values for the interpolation points * @return a function which interpolates the data set */ - public UnivariateRealFunction interpolate(double x[], double y[]) { + public PolynomialSplineFunction interpolate(double x[], double y[]) { if (x.length != y.length) { throw MathRuntimeException.createIllegalArgumentException( "dimension mismatch {0} != {1}", x.length, y.length); Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=794709&r1=794708&r2=794709&view=diff ============================================================================== --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Thu Jul 16 15:09:02 2009 @@ -39,6 +39,10 @@ </properties> <body> <release version="2.0" date="TBD" description="TBD"> + <action dev="luc" type="update" due-to="Gilles Sadowski"> + Changed the return type of the various interpolation algorithms to the + specific implementation of UnivariateRealFunction each one uses + </action> <action dev="luc" type="fix" issue="MATH-280"> The behavior of the bracket method in UnivariateRealSolverUtils has been changed to return successfully when a tentative bracketing interval has a root exactly at one of its end points. Previously, such intervals