@Test public void testInterpolate() { System.out.println("interpolate"); AbstractGraphRow row = new GraphRowSumValues(false); row.add(1, 1); row.add(2, 4); row.add(4, 2); CubicSpline instance = new CubicSpline(row); double xx = 1.0; double expResult = 1.0; double result = instance.interpolate(xx); Assert.assertEquals(expResult, result, 0.0); xx = 3.5; expResult = 3.125; result = instance.interpolate(xx); Assert.assertEquals(expResult, result, 0.0); }
public double interpolate(double xx) { double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; int k = 0; int klo = 0; int khi = size - 1; while (khi - klo > 1) { k = (khi + klo) >>> 1; if (x[k] > xx) { khi = k; } else { klo = k; } } h = x[khi] - x[klo]; a = (x[khi] - xx) / h; b = (xx - x[klo]) / h; yy = a * y[klo] + b * y[khi] + ((a * a * a - a) * d2ydx2[klo] + (b * b * b - b) * d2ydx2[khi]) * (h * h) / 6.0; return yy; }
CubicSpline { public double interpolate(double xx) { double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; int k = 0; int klo = 0; int khi = size - 1; while (khi - klo > 1) { k = (khi + klo) >>> 1; if (x[k] > xx) { khi = k; } else { klo = k; } } h = x[khi] - x[klo]; a = (x[khi] - xx) / h; b = (xx - x[klo]) / h; yy = a * y[klo] + b * y[khi] + ((a * a * a - a) * d2ydx2[klo] + (b * b * b - b) * d2ydx2[khi]) * (h * h) / 6.0; return yy; } }
CubicSpline { public double interpolate(double xx) { double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; int k = 0; int klo = 0; int khi = size - 1; while (khi - klo > 1) { k = (khi + klo) >>> 1; if (x[k] > xx) { khi = k; } else { klo = k; } } h = x[khi] - x[klo]; a = (x[khi] - xx) / h; b = (xx - x[klo]) / h; yy = a * y[klo] + b * y[khi] + ((a * a * a - a) * d2ydx2[klo] + (b * b * b - b) * d2ydx2[khi]) * (h * h) / 6.0; return yy; } CubicSpline(AbstractGraphRow row); }
CubicSpline { public double interpolate(double xx) { double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; int k = 0; int klo = 0; int khi = size - 1; while (khi - klo > 1) { k = (khi + klo) >>> 1; if (x[k] > xx) { khi = k; } else { klo = k; } } h = x[khi] - x[klo]; a = (x[khi] - xx) / h; b = (xx - x[klo]) / h; yy = a * y[klo] + b * y[khi] + ((a * a * a - a) * d2ydx2[klo] + (b * b * b - b) * d2ydx2[khi]) * (h * h) / 6.0; return yy; } CubicSpline(AbstractGraphRow row); final void init(AbstractGraphRow row); double interpolate(double xx); }
CubicSpline { public double interpolate(double xx) { double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; int k = 0; int klo = 0; int khi = size - 1; while (khi - klo > 1) { k = (khi + klo) >>> 1; if (x[k] > xx) { khi = k; } else { klo = k; } } h = x[khi] - x[klo]; a = (x[khi] - xx) / h; b = (xx - x[klo]) / h; yy = a * y[klo] + b * y[khi] + ((a * a * a - a) * d2ydx2[klo] + (b * b * b - b) * d2ydx2[khi]) * (h * h) / 6.0; return yy; } CubicSpline(AbstractGraphRow row); final void init(AbstractGraphRow row); double interpolate(double xx);  }