org.apache.commons.math3.analysis.BivariateFunction Java Examples

The following examples show how to use org.apache.commons.math3.analysis.BivariateFunction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute all partial derivatives.
 */
private void computePartialDerivatives() {
    final int lastI = xval.length - 1;
    final int lastJ = yval.length - 1;
    partialDerivatives = new BivariateFunction[5][lastI][lastJ];

    for (int i = 0; i < lastI; i++) {
        for (int j = 0; j < lastJ; j++) {
            final BicubicSplineFunction f = splines[i][j];
            partialDerivatives[0][i][j] = f.partialDerivativeX();
            partialDerivatives[1][i][j] = f.partialDerivativeY();
            partialDerivatives[2][i][j] = f.partialDerivativeXX();
            partialDerivatives[3][i][j] = f.partialDerivativeYY();
            partialDerivatives[4][i][j] = f.partialDerivativeXY();
        }
    }
}
 
Example #2
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute all partial derivatives.
 */
private void computePartialDerivatives() {
    final int lastI = xval.length - 1;
    final int lastJ = yval.length - 1;
    partialDerivatives = new BivariateFunction[5][lastI][lastJ];

    for (int i = 0; i < lastI; i++) {
        for (int j = 0; j < lastJ; j++) {
            final BicubicSplineFunction f = splines[i][j];
            partialDerivatives[0][i][j] = f.partialDerivativeX();
            partialDerivatives[1][i][j] = f.partialDerivativeY();
            partialDerivatives[2][i][j] = f.partialDerivativeXX();
            partialDerivatives[3][i][j] = f.partialDerivativeYY();
            partialDerivatives[4][i][j] = f.partialDerivativeXY();
        }
    }
}
 
Example #3
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute all partial derivatives.
 */
private void computePartialDerivatives() {
    final int lastI = xval.length - 1;
    final int lastJ = yval.length - 1;
    partialDerivatives = new BivariateFunction[5][lastI][lastJ];

    for (int i = 0; i < lastI; i++) {
        for (int j = 0; j < lastJ; j++) {
            final BicubicSplineFunction f = splines[i][j];
            partialDerivatives[0][i][j] = f.partialDerivativeX();
            partialDerivatives[1][i][j] = f.partialDerivativeY();
            partialDerivatives[2][i][j] = f.partialDerivativeXX();
            partialDerivatives[3][i][j] = f.partialDerivativeYY();
            partialDerivatives[4][i][j] = f.partialDerivativeXY();
        }
    }
}
 
Example #4
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compute all partial derivatives.
 */
private void computePartialDerivatives() {
    final int lastI = xval.length - 1;
    final int lastJ = yval.length - 1;
    partialDerivatives = new BivariateFunction[5][lastI][lastJ];

    for (int i = 0; i < lastI; i++) {
        for (int j = 0; j < lastJ; j++) {
            final BicubicSplineFunction f = splines[i][j];
            partialDerivatives[0][i][j] = f.partialDerivativeX();
            partialDerivatives[1][i][j] = f.partialDerivativeY();
            partialDerivatives[2][i][j] = f.partialDerivativeXX();
            partialDerivatives[3][i][j] = f.partialDerivativeYY();
            partialDerivatives[4][i][j] = f.partialDerivativeXY();
        }
    }
}
 
Example #5
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeY() {
    if (partialDerivativeY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeY;
}
 
Example #6
Source File: PiecewiseBicubicSplineInterpolatingFunctionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interpolating a paraboloid.
 * <p>
 * z = 2 x<sup>2</sup> - 3 y<sup>2</sup> + 4 x y - 5
 */
@Test
public void testParabaloid() {
    final int numberOfElements = 10;
    final double minimumX = -10;
    final double maximumX = 10;
    final double minimumY = -10;
    final double maximumY = 10;
    final int numberOfSamples = 100;

    final double interpolationTolerance = 2e-14;
    final double maxTolerance = 6e-14;

    // Function values
    BivariateFunction f = new BivariateFunction() {
            public double value(double x, double y) {
                return 2 * x * x - 3 * y * y + 4 * x * y - 5;
            }
        };

    testInterpolation(minimumX,
                      maximumX,
                      minimumY,
                      maximumY,
                      numberOfElements,
                      numberOfSamples,
                      f,
                      interpolationTolerance,
                      maxTolerance);
}
 
Example #7
Source File: BicubicInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interpolating a plane.
 * <p>
 * z = 2 x - 3 y + 5
 */
@Test
public void testPlane() {
    BivariateFunction f = new BivariateFunction() {
            public double value(double x, double y) {
                return 2 * x - 3 * y + 5;
            }
        };

    testInterpolation(3000,
                      1e-13,
                      f,
                      false);
}
 
Example #8
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeYY() {
    if (partialDerivativeYY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeYY;
}
 
Example #9
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial cross-derivative.
 */
public BivariateFunction partialDerivativeXY() {
    if (partialDerivativeXY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXY;
}
 
Example #10
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeX() {
    if (partialDerivativeX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeX;
}
 
Example #11
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeX() {
    if (partialDerivativeX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeX;
}
 
Example #12
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeY() {
    if (partialDerivativeY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeY;
}
 
Example #13
Source File: InterpUtil.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Make interpolation function for grid data
 *
 * @param x X data
 * @param y Y data
 * @param z Z data
 * @return Interpolation function
 */
public static BivariateFunction getBiInterpFunc(Array x, Array y, Array z) {
    double[] xd = (double[]) ArrayUtil.copyToNDJavaArray_Double(x);
    double[] yd = (double[]) ArrayUtil.copyToNDJavaArray_Double(y);
    double[][] zd = (double[][]) ArrayUtil.copyToNDJavaArray_Double(z);
    BivariateGridInterpolator li = new BicubicInterpolator();
    BivariateFunction func = li.interpolate(xd, yd, zd);

    return func;
}
 
Example #14
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeYY() {
    if (partialDerivativeYY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeYY;
}
 
Example #15
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial cross-derivative.
 */
public BivariateFunction partialDerivativeXY() {
    if (partialDerivativeXY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXY;
}
 
Example #16
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeX() {
    if (partialDerivativeX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeX;
}
 
Example #17
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeXX() {
    if (partialDerivativeXX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXX;
}
 
Example #18
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeYY() {
    if (partialDerivativeYY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeYY;
}
 
Example #19
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial cross-derivative.
 */
public BivariateFunction partialDerivativeXY() {
    if (partialDerivativeXY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXY;
}
 
Example #20
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeY() {
    if (partialDerivativeY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeY;
}
 
Example #21
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeX() {
    if (partialDerivativeX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeX;
}
 
Example #22
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeY() {
    if (partialDerivativeY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeY;
}
 
Example #23
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeXX() {
    if (partialDerivativeXX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXX;
}
 
Example #24
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeYY() {
    if (partialDerivativeYY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeYY;
}
 
Example #25
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial cross-derivative.
 */
public BivariateFunction partialDerivativeXY() {
    if (partialDerivativeXY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXY;
}
 
Example #26
Source File: PiecewiseBicubicSplineInterpolatingFunctionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interpolating a paraboloid.
 * <p>
 * z = 2 x<sup>2</sup> - 3 y<sup>2</sup> + 4 x y - 5
 */
@Test
public void testParabaloid() {
    final int numberOfElements = 10;
    final double minimumX = -10;
    final double maximumX = 10;
    final double minimumY = -10;
    final double maximumY = 10;
    final int numberOfSamples = 100;

    final double interpolationTolerance = 2e-14;
    final double maxTolerance = 6e-14;

    // Function values
    BivariateFunction f = new BivariateFunction() {
            public double value(double x, double y) {
                return 2 * x * x - 3 * y * y + 4 * x * y - 5;
            }
        };

    testInterpolation(minimumX,
                      maximumX,
                      minimumY,
                      maximumY,
                      numberOfElements,
                      numberOfSamples,
                      f,
                      interpolationTolerance,
                      maxTolerance);
}
 
Example #27
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeY() {
    if (partialDerivativeY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeY;
}
 
Example #28
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code x}.
 */
public BivariateFunction partialDerivativeXX() {
    if (partialDerivativeXX == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXX;
}
 
Example #29
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial derivative wrt {@code y}.
 */
public BivariateFunction partialDerivativeYY() {
    if (partialDerivativeYY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeYY;
}
 
Example #30
Source File: BicubicSplineInterpolatingFunction.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the second partial cross-derivative.
 */
public BivariateFunction partialDerivativeXY() {
    if (partialDerivativeXY == null) {
        computePartialDerivatives();
    }

    return partialDerivativeXY;
}