@Test public void testInterpolate() { System.out.println("interpolate"); double[] x1 = {1950, 1960, 1970, 1980, 1990}; double[] x2 = {10, 20, 30}; double[][] y = { {150.697, 199.592, 187.625}, {179.323, 195.072, 250.287}, {203.212, 179.092, 322.767}, {226.505, 153.706, 426.730}, {249.633, 120.281, 598.243} }; BilinearInterpolation instance = new BilinearInterpolation(x1, x2, y); assertEquals(190.6287, instance.interpolate(1975, 15), 1E-4); }
@Override public double interpolate(double x1, double x2) { int i = x1terp.search(x1); int j = x2terp.search(x2); double t = (x1-x1terp.xx[i])/(x1terp.xx[i+1]-x1terp.xx[i]); double u = (x2-x2terp.xx[j])/(x2terp.xx[j+1]-x2terp.xx[j]); double yy = (1.-t)*(1.-u)*y[i][j] + t*(1.-u)*y[i+1][j] + (1.-t)*u*y[i][j+1] + t*u*y[i+1][j+1]; return yy; }
BilinearInterpolation implements Interpolation2D { @Override public double interpolate(double x1, double x2) { int i = x1terp.search(x1); int j = x2terp.search(x2); double t = (x1-x1terp.xx[i])/(x1terp.xx[i+1]-x1terp.xx[i]); double u = (x2-x2terp.xx[j])/(x2terp.xx[j+1]-x2terp.xx[j]); double yy = (1.-t)*(1.-u)*y[i][j] + t*(1.-u)*y[i+1][j] + (1.-t)*u*y[i][j+1] + t*u*y[i+1][j+1]; return yy; } }
BilinearInterpolation implements Interpolation2D { @Override public double interpolate(double x1, double x2) { int i = x1terp.search(x1); int j = x2terp.search(x2); double t = (x1-x1terp.xx[i])/(x1terp.xx[i+1]-x1terp.xx[i]); double u = (x2-x2terp.xx[j])/(x2terp.xx[j+1]-x2terp.xx[j]); double yy = (1.-t)*(1.-u)*y[i][j] + t*(1.-u)*y[i+1][j] + (1.-t)*u*y[i][j+1] + t*u*y[i+1][j+1]; return yy; } BilinearInterpolation(double[] x1, double[] x2, double[][] y); }
BilinearInterpolation implements Interpolation2D { @Override public double interpolate(double x1, double x2) { int i = x1terp.search(x1); int j = x2terp.search(x2); double t = (x1-x1terp.xx[i])/(x1terp.xx[i+1]-x1terp.xx[i]); double u = (x2-x2terp.xx[j])/(x2terp.xx[j+1]-x2terp.xx[j]); double yy = (1.-t)*(1.-u)*y[i][j] + t*(1.-u)*y[i+1][j] + (1.-t)*u*y[i][j+1] + t*u*y[i+1][j+1]; return yy; } BilinearInterpolation(double[] x1, double[] x2, double[][] y); @Override double interpolate(double x1, double x2); @Override String toString(); }
BilinearInterpolation implements Interpolation2D { @Override public double interpolate(double x1, double x2) { int i = x1terp.search(x1); int j = x2terp.search(x2); double t = (x1-x1terp.xx[i])/(x1terp.xx[i+1]-x1terp.xx[i]); double u = (x2-x2terp.xx[j])/(x2terp.xx[j+1]-x2terp.xx[j]); double yy = (1.-t)*(1.-u)*y[i][j] + t*(1.-u)*y[i+1][j] + (1.-t)*u*y[i][j+1] + t*u*y[i+1][j+1]; return yy; } BilinearInterpolation(double[] x1, double[] x2, double[][] y); @Override double interpolate(double x1, double x2); @Override String toString();  }