commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject [4/4] [math] Remove deprecated interpolation and fitter classes.
Date Wed, 25 Feb 2015 22:02:46 GMT
Remove deprecated interpolation and fitter classes.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/0a5cd113
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/0a5cd113
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/0a5cd113

Branch: refs/heads/master
Commit: 0a5cd11327d50e5906fb4dc08bce5baea6b2d247
Parents: d389e94
Author: Thomas Neidhart <thomas.neidhart@gmail.com>
Authored: Wed Feb 25 23:02:30 2015 +0100
Committer: Thomas Neidhart <thomas.neidhart@gmail.com>
Committed: Wed Feb 25 23:02:30 2015 +0100

----------------------------------------------------------------------
 .../BicubicSplineInterpolatingFunction.java     | 638 ------------------
 .../BicubicSplineInterpolator.java              | 176 -----
 ...hingPolynomialBicubicSplineInterpolator.java | 171 -----
 .../TricubicSplineInterpolatingFunction.java    | 482 -------------
 .../TricubicSplineInterpolator.java             | 201 ------
 .../math4/analysis/solvers/NewtonSolver.java    |  92 ---
 .../commons/math4/fitting/CurveFitter.java      | 233 -------
 .../commons/math4/fitting/GaussianFitter.java   | 365 ----------
 .../commons/math4/fitting/HarmonicFitter.java   | 384 -----------
 .../commons/math4/fitting/PolynomialFitter.java |  72 --
 .../BicubicSplineInterpolatingFunctionTest.java | 670 -------------------
 .../BicubicSplineInterpolatorTest.java          | 186 -----
 ...PolynomialBicubicSplineInterpolatorTest.java | 181 -----
 ...TricubicSplineInterpolatingFunctionTest.java | 545 ---------------
 .../TricubicSplineInterpolatorTest.java         | 214 ------
 .../analysis/solvers/NewtonSolverTest.java      | 111 ---
 .../commons/math4/fitting/CurveFitterTest.java  | 143 ----
 .../math4/fitting/GaussianFitterTest.java       | 364 ----------
 .../math4/fitting/HarmonicFitterTest.java       | 187 ------
 .../math4/fitting/PolynomialFitterTest.java     | 288 --------
 20 files changed, 5703 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/0a5cd113/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolatingFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolatingFunction.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolatingFunction.java
deleted file mode 100644
index e9f7e19..0000000
--- a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolatingFunction.java
+++ /dev/null
@@ -1,638 +0,0 @@
-/*
- * 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.
- */
-package org.apache.commons.math4.analysis.interpolation;
-
-import java.util.Arrays;
-
-import org.apache.commons.math4.analysis.BivariateFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NoDataException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.exception.OutOfRangeException;
-import org.apache.commons.math4.util.MathArrays;
-
-/**
- * Function that implements the
- * <a href="http://en.wikipedia.org/wiki/Bicubic_interpolation">
- * bicubic spline interpolation</a>. Due to numerical accuracy issues this should not
- * be used.
- *
- * @since 2.1
- * @deprecated as of 3.4 replaced by
- * {@link org.apache.commons.math4.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction}
- */
-@Deprecated
-public class BicubicSplineInterpolatingFunction
-    implements BivariateFunction {
-    /** Number of coefficients. */
-    private static final int NUM_COEFF = 16;
-    /**
-     * Matrix to compute the spline coefficients from the function values
-     * and function derivatives values
-     */
-    private static final double[][] AINV = {
-        { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 },
-        { -3,3,0,0,-2,-1,0,0,0,0,0,0,0,0,0,0 },
-        { 2,-2,0,0,1,1,0,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 },
-        { 0,0,0,0,0,0,0,0,-3,3,0,0,-2,-1,0,0 },
-        { 0,0,0,0,0,0,0,0,2,-2,0,0,1,1,0,0 },
-        { -3,0,3,0,0,0,0,0,-2,0,-1,0,0,0,0,0 },
-        { 0,0,0,0,-3,0,3,0,0,0,0,0,-2,0,-1,0 },
-        { 9,-9,-9,9,6,3,-6,-3,6,-6,3,-3,4,2,2,1 },
-        { -6,6,6,-6,-3,-3,3,3,-4,4,-2,2,-2,-2,-1,-1 },
-        { 2,0,-2,0,0,0,0,0,1,0,1,0,0,0,0,0 },
-        { 0,0,0,0,2,0,-2,0,0,0,0,0,1,0,1,0 },
-        { -6,6,6,-6,-4,-2,4,2,-3,3,-3,3,-2,-1,-2,-1 },
-        { 4,-4,-4,4,2,2,-2,-2,2,-2,2,-2,1,1,1,1 }
-    };
-
-    /** Samples x-coordinates */
-    private final double[] xval;
-    /** Samples y-coordinates */
-    private final double[] yval;
-    /** Set of cubic splines patching the whole data grid */
-    private final BicubicSplineFunction[][] splines;
-    /**
-     * Partial derivatives.
-     * The value of the first index determines the kind of derivatives:
-     * 0 = first partial derivatives wrt x
-     * 1 = first partial derivatives wrt y
-     * 2 = second partial derivatives wrt x
-     * 3 = second partial derivatives wrt y
-     * 4 = cross partial derivatives
-     */
-    private final BivariateFunction[][][] partialDerivatives;
-
-    /**
-     * @param x Sample values of the x-coordinate, in increasing order.
-     * @param y Sample values of the y-coordinate, in increasing order.
-     * @param f Values of the function on every grid point.
-     * @param dFdX Values of the partial derivative of function with respect
-     * to x on every grid point.
-     * @param dFdY Values of the partial derivative of function with respect
-     * to y on every grid point.
-     * @param d2FdXdY Values of the cross partial derivative of function on
-     * every grid point.
-     * @throws DimensionMismatchException if the various arrays do not contain
-     * the expected number of elements.
-     * @throws NonMonotonicSequenceException if {@code x} or {@code y} are
-     * not strictly increasing.
-     * @throws NoDataException if any of the arrays has zero length.
-     */
-    public BicubicSplineInterpolatingFunction(double[] x,
-                                              double[] y,
-                                              double[][] f,
-                                              double[][] dFdX,
-                                              double[][] dFdY,
-                                              double[][] d2FdXdY)
-        throws DimensionMismatchException,
-               NoDataException,
-               NonMonotonicSequenceException {
-        this(x, y, f, dFdX, dFdY, d2FdXdY, false);
-    }
-
-    /**
-     * @param x Sample values of the x-coordinate, in increasing order.
-     * @param y Sample values of the y-coordinate, in increasing order.
-     * @param f Values of the function on every grid point.
-     * @param dFdX Values of the partial derivative of function with respect
-     * to x on every grid point.
-     * @param dFdY Values of the partial derivative of function with respect
-     * to y on every grid point.
-     * @param d2FdXdY Values of the cross partial derivative of function on
-     * every grid point.
-     * @param initializeDerivatives Whether to initialize the internal data
-     * needed for calling any of the methods that compute the partial derivatives
-     * this function.
-     * @throws DimensionMismatchException if the various arrays do not contain
-     * the expected number of elements.
-     * @throws NonMonotonicSequenceException if {@code x} or {@code y} are
-     * not strictly increasing.
-     * @throws NoDataException if any of the arrays has zero length.
-     *
-     * @see #partialDerivativeX(double,double)
-     * @see #partialDerivativeY(double,double)
-     * @see #partialDerivativeXX(double,double)
-     * @see #partialDerivativeYY(double,double)
-     * @see #partialDerivativeXY(double,double)
-     */
-    public BicubicSplineInterpolatingFunction(double[] x,
-                                              double[] y,
-                                              double[][] f,
-                                              double[][] dFdX,
-                                              double[][] dFdY,
-                                              double[][] d2FdXdY,
-                                              boolean initializeDerivatives)
-        throws DimensionMismatchException,
-               NoDataException,
-               NonMonotonicSequenceException {
-        final int xLen = x.length;
-        final int yLen = y.length;
-
-        if (xLen == 0 || yLen == 0 || f.length == 0 || f[0].length == 0) {
-            throw new NoDataException();
-        }
-        if (xLen != f.length) {
-            throw new DimensionMismatchException(xLen, f.length);
-        }
-        if (xLen != dFdX.length) {
-            throw new DimensionMismatchException(xLen, dFdX.length);
-        }
-        if (xLen != dFdY.length) {
-            throw new DimensionMismatchException(xLen, dFdY.length);
-        }
-        if (xLen != d2FdXdY.length) {
-            throw new DimensionMismatchException(xLen, d2FdXdY.length);
-        }
-
-        MathArrays.checkOrder(x);
-        MathArrays.checkOrder(y);
-
-        xval = x.clone();
-        yval = y.clone();
-
-        final int lastI = xLen - 1;
-        final int lastJ = yLen - 1;
-        splines = new BicubicSplineFunction[lastI][lastJ];
-
-        for (int i = 0; i < lastI; i++) {
-            if (f[i].length != yLen) {
-                throw new DimensionMismatchException(f[i].length, yLen);
-            }
-            if (dFdX[i].length != yLen) {
-                throw new DimensionMismatchException(dFdX[i].length, yLen);
-            }
-            if (dFdY[i].length != yLen) {
-                throw new DimensionMismatchException(dFdY[i].length, yLen);
-            }
-            if (d2FdXdY[i].length != yLen) {
-                throw new DimensionMismatchException(d2FdXdY[i].length, yLen);
-            }
-            final int ip1 = i + 1;
-            for (int j = 0; j < lastJ; j++) {
-                final int jp1 = j + 1;
-                final double[] beta = new double[] {
-                    f[i][j], f[ip1][j], f[i][jp1], f[ip1][jp1],
-                    dFdX[i][j], dFdX[ip1][j], dFdX[i][jp1], dFdX[ip1][jp1],
-                    dFdY[i][j], dFdY[ip1][j], dFdY[i][jp1], dFdY[ip1][jp1],
-                    d2FdXdY[i][j], d2FdXdY[ip1][j], d2FdXdY[i][jp1], d2FdXdY[ip1][jp1]
-                };
-
-                splines[i][j] = new BicubicSplineFunction(computeSplineCoefficients(beta),
-                                                          initializeDerivatives);
-            }
-        }
-
-        if (initializeDerivatives) {
-            // Compute all partial derivatives.
-            partialDerivatives = new BivariateFunction[5][lastI][lastJ];
-
-            for (int i = 0; i < lastI; i++) {
-                for (int j = 0; j < lastJ; j++) {
-                    final BicubicSplineFunction bcs = splines[i][j];
-                    partialDerivatives[0][i][j] = bcs.partialDerivativeX();
-                    partialDerivatives[1][i][j] = bcs.partialDerivativeY();
-                    partialDerivatives[2][i][j] = bcs.partialDerivativeXX();
-                    partialDerivatives[3][i][j] = bcs.partialDerivativeYY();
-                    partialDerivatives[4][i][j] = bcs.partialDerivativeXY();
-                }
-            }
-        } else {
-            // Partial derivative methods cannot be used.
-            partialDerivatives = null;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public double value(double x, double y)
-        throws OutOfRangeException {
-        final int i = searchIndex(x, xval);
-        final int j = searchIndex(y, yval);
-
-        final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
-        final double yN = (y - yval[j]) / (yval[j + 1] - yval[j]);
-
-        return splines[i][j].value(xN, yN);
-    }
-
-    /**
-     * Indicates whether a point is within the interpolation range.
-     *
-     * @param x First coordinate.
-     * @param y Second coordinate.
-     * @return {@code true} if (x, y) is a valid point.
-     * @since 3.3
-     */
-    public boolean isValidPoint(double x, double y) {
-        if (x < xval[0] ||
-            x > xval[xval.length - 1] ||
-            y < yval[0] ||
-            y > yval[yval.length - 1]) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    /**
-     * @param x x-coordinate.
-     * @param y y-coordinate.
-     * @return the value at point (x, y) of the first partial derivative with
-     * respect to x.
-     * @throws OutOfRangeException if {@code x} (resp. {@code y}) is outside
-     * the range defined by the boundary values of {@code xval} (resp.
-     * {@code yval}).
-     * @throws NullPointerException if the internal data were not initialized
-     * (cf. {@link #BicubicSplineInterpolatingFunction(double[],double[],double[][],
-     *             double[][],double[][],double[][],boolean) constructor}).
-     */
-    public double partialDerivativeX(double x, double y)
-        throws OutOfRangeException {
-        return partialDerivative(0, x, y);
-    }
-    /**
-     * @param x x-coordinate.
-     * @param y y-coordinate.
-     * @return the value at point (x, y) of the first partial derivative with
-     * respect to y.
-     * @throws OutOfRangeException if {@code x} (resp. {@code y}) is outside
-     * the range defined by the boundary values of {@code xval} (resp.
-     * {@code yval}).
-     * @throws NullPointerException if the internal data were not initialized
-     * (cf. {@link #BicubicSplineInterpolatingFunction(double[],double[],double[][],
-     *             double[][],double[][],double[][],boolean) constructor}).
-     */
-    public double partialDerivativeY(double x, double y)
-        throws OutOfRangeException {
-        return partialDerivative(1, x, y);
-    }
-    /**
-     * @param x x-coordinate.
-     * @param y y-coordinate.
-     * @return the value at point (x, y) of the second partial derivative with
-     * respect to x.
-     * @throws OutOfRangeException if {@code x} (resp. {@code y}) is outside
-     * the range defined by the boundary values of {@code xval} (resp.
-     * {@code yval}).
-     * @throws NullPointerException if the internal data were not initialized
-     * (cf. {@link #BicubicSplineInterpolatingFunction(double[],double[],double[][],
-     *             double[][],double[][],double[][],boolean) constructor}).
-     */
-    public double partialDerivativeXX(double x, double y)
-        throws OutOfRangeException {
-        return partialDerivative(2, x, y);
-    }
-    /**
-     * @param x x-coordinate.
-     * @param y y-coordinate.
-     * @return the value at point (x, y) of the second partial derivative with
-     * respect to y.
-     * @throws OutOfRangeException if {@code x} (resp. {@code y}) is outside
-     * the range defined by the boundary values of {@code xval} (resp.
-     * {@code yval}).
-     * @throws NullPointerException if the internal data were not initialized
-     * (cf. {@link #BicubicSplineInterpolatingFunction(double[],double[],double[][],
-     *             double[][],double[][],double[][],boolean) constructor}).
-     */
-    public double partialDerivativeYY(double x, double y)
-        throws OutOfRangeException {
-        return partialDerivative(3, x, y);
-    }
-    /**
-     * @param x x-coordinate.
-     * @param y y-coordinate.
-     * @return the value at point (x, y) of the second partial cross-derivative.
-     * @throws OutOfRangeException if {@code x} (resp. {@code y}) is outside
-     * the range defined by the boundary values of {@code xval} (resp.
-     * {@code yval}).
-     * @throws NullPointerException if the internal data were not initialized
-     * (cf. {@link #BicubicSplineInterpolatingFunction(double[],double[],double[][],
-     *             double[][],double[][],double[][],boolean) constructor}).
-     */
-    public double partialDerivativeXY(double x, double y)
-        throws OutOfRangeException {
-        return partialDerivative(4, x, y);
-    }
-
-    /**
-     * @param which First index in {@link #partialDerivatives}.
-     * @param x x-coordinate.
-     * @param y y-coordinate.
-     * @return the value at point (x, y) of the selected partial derivative.
-     * @throws OutOfRangeException if {@code x} (resp. {@code y}) is outside
-     * the range defined by the boundary values of {@code xval} (resp.
-     * {@code yval}).
-     * @throws NullPointerException if the internal data were not initialized
-     * (cf. {@link #BicubicSplineInterpolatingFunction(double[],double[],double[][],
-     *             double[][],double[][],double[][],boolean) constructor}).
-     */
-    private double partialDerivative(int which, double x, double y)
-        throws OutOfRangeException {
-        final int i = searchIndex(x, xval);
-        final int j = searchIndex(y, yval);
-
-        final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
-        final double yN = (y - yval[j]) / (yval[j + 1] - yval[j]);
-
-        return partialDerivatives[which][i][j].value(xN, yN);
-    }
-
-    /**
-     * @param c Coordinate.
-     * @param val Coordinate samples.
-     * @return the index in {@code val} corresponding to the interval
-     * containing {@code c}.
-     * @throws OutOfRangeException if {@code c} is out of the
-     * range defined by the boundary values of {@code val}.
-     */
-    private int searchIndex(double c, double[] val) {
-        final int r = Arrays.binarySearch(val, c);
-
-        if (r == -1 ||
-            r == -val.length - 1) {
-            throw new OutOfRangeException(c, val[0], val[val.length - 1]);
-        }
-
-        if (r < 0) {
-            // "c" in within an interpolation sub-interval: Return the
-            // index of the sample at the lower end of the sub-interval.
-            return -r - 2;
-        }
-        final int last = val.length - 1;
-        if (r == last) {
-            // "c" is the last sample of the range: Return the index
-            // of the sample at the lower end of the last sub-interval.
-            return last - 1;
-        }
-
-        // "c" is another sample point.
-        return r;
-    }
-
-    /**
-     * Compute the spline coefficients from the list of function values and
-     * function partial derivatives values at the four corners of a grid
-     * element. They must be specified in the following order:
-     * <ul>
-     *  <li>f(0,0)</li>
-     *  <li>f(1,0)</li>
-     *  <li>f(0,1)</li>
-     *  <li>f(1,1)</li>
-     *  <li>f<sub>x</sub>(0,0)</li>
-     *  <li>f<sub>x</sub>(1,0)</li>
-     *  <li>f<sub>x</sub>(0,1)</li>
-     *  <li>f<sub>x</sub>(1,1)</li>
-     *  <li>f<sub>y</sub>(0,0)</li>
-     *  <li>f<sub>y</sub>(1,0)</li>
-     *  <li>f<sub>y</sub>(0,1)</li>
-     *  <li>f<sub>y</sub>(1,1)</li>
-     *  <li>f<sub>xy</sub>(0,0)</li>
-     *  <li>f<sub>xy</sub>(1,0)</li>
-     *  <li>f<sub>xy</sub>(0,1)</li>
-     *  <li>f<sub>xy</sub>(1,1)</li>
-     * </ul>
-     * where the subscripts indicate the partial derivative with respect to
-     * the corresponding variable(s).
-     *
-     * @param beta List of function values and function partial derivatives
-     * values.
-     * @return the spline coefficients.
-     */
-    private double[] computeSplineCoefficients(double[] beta) {
-        final double[] a = new double[NUM_COEFF];
-
-        for (int i = 0; i < NUM_COEFF; i++) {
-            double result = 0;
-            final double[] row = AINV[i];
-            for (int j = 0; j < NUM_COEFF; j++) {
-                result += row[j] * beta[j];
-            }
-            a[i] = result;
-        }
-
-        return a;
-    }
-}
-
-/**
- * 2D-spline function.
- *
- */
-class BicubicSplineFunction implements BivariateFunction {
-    /** Number of points. */
-    private static final short N = 4;
-    /** Coefficients */
-    private final double[][] a;
-    /** First partial derivative along x. */
-    private final BivariateFunction partialDerivativeX;
-    /** First partial derivative along y. */
-    private final BivariateFunction partialDerivativeY;
-    /** Second partial derivative along x. */
-    private final BivariateFunction partialDerivativeXX;
-    /** Second partial derivative along y. */
-    private final BivariateFunction partialDerivativeYY;
-    /** Second crossed partial derivative. */
-    private final BivariateFunction partialDerivativeXY;
-
-    /**
-     * Simple constructor.
-     *
-     * @param coeff Spline coefficients.
-     */
-    public BicubicSplineFunction(double[] coeff) {
-        this(coeff, false);
-    }
-
-    /**
-     * Simple constructor.
-     *
-     * @param coeff Spline coefficients.
-     * @param initializeDerivatives Whether to initialize the internal data
-     * needed for calling any of the methods that compute the partial derivatives
-     * this function.
-     */
-    public BicubicSplineFunction(double[] coeff,
-                                 boolean initializeDerivatives) {
-        a = new double[N][N];
-        for (int i = 0; i < N; i++) {
-            for (int j = 0; j < N; j++) {
-                a[i][j] = coeff[i * N + j];
-            }
-        }
-
-        if (initializeDerivatives) {
-            // Compute all partial derivatives functions.
-            final double[][] aX = new double[N][N];
-            final double[][] aY = new double[N][N];
-            final double[][] aXX = new double[N][N];
-            final double[][] aYY = new double[N][N];
-            final double[][] aXY = new double[N][N];
-
-            for (int i = 0; i < N; i++) {
-                for (int j = 0; j < N; j++) {
-                    final double c = a[i][j];
-                    aX[i][j] = i * c;
-                    aY[i][j] = j * c;
-                    aXX[i][j] = (i - 1) * aX[i][j];
-                    aYY[i][j] = (j - 1) * aY[i][j];
-                    aXY[i][j] = j * aX[i][j];
-                }
-            }
-
-            partialDerivativeX = new BivariateFunction() {
-                    public double value(double x, double y)  {
-                        final double x2 = x * x;
-                        final double[] pX = {0, 1, x, x2};
-
-                        final double y2 = y * y;
-                        final double y3 = y2 * y;
-                        final double[] pY = {1, y, y2, y3};
-
-                        return apply(pX, pY, aX);
-                    }
-                };
-            partialDerivativeY = new BivariateFunction() {
-                    public double value(double x, double y)  {
-                        final double x2 = x * x;
-                        final double x3 = x2 * x;
-                        final double[] pX = {1, x, x2, x3};
-
-                        final double y2 = y * y;
-                        final double[] pY = {0, 1, y, y2};
-
-                        return apply(pX, pY, aY);
-                    }
-                };
-            partialDerivativeXX = new BivariateFunction() {
-                    public double value(double x, double y)  {
-                        final double[] pX = {0, 0, 1, x};
-
-                        final double y2 = y * y;
-                        final double y3 = y2 * y;
-                        final double[] pY = {1, y, y2, y3};
-
-                        return apply(pX, pY, aXX);
-                    }
-                };
-            partialDerivativeYY = new BivariateFunction() {
-                    public double value(double x, double y)  {
-                        final double x2 = x * x;
-                        final double x3 = x2 * x;
-                        final double[] pX = {1, x, x2, x3};
-
-                        final double[] pY = {0, 0, 1, y};
-
-                        return apply(pX, pY, aYY);
-                    }
-                };
-            partialDerivativeXY = new BivariateFunction() {
-                    public double value(double x, double y)  {
-                        final double x2 = x * x;
-                        final double[] pX = {0, 1, x, x2};
-
-                        final double y2 = y * y;
-                        final double[] pY = {0, 1, y, y2};
-
-                        return apply(pX, pY, aXY);
-                    }
-                };
-        } else {
-            partialDerivativeX = null;
-            partialDerivativeY = null;
-            partialDerivativeXX = null;
-            partialDerivativeYY = null;
-            partialDerivativeXY = null;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public double value(double x, double y) {
-        if (x < 0 || x > 1) {
-            throw new OutOfRangeException(x, 0, 1);
-        }
-        if (y < 0 || y > 1) {
-            throw new OutOfRangeException(y, 0, 1);
-        }
-
-        final double x2 = x * x;
-        final double x3 = x2 * x;
-        final double[] pX = {1, x, x2, x3};
-
-        final double y2 = y * y;
-        final double y3 = y2 * y;
-        final double[] pY = {1, y, y2, y3};
-
-        return apply(pX, pY, a);
-    }
-
-    /**
-     * Compute the value of the bicubic polynomial.
-     *
-     * @param pX Powers of the x-coordinate.
-     * @param pY Powers of the y-coordinate.
-     * @param coeff Spline coefficients.
-     * @return the interpolated value.
-     */
-    private double apply(double[] pX, double[] pY, double[][] coeff) {
-        double result = 0;
-        for (int i = 0; i < N; i++) {
-            for (int j = 0; j < N; j++) {
-                result += coeff[i][j] * pX[i] * pY[j];
-            }
-        }
-
-        return result;
-    }
-
-    /**
-     * @return the partial derivative wrt {@code x}.
-     */
-    public BivariateFunction partialDerivativeX() {
-        return partialDerivativeX;
-    }
-    /**
-     * @return the partial derivative wrt {@code y}.
-     */
-    public BivariateFunction partialDerivativeY() {
-        return partialDerivativeY;
-    }
-    /**
-     * @return the second partial derivative wrt {@code x}.
-     */
-    public BivariateFunction partialDerivativeXX() {
-        return partialDerivativeXX;
-    }
-    /**
-     * @return the second partial derivative wrt {@code y}.
-     */
-    public BivariateFunction partialDerivativeYY() {
-        return partialDerivativeYY;
-    }
-    /**
-     * @return the second partial cross-derivative.
-     */
-    public BivariateFunction partialDerivativeXY() {
-        return partialDerivativeXY;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0a5cd113/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolator.java
deleted file mode 100644
index 53e726f..0000000
--- a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicSplineInterpolator.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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.
- */
-package org.apache.commons.math4.analysis.interpolation;
-
-import org.apache.commons.math4.analysis.UnivariateFunction;
-import org.apache.commons.math4.analysis.polynomials.PolynomialSplineFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NoDataException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.util.MathArrays;
-
-/**
- * Generates a bicubic interpolating function. Due to numerical accuracy issues this should not
- * be used.
- *
- * @since 2.2
- * @deprecated as of 3.4 replaced by {@link org.apache.commons.math4.analysis.interpolation.PiecewiseBicubicSplineInterpolator}
- */
-@Deprecated
-public class BicubicSplineInterpolator
-    implements BivariateGridInterpolator {
-    /** Whether to initialize internal data used to compute the analytical
-        derivatives of the splines. */
-    private final boolean initializeDerivatives;
-
-    /**
-     * Default constructor.
-     * The argument {@link #BicubicSplineInterpolator(boolean) initializeDerivatives}
-     * is set to {@code false}.
-     */
-    public BicubicSplineInterpolator() {
-        this(false);
-    }
-
-    /**
-     * Creates an interpolator.
-     *
-     * @param initializeDerivatives Whether to initialize the internal data
-     * needed for calling any of the methods that compute the partial derivatives
-     * of the {@link BicubicSplineInterpolatingFunction function} returned from
-     * the call to {@link #interpolate(double[],double[],double[][]) interpolate}.
-     */
-    public BicubicSplineInterpolator(boolean initializeDerivatives) {
-        this.initializeDerivatives = initializeDerivatives;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public BicubicSplineInterpolatingFunction interpolate(final double[] xval,
-                                                          final double[] yval,
-                                                          final double[][] fval)
-        throws NoDataException, DimensionMismatchException,
-               NonMonotonicSequenceException, NumberIsTooSmallException {
-        if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
-            throw new NoDataException();
-        }
-        if (xval.length != fval.length) {
-            throw new DimensionMismatchException(xval.length, fval.length);
-        }
-
-        MathArrays.checkOrder(xval);
-        MathArrays.checkOrder(yval);
-
-        final int xLen = xval.length;
-        final int yLen = yval.length;
-
-        // Samples (first index is y-coordinate, i.e. subarray variable is x)
-        // 0 <= i < xval.length
-        // 0 <= j < yval.length
-        // fX[j][i] = f(xval[i], yval[j])
-        final double[][] fX = new double[yLen][xLen];
-        for (int i = 0; i < xLen; i++) {
-            if (fval[i].length != yLen) {
-                throw new DimensionMismatchException(fval[i].length, yLen);
-            }
-
-            for (int j = 0; j < yLen; j++) {
-                fX[j][i] = fval[i][j];
-            }
-        }
-
-        final SplineInterpolator spInterpolator = new SplineInterpolator();
-
-        // For each line y[j] (0 <= j < yLen), construct a 1D spline with
-        // respect to variable x
-        final PolynomialSplineFunction[] ySplineX = new PolynomialSplineFunction[yLen];
-        for (int j = 0; j < yLen; j++) {
-            ySplineX[j] = spInterpolator.interpolate(xval, fX[j]);
-        }
-
-        // For each line x[i] (0 <= i < xLen), construct a 1D spline with
-        // respect to variable y generated by array fY_1[i]
-        final PolynomialSplineFunction[] xSplineY = new PolynomialSplineFunction[xLen];
-        for (int i = 0; i < xLen; i++) {
-            xSplineY[i] = spInterpolator.interpolate(yval, fval[i]);
-        }
-
-        // Partial derivatives with respect to x at the grid knots
-        final double[][] dFdX = new double[xLen][yLen];
-        for (int j = 0; j < yLen; j++) {
-            final UnivariateFunction f = ySplineX[j].derivative();
-            for (int i = 0; i < xLen; i++) {
-                dFdX[i][j] = f.value(xval[i]);
-            }
-        }
-
-        // Partial derivatives with respect to y at the grid knots
-        final double[][] dFdY = new double[xLen][yLen];
-        for (int i = 0; i < xLen; i++) {
-            final UnivariateFunction f = xSplineY[i].derivative();
-            for (int j = 0; j < yLen; j++) {
-                dFdY[i][j] = f.value(yval[j]);
-            }
-        }
-
-        // Cross partial derivatives
-        final double[][] d2FdXdY = new double[xLen][yLen];
-        for (int i = 0; i < xLen ; i++) {
-            final int nI = nextIndex(i, xLen);
-            final int pI = previousIndex(i);
-            for (int j = 0; j < yLen; j++) {
-                final int nJ = nextIndex(j, yLen);
-                final int pJ = previousIndex(j);
-                d2FdXdY[i][j] = (fval[nI][nJ] - fval[nI][pJ] -
-                                 fval[pI][nJ] + fval[pI][pJ]) /
-                    ((xval[nI] - xval[pI]) * (yval[nJ] - yval[pJ]));
-            }
-        }
-
-        // Create the interpolating splines
-        return new BicubicSplineInterpolatingFunction(xval, yval, fval,
-                                                      dFdX, dFdY, d2FdXdY,
-                                                      initializeDerivatives);
-    }
-
-    /**
-     * Computes the next index of an array, clipping if necessary.
-     * It is assumed (but not checked) that {@code i >= 0}.
-     *
-     * @param i Index.
-     * @param max Upper limit of the array.
-     * @return the next index.
-     */
-    private int nextIndex(int i, int max) {
-        final int index = i + 1;
-        return index < max ? index : index - 1;
-    }
-    /**
-     * Computes the previous index of an array, clipping if necessary.
-     * It is assumed (but not checked) that {@code i} is smaller than the size
-     * of the array.
-     *
-     * @param i Index.
-     * @return the previous index.
-     */
-    private int previousIndex(int i) {
-        final int index = i - 1;
-        return index >= 0 ? index : 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0a5cd113/src/main/java/org/apache/commons/math4/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
deleted file mode 100644
index 243da0c..0000000
--- a/src/main/java/org/apache/commons/math4/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.
- */
-package org.apache.commons.math4.analysis.interpolation;
-
-import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NoDataException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.exception.NotPositiveException;
-import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.fitting.PolynomialFitter;
-import org.apache.commons.math4.optim.SimpleVectorValueChecker;
-import org.apache.commons.math4.optim.nonlinear.vector.jacobian.GaussNewtonOptimizer;
-import org.apache.commons.math4.util.MathArrays;
-import org.apache.commons.math4.util.Precision;
-
-/**
- * Generates a bicubic interpolation function.
- * Prior to generating the interpolating function, the input is smoothed using
- * polynomial fitting.
- *
- * @since 2.2
- * @deprecated To be removed in 4.0 (see MATH-1166).
- */
-@Deprecated
-public class SmoothingPolynomialBicubicSplineInterpolator
-    extends BicubicSplineInterpolator {
-    /** Fitter for x. */
-    private final PolynomialFitter xFitter;
-    /** Degree of the fitting polynomial. */
-    private final int xDegree;
-    /** Fitter for y. */
-    private final PolynomialFitter yFitter;
-    /** Degree of the fitting polynomial. */
-    private final int yDegree;
-
-    /**
-     * Default constructor. The degree of the fitting polynomials is set to 3.
-     */
-    public SmoothingPolynomialBicubicSplineInterpolator() {
-        this(3);
-    }
-
-    /**
-     * @param degree Degree of the polynomial fitting functions.
-     * @exception NotPositiveException if degree is not positive
-     */
-    public SmoothingPolynomialBicubicSplineInterpolator(int degree)
-        throws NotPositiveException {
-        this(degree, degree);
-    }
-
-    /**
-     * @param xDegree Degree of the polynomial fitting functions along the
-     * x-dimension.
-     * @param yDegree Degree of the polynomial fitting functions along the
-     * y-dimension.
-     * @exception NotPositiveException if degrees are not positive
-     */
-    public SmoothingPolynomialBicubicSplineInterpolator(int xDegree, int yDegree)
-        throws NotPositiveException {
-        if (xDegree < 0) {
-            throw new NotPositiveException(xDegree);
-        }
-        if (yDegree < 0) {
-            throw new NotPositiveException(yDegree);
-        }
-        this.xDegree = xDegree;
-        this.yDegree = yDegree;
-
-        final double safeFactor = 1e2;
-        final SimpleVectorValueChecker checker
-            = new SimpleVectorValueChecker(safeFactor * Precision.EPSILON,
-                                           safeFactor * Precision.SAFE_MIN);
-        xFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
-        yFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BicubicSplineInterpolatingFunction interpolate(final double[] xval,
-                                                          final double[] yval,
-                                                          final double[][] fval)
-        throws NoDataException, NullArgumentException,
-               DimensionMismatchException, NonMonotonicSequenceException {
-        if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
-            throw new NoDataException();
-        }
-        if (xval.length != fval.length) {
-            throw new DimensionMismatchException(xval.length, fval.length);
-        }
-
-        final int xLen = xval.length;
-        final int yLen = yval.length;
-
-        for (int i = 0; i < xLen; i++) {
-            if (fval[i].length != yLen) {
-                throw new DimensionMismatchException(fval[i].length, yLen);
-            }
-        }
-
-        MathArrays.checkOrder(xval);
-        MathArrays.checkOrder(yval);
-
-        // For each line y[j] (0 <= j < yLen), construct a polynomial, with
-        // respect to variable x, fitting array fval[][j]
-        final PolynomialFunction[] yPolyX = new PolynomialFunction[yLen];
-        for (int j = 0; j < yLen; j++) {
-            xFitter.clearObservations();
-            for (int i = 0; i < xLen; i++) {
-                xFitter.addObservedPoint(1, xval[i], fval[i][j]);
-            }
-
-            // Initial guess for the fit is zero for each coefficients (of which
-            // there are "xDegree" + 1).
-            yPolyX[j] = new PolynomialFunction(xFitter.fit(new double[xDegree + 1]));
-        }
-
-        // For every knot (xval[i], yval[j]) of the grid, calculate corrected
-        // values fval_1
-        final double[][] fval_1 = new double[xLen][yLen];
-        for (int j = 0; j < yLen; j++) {
-            final PolynomialFunction f = yPolyX[j];
-            for (int i = 0; i < xLen; i++) {
-                fval_1[i][j] = f.value(xval[i]);
-            }
-        }
-
-        // For each line x[i] (0 <= i < xLen), construct a polynomial, with
-        // respect to variable y, fitting array fval_1[i][]
-        final PolynomialFunction[] xPolyY = new PolynomialFunction[xLen];
-        for (int i = 0; i < xLen; i++) {
-            yFitter.clearObservations();
-            for (int j = 0; j < yLen; j++) {
-                yFitter.addObservedPoint(1, yval[j], fval_1[i][j]);
-            }
-
-            // Initial guess for the fit is zero for each coefficients (of which
-            // there are "yDegree" + 1).
-            xPolyY[i] = new PolynomialFunction(yFitter.fit(new double[yDegree + 1]));
-        }
-
-        // For every knot (xval[i], yval[j]) of the grid, calculate corrected
-        // values fval_2
-        final double[][] fval_2 = new double[xLen][yLen];
-        for (int i = 0; i < xLen; i++) {
-            final PolynomialFunction f = xPolyY[i];
-            for (int j = 0; j < yLen; j++) {
-                fval_2[i][j] = f.value(yval[j]);
-            }
-        }
-
-        return super.interpolate(xval, yval, fval_2);
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0a5cd113/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolatingFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolatingFunction.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolatingFunction.java
deleted file mode 100644
index fa5f76c..0000000
--- a/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolatingFunction.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * 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.
- */
-package org.apache.commons.math4.analysis.interpolation;
-
-import org.apache.commons.math4.analysis.TrivariateFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NoDataException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.exception.OutOfRangeException;
-import org.apache.commons.math4.util.MathArrays;
-
-/**
- * Function that implements the
- * <a href="http://en.wikipedia.org/wiki/Tricubic_interpolation">
- * tricubic spline interpolation</a>, as proposed in
- * <quote>
- *  Tricubic interpolation in three dimensions<br/>
- *  F. Lekien and J. Marsden<br/>
- *  <em>Int. J. Numer. Meth. Engng</em> 2005; <b>63</b>:455-471
- * </quote>
- *
- * @since 2.2
- * @deprecated To be removed in 4.0 (see MATH-1166).
- */
-@Deprecated
-public class TricubicSplineInterpolatingFunction
-    implements TrivariateFunction {
-    /**
-     * Matrix to compute the spline coefficients from the function values
-     * and function derivatives values
-     */
-    private static final double[][] AINV = {
-        { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { -3,3,0,0,0,0,0,0,-2,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { 2,-2,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-2,-1,0,0,0,0,0,0,0,0,0,0,0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3,0,3,0,0,0,0,0,0,0,0,0,-2,0,-1,0,-2,0,-1,0 },
-        { 18,-18,-18,18,-18,18,18,-18,12,6,-12,-6,-12,-6,12,6,12,-12,6,-6,-12,12,-6,6,9,-9,-9,9,9,-9,-9,9,8,4,4,2,-8,-4,-4,-2,6,3,-6,-3,6,3,-6,-3,6,-6,3,-3,6,-6,3,-3,4,2,2,1,4,2,2,1 },
-        { -12,12,12,-12,12,-12,-12,12,-6,-6,6,6,6,6,-6,-6,-8,8,-4,4,8,-8,4,-4,-6,6,6,-6,-6,6,6,-6,-4,-4,-2,-2,4,4,2,2,-3,-3,3,3,-3,-3,3,3,-4,4,-2,2,-4,4,-2,2,-2,-2,-1,-1,-2,-2,-1,-1 },
-        { 4,0,-4,0,-4,0,4,0,0,0,0,0,0,0,0,0,2,0,2,0,-2,0,-2,0,2,0,-2,0,2,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0 },
-        { 0,0,0,0,0,0,0,0,4,0,-4,0,-4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,-2,0,-2,0,2,0,-2,0,2,0,-2,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0 },
-        { -12,12,12,-12,12,-12,-12,12,-8,-4,8,4,8,4,-8,-4,-6,6,-6,6,6,-6,6,-6,-6,6,6,-6,-6,6,6,-6,-4,-2,-4,-2,4,2,4,2,-4,-2,4,2,-4,-2,4,2,-3,3,-3,3,-3,3,-3,3,-2,-1,-2,-1,-2,-1,-2,-1 },
-        { 8,-8,-8,8,-8,8,8,-8,4,4,-4,-4,-4,-4,4,4,4,-4,4,-4,-4,4,-4,4,4,-4,-4,4,4,-4,-4,4,2,2,2,2,-2,-2,-2,-2,2,2,-2,-2,2,2,-2,-2,2,-2,2,-2,2,-2,2,-2,1,1,1,1,1,1,1,1 }
-    };
-
-    /** Samples x-coordinates */
-    private final double[] xval;
-    /** Samples y-coordinates */
-    private final double[] yval;
-    /** Samples z-coordinates */
-    private final double[] zval;
-    /** Set of cubic splines pacthing the whole data grid */
-    private final TricubicSplineFunction[][][] splines;
-
-    /**
-     * @param x Sample values of the x-coordinate, in increasing order.
-     * @param y Sample values of the y-coordinate, in increasing order.
-     * @param z Sample values of the y-coordinate, in increasing order.
-     * @param f Values of the function on every grid point.
-     * @param dFdX Values of the partial derivative of function with respect to x on every grid point.
-     * @param dFdY Values of the partial derivative of function with respect to y on every grid point.
-     * @param dFdZ Values of the partial derivative of function with respect to z on every grid point.
-     * @param d2FdXdY Values of the cross partial derivative of function on every grid point.
-     * @param d2FdXdZ Values of the cross partial derivative of function on every grid point.
-     * @param d2FdYdZ Values of the cross partial derivative of function on every grid point.
-     * @param d3FdXdYdZ Values of the cross partial derivative of function on every grid point.
-     * @throws NoDataException if any of the arrays has zero length.
-     * @throws DimensionMismatchException if the various arrays do not contain the expected number of elements.
-     * @throws NonMonotonicSequenceException if {@code x}, {@code y} or {@code z} are not strictly increasing.
-     */
-    public TricubicSplineInterpolatingFunction(double[] x,
-                                               double[] y,
-                                               double[] z,
-                                               double[][][] f,
-                                               double[][][] dFdX,
-                                               double[][][] dFdY,
-                                               double[][][] dFdZ,
-                                               double[][][] d2FdXdY,
-                                               double[][][] d2FdXdZ,
-                                               double[][][] d2FdYdZ,
-                                               double[][][] d3FdXdYdZ)
-        throws NoDataException,
-               DimensionMismatchException,
-               NonMonotonicSequenceException {
-        final int xLen = x.length;
-        final int yLen = y.length;
-        final int zLen = z.length;
-
-        if (xLen == 0 || yLen == 0 || z.length == 0 || f.length == 0 || f[0].length == 0) {
-            throw new NoDataException();
-        }
-        if (xLen != f.length) {
-            throw new DimensionMismatchException(xLen, f.length);
-        }
-        if (xLen != dFdX.length) {
-            throw new DimensionMismatchException(xLen, dFdX.length);
-        }
-        if (xLen != dFdY.length) {
-            throw new DimensionMismatchException(xLen, dFdY.length);
-        }
-        if (xLen != dFdZ.length) {
-            throw new DimensionMismatchException(xLen, dFdZ.length);
-        }
-        if (xLen != d2FdXdY.length) {
-            throw new DimensionMismatchException(xLen, d2FdXdY.length);
-        }
-        if (xLen != d2FdXdZ.length) {
-            throw new DimensionMismatchException(xLen, d2FdXdZ.length);
-        }
-        if (xLen != d2FdYdZ.length) {
-            throw new DimensionMismatchException(xLen, d2FdYdZ.length);
-        }
-        if (xLen != d3FdXdYdZ.length) {
-            throw new DimensionMismatchException(xLen, d3FdXdYdZ.length);
-        }
-
-        MathArrays.checkOrder(x);
-        MathArrays.checkOrder(y);
-        MathArrays.checkOrder(z);
-
-        xval = x.clone();
-        yval = y.clone();
-        zval = z.clone();
-
-        final int lastI = xLen - 1;
-        final int lastJ = yLen - 1;
-        final int lastK = zLen - 1;
-        splines = new TricubicSplineFunction[lastI][lastJ][lastK];
-
-        for (int i = 0; i < lastI; i++) {
-            if (f[i].length != yLen) {
-                throw new DimensionMismatchException(f[i].length, yLen);
-            }
-            if (dFdX[i].length != yLen) {
-                throw new DimensionMismatchException(dFdX[i].length, yLen);
-            }
-            if (dFdY[i].length != yLen) {
-                throw new DimensionMismatchException(dFdY[i].length, yLen);
-            }
-            if (dFdZ[i].length != yLen) {
-                throw new DimensionMismatchException(dFdZ[i].length, yLen);
-            }
-            if (d2FdXdY[i].length != yLen) {
-                throw new DimensionMismatchException(d2FdXdY[i].length, yLen);
-            }
-            if (d2FdXdZ[i].length != yLen) {
-                throw new DimensionMismatchException(d2FdXdZ[i].length, yLen);
-            }
-            if (d2FdYdZ[i].length != yLen) {
-                throw new DimensionMismatchException(d2FdYdZ[i].length, yLen);
-            }
-            if (d3FdXdYdZ[i].length != yLen) {
-                throw new DimensionMismatchException(d3FdXdYdZ[i].length, yLen);
-            }
-
-            final int ip1 = i + 1;
-            for (int j = 0; j < lastJ; j++) {
-                if (f[i][j].length != zLen) {
-                    throw new DimensionMismatchException(f[i][j].length, zLen);
-                }
-                if (dFdX[i][j].length != zLen) {
-                    throw new DimensionMismatchException(dFdX[i][j].length, zLen);
-                }
-                if (dFdY[i][j].length != zLen) {
-                    throw new DimensionMismatchException(dFdY[i][j].length, zLen);
-                }
-                if (dFdZ[i][j].length != zLen) {
-                    throw new DimensionMismatchException(dFdZ[i][j].length, zLen);
-                }
-                if (d2FdXdY[i][j].length != zLen) {
-                    throw new DimensionMismatchException(d2FdXdY[i][j].length, zLen);
-                }
-                if (d2FdXdZ[i][j].length != zLen) {
-                    throw new DimensionMismatchException(d2FdXdZ[i][j].length, zLen);
-                }
-                if (d2FdYdZ[i][j].length != zLen) {
-                    throw new DimensionMismatchException(d2FdYdZ[i][j].length, zLen);
-                }
-                if (d3FdXdYdZ[i][j].length != zLen) {
-                    throw new DimensionMismatchException(d3FdXdYdZ[i][j].length, zLen);
-                }
-
-                final int jp1 = j + 1;
-                for (int k = 0; k < lastK; k++) {
-                    final int kp1 = k + 1;
-
-                    final double[] beta = new double[] {
-                        f[i][j][k], f[ip1][j][k],
-                        f[i][jp1][k], f[ip1][jp1][k],
-                        f[i][j][kp1], f[ip1][j][kp1],
-                        f[i][jp1][kp1], f[ip1][jp1][kp1],
-
-                        dFdX[i][j][k], dFdX[ip1][j][k],
-                        dFdX[i][jp1][k], dFdX[ip1][jp1][k],
-                        dFdX[i][j][kp1], dFdX[ip1][j][kp1],
-                        dFdX[i][jp1][kp1], dFdX[ip1][jp1][kp1],
-
-                        dFdY[i][j][k], dFdY[ip1][j][k],
-                        dFdY[i][jp1][k], dFdY[ip1][jp1][k],
-                        dFdY[i][j][kp1], dFdY[ip1][j][kp1],
-                        dFdY[i][jp1][kp1], dFdY[ip1][jp1][kp1],
-
-                        dFdZ[i][j][k], dFdZ[ip1][j][k],
-                        dFdZ[i][jp1][k], dFdZ[ip1][jp1][k],
-                        dFdZ[i][j][kp1], dFdZ[ip1][j][kp1],
-                        dFdZ[i][jp1][kp1], dFdZ[ip1][jp1][kp1],
-
-                        d2FdXdY[i][j][k], d2FdXdY[ip1][j][k],
-                        d2FdXdY[i][jp1][k], d2FdXdY[ip1][jp1][k],
-                        d2FdXdY[i][j][kp1], d2FdXdY[ip1][j][kp1],
-                        d2FdXdY[i][jp1][kp1], d2FdXdY[ip1][jp1][kp1],
-
-                        d2FdXdZ[i][j][k], d2FdXdZ[ip1][j][k],
-                        d2FdXdZ[i][jp1][k], d2FdXdZ[ip1][jp1][k],
-                        d2FdXdZ[i][j][kp1], d2FdXdZ[ip1][j][kp1],
-                        d2FdXdZ[i][jp1][kp1], d2FdXdZ[ip1][jp1][kp1],
-
-                        d2FdYdZ[i][j][k], d2FdYdZ[ip1][j][k],
-                        d2FdYdZ[i][jp1][k], d2FdYdZ[ip1][jp1][k],
-                        d2FdYdZ[i][j][kp1], d2FdYdZ[ip1][j][kp1],
-                        d2FdYdZ[i][jp1][kp1], d2FdYdZ[ip1][jp1][kp1],
-
-                        d3FdXdYdZ[i][j][k], d3FdXdYdZ[ip1][j][k],
-                        d3FdXdYdZ[i][jp1][k], d3FdXdYdZ[ip1][jp1][k],
-                        d3FdXdYdZ[i][j][kp1], d3FdXdYdZ[ip1][j][kp1],
-                        d3FdXdYdZ[i][jp1][kp1], d3FdXdYdZ[ip1][jp1][kp1],
-                    };
-
-                    splines[i][j][k] = new TricubicSplineFunction(computeSplineCoefficients(beta));
-                }
-            }
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * @throws OutOfRangeException if any of the variables is outside its interpolation range.
-     */
-    public double value(double x, double y, double z)
-        throws OutOfRangeException {
-        final int i = searchIndex(x, xval);
-        if (i == -1) {
-            throw new OutOfRangeException(x, xval[0], xval[xval.length - 1]);
-        }
-        final int j = searchIndex(y, yval);
-        if (j == -1) {
-            throw new OutOfRangeException(y, yval[0], yval[yval.length - 1]);
-        }
-        final int k = searchIndex(z, zval);
-        if (k == -1) {
-            throw new OutOfRangeException(z, zval[0], zval[zval.length - 1]);
-        }
-
-        final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
-        final double yN = (y - yval[j]) / (yval[j + 1] - yval[j]);
-        final double zN = (z - zval[k]) / (zval[k + 1] - zval[k]);
-
-        return splines[i][j][k].value(xN, yN, zN);
-    }
-
-    /**
-     * @param c Coordinate.
-     * @param val Coordinate samples.
-     * @return the index in {@code val} corresponding to the interval containing {@code c}, or {@code -1}
-     *   if {@code c} is out of the range defined by the end values of {@code val}.
-     */
-    private int searchIndex(double c, double[] val) {
-        if (c < val[0]) {
-            return -1;
-        }
-
-        final int max = val.length;
-        for (int i = 1; i < max; i++) {
-            if (c <= val[i]) {
-                return i - 1;
-            }
-        }
-
-        return -1;
-    }
-
-    /**
-     * Compute the spline coefficients from the list of function values and
-     * function partial derivatives values at the four corners of a grid
-     * element. They must be specified in the following order:
-     * <ul>
-     *  <li>f(0,0,0)</li>
-     *  <li>f(1,0,0)</li>
-     *  <li>f(0,1,0)</li>
-     *  <li>f(1,1,0)</li>
-     *  <li>f(0,0,1)</li>
-     *  <li>f(1,0,1)</li>
-     *  <li>f(0,1,1)</li>
-     *  <li>f(1,1,1)</li>
-     *
-     *  <li>f<sub>x</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>x</sub>(1,1,1)</li>
-     *
-     *  <li>f<sub>y</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>y</sub>(1,1,1)</li>
-     *
-     *  <li>f<sub>z</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>z</sub>(1,1,1)</li>
-     *
-     *  <li>f<sub>xy</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>xy</sub>(1,1,1)</li>
-     *
-     *  <li>f<sub>xz</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>xz</sub>(1,1,1)</li>
-     *
-     *  <li>f<sub>yz</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>yz</sub>(1,1,1)</li>
-     *
-     *  <li>f<sub>xyz</sub>(0,0,0)</li>
-     *  <li>... <em>(same order as above)</em></li>
-     *  <li>f<sub>xyz</sub>(1,1,1)</li>
-     * </ul>
-     * where the subscripts indicate the partial derivative with respect to
-     * the corresponding variable(s).
-     *
-     * @param beta List of function values and function partial derivatives values.
-     * @return the spline coefficients.
-     */
-    private double[] computeSplineCoefficients(double[] beta) {
-        final int sz = 64;
-        final double[] a = new double[sz];
-
-        for (int i = 0; i < sz; i++) {
-            double result = 0;
-            final double[] row = AINV[i];
-            for (int j = 0; j < sz; j++) {
-                result += row[j] * beta[j];
-            }
-            a[i] = result;
-        }
-
-        return a;
-    }
-}
-
-/**
- * 3D-spline function.
- *
- */
-class TricubicSplineFunction
-    implements TrivariateFunction {
-    /** Number of points. */
-    private static final short N = 4;
-    /** Coefficients */
-    private final double[][][] a = new double[N][N][N];
-
-    /**
-     * @param aV List of spline coefficients.
-     */
-    public TricubicSplineFunction(double[] aV) {
-        for (int i = 0; i < N; i++) {
-            for (int j = 0; j < N; j++) {
-                for (int k = 0; k < N; k++) {
-                    a[i][j][k] = aV[i + N * (j + N * k)];
-                }
-            }
-        }
-    }
-
-    /**
-     * @param x x-coordinate of the interpolation point.
-     * @param y y-coordinate of the interpolation point.
-     * @param z z-coordinate of the interpolation point.
-     * @return the interpolated value.
-     * @throws OutOfRangeException if {@code x}, {@code y} or
-     * {@code z} are not in the interval {@code [0, 1]}.
-     */
-    public double value(double x, double y, double z)
-        throws OutOfRangeException {
-        if (x < 0 || x > 1) {
-            throw new OutOfRangeException(x, 0, 1);
-        }
-        if (y < 0 || y > 1) {
-            throw new OutOfRangeException(y, 0, 1);
-        }
-        if (z < 0 || z > 1) {
-            throw new OutOfRangeException(z, 0, 1);
-        }
-
-        final double x2 = x * x;
-        final double x3 = x2 * x;
-        final double[] pX = { 1, x, x2, x3 };
-
-        final double y2 = y * y;
-        final double y3 = y2 * y;
-        final double[] pY = { 1, y, y2, y3 };
-
-        final double z2 = z * z;
-        final double z3 = z2 * z;
-        final double[] pZ = { 1, z, z2, z3 };
-
-        double result = 0;
-        for (int i = 0; i < N; i++) {
-            for (int j = 0; j < N; j++) {
-                for (int k = 0; k < N; k++) {
-                    result += a[i][j][k] * pX[i] * pY[j] * pZ[k];
-                }
-            }
-        }
-
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0a5cd113/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolator.java
deleted file mode 100644
index c068f74..0000000
--- a/src/main/java/org/apache/commons/math4/analysis/interpolation/TricubicSplineInterpolator.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.
- */
-package org.apache.commons.math4.analysis.interpolation;
-
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NoDataException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.util.MathArrays;
-
-/**
- * Generates a tricubic interpolating function.
- *
- * @since 2.2
- * @deprecated To be removed in 4.0 (see MATH-1166).
- */
-@Deprecated
-public class TricubicSplineInterpolator
-    implements TrivariateGridInterpolator {
-    /**
-     * {@inheritDoc}
-     */
-    public TricubicSplineInterpolatingFunction interpolate(final double[] xval,
-                                                           final double[] yval,
-                                                           final double[] zval,
-                                                           final double[][][] fval)
-        throws NoDataException, NumberIsTooSmallException,
-               DimensionMismatchException, NonMonotonicSequenceException {
-        if (xval.length == 0 || yval.length == 0 || zval.length == 0 || fval.length == 0) {
-            throw new NoDataException();
-        }
-        if (xval.length != fval.length) {
-            throw new DimensionMismatchException(xval.length, fval.length);
-        }
-
-        MathArrays.checkOrder(xval);
-        MathArrays.checkOrder(yval);
-        MathArrays.checkOrder(zval);
-
-        final int xLen = xval.length;
-        final int yLen = yval.length;
-        final int zLen = zval.length;
-
-        // Samples, re-ordered as (z, x, y) and (y, z, x) tuplets
-        // fvalXY[k][i][j] = f(xval[i], yval[j], zval[k])
-        // fvalZX[j][k][i] = f(xval[i], yval[j], zval[k])
-        final double[][][] fvalXY = new double[zLen][xLen][yLen];
-        final double[][][] fvalZX = new double[yLen][zLen][xLen];
-        for (int i = 0; i < xLen; i++) {
-            if (fval[i].length != yLen) {
-                throw new DimensionMismatchException(fval[i].length, yLen);
-            }
-
-            for (int j = 0; j < yLen; j++) {
-                if (fval[i][j].length != zLen) {
-                    throw new DimensionMismatchException(fval[i][j].length, zLen);
-                }
-
-                for (int k = 0; k < zLen; k++) {
-                    final double v = fval[i][j][k];
-                    fvalXY[k][i][j] = v;
-                    fvalZX[j][k][i] = v;
-                }
-            }
-        }
-
-        final BicubicSplineInterpolator bsi = new BicubicSplineInterpolator(true);
-
-        // For each line x[i] (0 <= i < xLen), construct a 2D spline in y and z
-        final BicubicSplineInterpolatingFunction[] xSplineYZ
-            = new BicubicSplineInterpolatingFunction[xLen];
-        for (int i = 0; i < xLen; i++) {
-            xSplineYZ[i] = bsi.interpolate(yval, zval, fval[i]);
-        }
-
-        // For each line y[j] (0 <= j < yLen), construct a 2D spline in z and x
-        final BicubicSplineInterpolatingFunction[] ySplineZX
-            = new BicubicSplineInterpolatingFunction[yLen];
-        for (int j = 0; j < yLen; j++) {
-            ySplineZX[j] = bsi.interpolate(zval, xval, fvalZX[j]);
-        }
-
-        // For each line z[k] (0 <= k < zLen), construct a 2D spline in x and y
-        final BicubicSplineInterpolatingFunction[] zSplineXY
-            = new BicubicSplineInterpolatingFunction[zLen];
-        for (int k = 0; k < zLen; k++) {
-            zSplineXY[k] = bsi.interpolate(xval, yval, fvalXY[k]);
-        }
-
-        // Partial derivatives wrt x and wrt y
-        final double[][][] dFdX = new double[xLen][yLen][zLen];
-        final double[][][] dFdY = new double[xLen][yLen][zLen];
-        final double[][][] d2FdXdY = new double[xLen][yLen][zLen];
-        for (int k = 0; k < zLen; k++) {
-            final BicubicSplineInterpolatingFunction f = zSplineXY[k];
-            for (int i = 0; i < xLen; i++) {
-                final double x = xval[i];
-                for (int j = 0; j < yLen; j++) {
-                    final double y = yval[j];
-                    dFdX[i][j][k] = f.partialDerivativeX(x, y);
-                    dFdY[i][j][k] = f.partialDerivativeY(x, y);
-                    d2FdXdY[i][j][k] = f.partialDerivativeXY(x, y);
-                }
-            }
-        }
-
-        // Partial derivatives wrt y and wrt z
-        final double[][][] dFdZ = new double[xLen][yLen][zLen];
-        final double[][][] d2FdYdZ = new double[xLen][yLen][zLen];
-        for (int i = 0; i < xLen; i++) {
-            final BicubicSplineInterpolatingFunction f = xSplineYZ[i];
-            for (int j = 0; j < yLen; j++) {
-                final double y = yval[j];
-                for (int k = 0; k < zLen; k++) {
-                    final double z = zval[k];
-                    dFdZ[i][j][k] = f.partialDerivativeY(y, z);
-                    d2FdYdZ[i][j][k] = f.partialDerivativeXY(y, z);
-                }
-            }
-        }
-
-        // Partial derivatives wrt x and wrt z
-        final double[][][] d2FdZdX = new double[xLen][yLen][zLen];
-        for (int j = 0; j < yLen; j++) {
-            final BicubicSplineInterpolatingFunction f = ySplineZX[j];
-            for (int k = 0; k < zLen; k++) {
-                final double z = zval[k];
-                for (int i = 0; i < xLen; i++) {
-                    final double x = xval[i];
-                    d2FdZdX[i][j][k] = f.partialDerivativeXY(z, x);
-                }
-            }
-        }
-
-        // Third partial cross-derivatives
-        final double[][][] d3FdXdYdZ = new double[xLen][yLen][zLen];
-        for (int i = 0; i < xLen ; i++) {
-            final int nI = nextIndex(i, xLen);
-            final int pI = previousIndex(i);
-            for (int j = 0; j < yLen; j++) {
-                final int nJ = nextIndex(j, yLen);
-                final int pJ = previousIndex(j);
-                for (int k = 0; k < zLen; k++) {
-                    final int nK = nextIndex(k, zLen);
-                    final int pK = previousIndex(k);
-
-                    // XXX Not sure about this formula
-                    d3FdXdYdZ[i][j][k] = (fval[nI][nJ][nK] - fval[nI][pJ][nK] -
-                                          fval[pI][nJ][nK] + fval[pI][pJ][nK] -
-                                          fval[nI][nJ][pK] + fval[nI][pJ][pK] +
-                                          fval[pI][nJ][pK] - fval[pI][pJ][pK]) /
-                        ((xval[nI] - xval[pI]) * (yval[nJ] - yval[pJ]) * (zval[nK] - zval[pK])) ;
-                }
-            }
-        }
-
-        // Create the interpolating splines
-        return new TricubicSplineInterpolatingFunction(xval, yval, zval, fval,
-                                                       dFdX, dFdY, dFdZ,
-                                                       d2FdXdY, d2FdZdX, d2FdYdZ,
-                                                       d3FdXdYdZ);
-    }
-
-    /**
-     * Compute the next index of an array, clipping if necessary.
-     * It is assumed (but not checked) that {@code i} is larger than or equal to 0}.
-     *
-     * @param i Index
-     * @param max Upper limit of the array
-     * @return the next index
-     */
-    private int nextIndex(int i, int max) {
-        final int index = i + 1;
-        return index < max ? index : index - 1;
-    }
-    /**
-     * Compute the previous index of an array, clipping if necessary.
-     * It is assumed (but not checked) that {@code i} is smaller than the size of the array.
-     *
-     * @param i Index
-     * @return the previous index
-     */
-    private int previousIndex(int i) {
-        final int index = i - 1;
-        return index >= 0 ? index : 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0a5cd113/src/main/java/org/apache/commons/math4/analysis/solvers/NewtonSolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/solvers/NewtonSolver.java b/src/main/java/org/apache/commons/math4/analysis/solvers/NewtonSolver.java
deleted file mode 100644
index f377030..0000000
--- a/src/main/java/org/apache/commons/math4/analysis/solvers/NewtonSolver.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.commons.math4.analysis.solvers;
-
-import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
-import org.apache.commons.math4.util.FastMath;
-
-/**
- * Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
- * Newton's Method</a> for finding zeros of real univariate functions.
- * <p>
- * The function should be continuous but not necessarily smooth.</p>
- *
- * @deprecated as of 3.1, replaced by {@link NewtonRaphsonSolver}
- */
-@Deprecated
-public class NewtonSolver extends AbstractDifferentiableUnivariateSolver {
-    /** Default absolute accuracy. */
-    private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
-
-    /**
-     * Construct a solver.
-     */
-    public NewtonSolver() {
-        this(DEFAULT_ABSOLUTE_ACCURACY);
-    }
-    /**
-     * Construct a solver.
-     *
-     * @param absoluteAccuracy Absolute accuracy.
-     */
-    public NewtonSolver(double absoluteAccuracy) {
-        super(absoluteAccuracy);
-    }
-
-    /**
-     * Find a zero near the midpoint of {@code min} and {@code max}.
-     *
-     * @param f Function to solve.
-     * @param min Lower bound for the interval.
-     * @param max Upper bound for the interval.
-     * @param maxEval Maximum number of evaluations.
-     * @return the value where the function is zero.
-     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException
-     * if the maximum evaluation count is exceeded.
-     * @throws org.apache.commons.math4.exception.NumberIsTooLargeException
-     * if {@code min >= max}.
-     */
-    @Override
-    public double solve(int maxEval, final DifferentiableUnivariateFunction f,
-                        final double min, final double max)
-        throws TooManyEvaluationsException {
-        return super.solve(maxEval, f, UnivariateSolverUtils.midpoint(min, max));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected double doSolve()
-        throws TooManyEvaluationsException {
-        final double startValue = getStartValue();
-        final double absoluteAccuracy = getAbsoluteAccuracy();
-
-        double x0 = startValue;
-        double x1;
-        while (true) {
-            x1 = x0 - (computeObjectiveValue(x0) / computeDerivativeObjectiveValue(x0));
-            if (FastMath.abs(x1 - x0) <= absoluteAccuracy) {
-                return x1;
-            }
-
-            x0 = x1;
-        }
-    }
-}


Mime
View raw message