/** Test of interpolate method, of class NaturalSpline. */ @Test public void testInterpolate5() { double[] xx = new double[] {1, 11, 20, 30, 40}; double[] yy = new double[] {1, 2, 3, 4, 3}; NaturalSpline spline = NaturalSpline.interpolate(xx, yy); System.out.println(spline.toString()); for (double x = xx[0]; x <= xx[xx.length - 1]; x++) { double y = spline.yAtX(x); System.out.println("x=" + x + " y=" + (float) y); } }
/** Test of interpolate method, of class NaturalSpline. */ @Test public void testInterpolateDiff() { double[] xx = new double[] {}; double[] yy = new double[] {1}; try { NaturalSpline spline = NaturalSpline.interpolate(xx, yy); fail("Exception should be raised when no points are defined"); System.out.println(spline.toString()); } catch (IllegalArgumentException expected) { checkException(expected); } }