FunctionalCurveShiftFunction implements CurveShiftFunction<FunctionalDoublesCurve> { @Override public FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double shift) { Validate.notNull(curve, "curve"); return evaluate(curve, shift, "PARALLEL_SHIFT_" + curve.getName()); }  @Override FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double shift); @Override FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double shift, final String newName); @Override FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double x, final double shift); @Override FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double x, final double shift, final String newName); @Override FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double[] xShift, final double[] yShift); @Override FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double[] xShift, final double[] yShift, final String newName);  }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test1() { SHIFT.evaluate(CURVE, 2, 1); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test2() { SHIFT.evaluate(CURVE, 2, 1, "A"); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test3() { SHIFT.evaluate(CURVE, new double[] {2 }, new double[] {1 }); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test4() { SHIFT.evaluate(CURVE, new double[] {2 }, new double[] {1 }, "A"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurve1() { SHIFT.evaluate(null, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurve2() { SHIFT.evaluate(null, 1, "B"); }
@Test public void test() { final double shift = 0.34; FunctionalDoublesCurve shifted = SHIFT.evaluate(CURVE, shift); for (int i = 0; i < 10; i++) { final double x = Math.random(); assertEquals(shifted.getYValue(x), F.evaluate(x) + shift, 1e-15); } assertEquals(shifted.getName(), "PARALLEL_SHIFT_X"); final String newName = "Y"; shifted = SHIFT.evaluate(CURVE, shift, newName); for (int i = 0; i < 10; i++) { final double x = Math.random(); assertEquals(shifted.getYValue(x), F.evaluate(x) + shift, 1e-15); } assertEquals(shifted.getName(), newName); }