@Test public void testConstant(){ double[] x = new double[] { 1 }; double[] y = new double[] { 1 }; LinearInterpolatedFunction fct = new LinearInterpolatedFunction(x, y); assertThat(fct.value(0), equalTo(y[0])); assertThat(fct.value(100), equalTo(y[0])); }
public double value(double x0) { if (splineFunction != null && splineFunction.isValidPoint(x0)) { return splineFunction.value(x0); } if (x0 <= start.getX()) { return start.getY(); } if (x0 >= end.getX()) { return end.getY(); } throw new IllegalStateException("should not reach undefined function range=" + x0); }
LinearInterpolatedFunction { public double value(double x0) { if (splineFunction != null && splineFunction.isValidPoint(x0)) { return splineFunction.value(x0); } if (x0 <= start.getX()) { return start.getY(); } if (x0 >= end.getX()) { return end.getY(); } throw new IllegalStateException("should not reach undefined function range=" + x0); } }
LinearInterpolatedFunction { public double value(double x0) { if (splineFunction != null && splineFunction.isValidPoint(x0)) { return splineFunction.value(x0); } if (x0 <= start.getX()) { return start.getY(); } if (x0 >= end.getX()) { return end.getY(); } throw new IllegalStateException("should not reach undefined function range=" + x0); } LinearInterpolatedFunction(double[] x, double[] y); }
LinearInterpolatedFunction { public double value(double x0) { if (splineFunction != null && splineFunction.isValidPoint(x0)) { return splineFunction.value(x0); } if (x0 <= start.getX()) { return start.getY(); } if (x0 >= end.getX()) { return end.getY(); } throw new IllegalStateException("should not reach undefined function range=" + x0); } LinearInterpolatedFunction(double[] x, double[] y); int getNumberOfDataPoints(); double value(double x0); }
LinearInterpolatedFunction { public double value(double x0) { if (splineFunction != null && splineFunction.isValidPoint(x0)) { return splineFunction.value(x0); } if (x0 <= start.getX()) { return start.getY(); } if (x0 >= end.getX()) { return end.getY(); } throw new IllegalStateException("should not reach undefined function range=" + x0); } LinearInterpolatedFunction(double[] x, double[] y); int getNumberOfDataPoints(); double value(double x0);  }