org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolator Java Examples
The following examples show how to use
org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolator.
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: BicubicSplineEvaluator.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public Object doWork(Object... objects) throws IOException { if(objects.length != 3) { throw new IOException("The bicubicSpline function requires three paremeters,"+objects.length+" found."); } Object first = objects[0]; Object second = objects[1]; Object third = objects[2]; double[] x = null; double[] y = null; double[][] grid = null; if(first instanceof List && second instanceof List && third instanceof Matrix) { @SuppressWarnings({"unchecked"}) List<Number> xlist = (List<Number>) first; x = new double[xlist.size()]; for(int i=0; i<x.length; i++) { x[i]=xlist.get(i).doubleValue(); } @SuppressWarnings({"unchecked"}) List<Number> ylist = (List<Number>) second; y = new double[ylist.size()]; for(int i=0; i<y.length; i++) { y[i] = ylist.get(i).doubleValue(); } Matrix matrix = (Matrix)third; grid = matrix.getData(); PiecewiseBicubicSplineInterpolator interpolator = new PiecewiseBicubicSplineInterpolator(); BivariateFunction bivariateFunction = interpolator.interpolate(x, y, grid); return bivariateFunction; } else { throw new IOException("The bicubicSpline function expects two numeric arrays and a matrix as parameters."); } }
Example #2
Source File: Interpolation.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void test1() { double[] xValues = new double[] {36, 36.001, 36.002}; double[] yValues = new double[] {-108.00, -107.999, -107.998}; double[][] fValues = new double[][] {{1915, 1906, 1931}, {1877, 1889, 1894}, {1878, 1873, 1888}}; // BicubicSplineInterpolator interpolator = new BicubicSplineInterpolator(); PiecewiseBicubicSplineInterpolator interpolator = new PiecewiseBicubicSplineInterpolator(); // BicubicSplineInterpolatingFunction interpolatorFunction = interpolator.interpolate(xValues, yValues, fValues); PiecewiseBicubicSplineInterpolatingFunction interpolatorFunction = interpolator.interpolate(xValues, yValues, fValues); double[][] results = new double[9][9]; double x = 36; int arrayIndexX = 0; int arrayIndexY = 0; while(x <= 36.002) { double y = -108; arrayIndexY = 0; while (y <= -107.998) { results[arrayIndexX][arrayIndexY] = interpolatorFunction.value(x, y); System.out.println(results[arrayIndexX][arrayIndexY]); y = y + 0.00025; arrayIndexY++; } x = x + 0.00025; arrayIndexX++; } }