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

The following examples show how to use org.apache.commons.math3.analysis.TrivariateFunction. 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: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Ignore@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #2
Source File: TricubicInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sine wave.
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };

    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction tcf = new TricubicInterpolator().interpolate(xval,
                                                                    yval,
                                                                    zval,
                                                                    fval);

    double x, y, z;
    double expected, result;

    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-14);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 1e-1); // XXX Too high tolerance!
}
 
Example #3
Source File: TricubicInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test for a plane.
 * <p>
 *  f(x, y, z) = 2 x - 3 y - 4 z + 5
 * </p>
 */
@Test
public void testPlane() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};

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

    double[][][] fval = new double[xval.length][yval.length][zval.length];

    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction tcf = new TricubicInterpolator().interpolate(xval,
                                                                    yval,
                                                                    zval,
                                                                    fval);
    double x, y, z;
    double expected, result;

    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 1e-14);
}
 
Example #4
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Ignore@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #5
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Ignore@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #6
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Ignore@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #7
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Ignore@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #8
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #9
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #10
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #11
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #12
Source File: Interpolation.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public static void testTri() {
//    	see http://commons.apache.org/proper/commons-math/userguide/analysis.html
        double[] xval = new double[] {203, 211, 221, 229, 238, 246, 248, 249, 252, 255, 218, 181};
        double[] yval = new double[] {166, 179, 193, 208, 223, 238, 241, 244, 249, 255, 253, 251};
        double[] zval = new double[] {155, 170, 185, 201, 218, 236, 239, 243, 249, 255, 255, 254};
 
        double[][][] fval = new double[xval.length][yval.length][zval.length];

        TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();
//        TricubicSplineInterpolator
        
        TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);

//        double[] wxval = new double[] {3, 2, 5, 6.5};
//        try {
//            p = interpolator.interpolate(wxval, yval, zval, fval);
////            Assert.fail("an exception should have been thrown");
//        } catch (MathIllegalArgumentException e) {
//            // Expected
//        }

//	      System.out.println("Piecewise functions:");
//	      Arrays.stream(p.getPolynomials()).forEach(System.out::println);
	      
	      double value = p.value(208, 185, 163);
	      System.out.println(value);
    
    
//        double[] wyval = new double[] {-4, -3, -1, -1};
//        try {
//            p = interpolator.interpolate(xval, wyval, zval, fval);
////            Assert.fail("an exception should have been thrown");
//        } catch (MathIllegalArgumentException e) {
//            // Expected
//        }
//
//        double[] wzval = new double[] {-12, -8, -5.5, -3, -4, 2.5};
//        try {
//            p = interpolator.interpolate(xval, yval, wzval, fval);
////            Assert.fail("an exception should have been thrown");
//        } catch (MathIllegalArgumentException e) {
//            // Expected
//        }
//
//        double[][][] wfval = new double[xval.length][yval.length + 1][zval.length];
//        try {
//            p = interpolator.interpolate(xval, yval, zval, wfval);
////            Assert.fail("an exception should have been thrown");
//        } catch (DimensionMismatchException e) {
//            // Expected
//        }
//        wfval = new double[xval.length - 1][yval.length][zval.length];
//        try {
//            p = interpolator.interpolate(xval, yval, zval, wfval);
////            Assert.fail("an exception should have been thrown");
//        } catch (DimensionMismatchException e) {
//            // Expected
//        }
//        wfval = new double[xval.length][yval.length][zval.length - 1];
//        try {
//            p = interpolator.interpolate(xval, yval, zval, wfval);
////            Assert.fail("an exception should have been thrown");
//        } catch (DimensionMismatchException e) {
//            // Expected
//        }
    }
 
Example #13
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Ignore@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #14
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #15
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #16
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #17
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #18
Source File: TricubicInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sine wave.
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };

    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction tcf = new TricubicInterpolator().interpolate(xval,
                                                                    yval,
                                                                    zval,
                                                                    fval);

    double x, y, z;
    double expected, result;

    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-14);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 1e-1); // XXX Too high tolerance!
}
 
Example #19
Source File: TricubicInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test for a plane.
 * <p>
 *  f(x, y, z) = 2 x - 3 y - 4 z + 5
 * </p>
 */
@Test
public void testPlane() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};

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

    double[][][] fval = new double[xval.length][yval.length][zval.length];

    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction tcf = new TricubicInterpolator().interpolate(xval,
                                                                    yval,
                                                                    zval,
                                                                    fval);
    double x, y, z;
    double expected, result;

    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = tcf.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 1e-14);
}
 
Example #20
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a sine wave.
 * <p>
 * <p>
 *  f(x, y, z) = a cos [&omega; z - k<sub>y</sub> x - k<sub>y</sub> y]
 * </p>
 * with A = 0.2, &omega; = 0.5, k<sub>x</sub> = 2, k<sub>y</sub> = 1.
 */
@Ignore@Test
public void testWave() {
    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 4};

    final double a = 0.2;
    final double omega = 0.5;
    final double kx = 2;
    final double ky = 1;

    // Function values
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return a * FastMath.cos(omega * z - kx * x - ky * y);
            }
        };
    
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point",
                        expected, result, 1e-12);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (middle of the patch)",
                        expected, result, 0.1);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("Half-way between sample points (border of the patch)",
                        expected, result, 0.1);
}
 
Example #21
Source File: TricubicSplineInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test of interpolator for a plane.
 * <p>
 * f(x, y, z) = 2 x - 3 y - z + 5
 */
@Ignore@Test
public void testPlane() {
    TrivariateFunction f = new TrivariateFunction() {
            public double value(double x, double y, double z) {
                return 2 * x - 3 * y - z + 5;
            }
        };

    TrivariateGridInterpolator interpolator = new TricubicSplineInterpolator();

    double[] xval = new double[] {3, 4, 5, 6.5};
    double[] yval = new double[] {-4, -3, -1, 2, 2.5};
    double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
    double[][][] fval = new double[xval.length][yval.length][zval.length];
    for (int i = 0; i < xval.length; i++) {
        for (int j = 0; j < yval.length; j++) {
            for (int k = 0; k < zval.length; k++) {
                fval[i][j][k] = f.value(xval[i], yval[j], zval[k]);
            }
        }
    }

    TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
    double x, y, z;
    double expected, result;
    
    x = 4;
    y = -3;
    z = 0;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("On sample point", expected, result, 1e-15);

    x = 4.5;
    y = -1.5;
    z = -4.25;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (middle of the patch)", expected, result, 0.3);

    x = 3.5;
    y = -3.5;
    z = -10;
    expected = f.value(x, y, z);
    result = p.value(x, y, z);
    Assert.assertEquals("half-way between sample points (border of the patch)", expected, result, 0.3);
}
 
Example #22
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws NoDataException if any of the arrays has zero length.
 * @throws DimensionMismatchException if the array lengths are inconsistent.
 * @throws NonMonotonicSequenceException if arrays are not sorted
 * @throws NumberIsTooSmallException if the number of points is too small for
 * the order of the interpolation
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                               double[][][] fval)
    throws NoDataException, NumberIsTooSmallException,
           DimensionMismatchException, NonMonotonicSequenceException;
 
Example #23
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws org.apache.commons.math3.exception.NoDataException if any of
 * the arrays has zero length.
 * @throws org.apache.commons.math3.exception.DimensionMismatchException
 * if the array lengths are inconsistent.
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                                   double[][][] fval);
 
Example #24
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws org.apache.commons.math3.exception.NoDataException if any of
 * the arrays has zero length.
 * @throws org.apache.commons.math3.exception.DimensionMismatchException
 * if the array lengths are inconsistent.
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                                   double[][][] fval);
 
Example #25
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws NoDataException if any of the arrays has zero length.
 * @throws DimensionMismatchException if the array lengths are inconsistent.
 * @throws NonMonotonicSequenceException if arrays are not sorted
 * @throws NumberIsTooSmallException if the number of points is too small for
 * the order of the interpolation
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                               double[][][] fval)
    throws NoDataException, NumberIsTooSmallException,
           DimensionMismatchException, NonMonotonicSequenceException;
 
Example #26
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws NoDataException if any of the arrays has zero length.
 * @throws DimensionMismatchException if the array lengths are inconsistent.
 * @throws NonMonotonicSequenceException if arrays are not sorted
 * @throws NumberIsTooSmallException if the number of points is too small for
 * the order of the interpolation
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                               double[][][] fval)
    throws NoDataException, NumberIsTooSmallException,
           DimensionMismatchException, NonMonotonicSequenceException;
 
Example #27
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws NoDataException if any of the arrays has zero length.
 * @throws DimensionMismatchException if the array lengths are inconsistent.
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                               double[][][] fval)
    throws NoDataException,
           DimensionMismatchException;
 
Example #28
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws NoDataException if any of the arrays has zero length.
 * @throws DimensionMismatchException if the array lengths are inconsistent.
 * @throws NonMonotonicSequenceException if arrays are not sorted
 * @throws NumberIsTooSmallException if the number of points is too small for
 * the order of the interpolation
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                               double[][][] fval)
    throws NoDataException, NumberIsTooSmallException,
           DimensionMismatchException, NonMonotonicSequenceException;
 
Example #29
Source File: TrivariateGridInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compute an interpolating function for the dataset.
 *
 * @param xval All the x-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param yval All the y-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param zval All the z-coordinates of the interpolation points, sorted
 * in increasing order.
 * @param fval the values of the interpolation points on all the grid knots:
 * {@code fval[i][j][k] = f(xval[i], yval[j], zval[k])}.
 * @return a function that interpolates the data set.
 * @throws NoDataException if any of the arrays has zero length.
 * @throws DimensionMismatchException if the array lengths are inconsistent.
 * @throws NonMonotonicSequenceException if arrays are not sorted
 * @throws NumberIsTooSmallException if the number of points is too small for
 * the order of the interpolation
 */
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
                               double[][][] fval)
    throws NoDataException, NumberIsTooSmallException,
           DimensionMismatchException, NonMonotonicSequenceException;