/** * This is the Taylor expansion of $$\frac{\exp(x)-1}{x}$$ - note for $$|x| > 10^{-10}$$ the expansion is note used . * * @param x the value * @return the result */ public static double epsilon(double x) { if (Math.abs(x) > 1e-10) { return Math.expm1(x) / x; } return taylor(x, COEFF1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffDoubleNtimesTtooSmall() { Diff.values(_dataDouble, -1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullVector() { CommonsMathWrapper.unwrap((RealVector) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull1DMatrix() { CommonsMathWrapper.wrap((DoubleArray) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull1DFunction() { CommonsMathWrapper.wrapUnivariate((Function<Double, Double>) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffIntegerNtimesTtooLarge() { Diff.values(_dataInteger, 8); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullRealMatrix() { CommonsMathWrapper.unwrap((RealMatrix) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullMatrix() { CommonsMathWrapper.wrap((DoubleMatrix) null); }
/** * This is the Taylor expansion of the first derivative of $$\frac{\exp(x)-1}{x}$$. * * @param x the value * @return the result */ public static double epsilonP(double x) { if (Math.abs(x) > 1e-7) { return ((x - 1) * Math.expm1(x) + x) / x / x; } return taylor(x, COEFF2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffLongNtimesTtooSmall() { Diff.values(_dataLong, -1); }
/** * This is the Taylor expansion of the second derivative of $$\frac{\exp(x)-1}{x}$$. * * @param x the value * @return the result */ public static double epsilonPP(double x) { if (Math.abs(x) > 1e-5) { double x2 = x * x; double x3 = x * x2; return (Math.expm1(x) * (x2 - 2 * x + 2) + x2 - 2 * x) / x3; } return taylor(x, COEFF3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffDoubleNull() { Diff.values(_dataNullDouble); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffFloatNtimesFloatNull() { Diff.values(_dataNullFloat, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffFloatNtimesTtooSmall() { Diff.values(_dataFloat, -1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffIntegerNull() { Diff.values(_dataNullInteger); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffDoubleNtimesTtooLarge() { Diff.values(_dataDouble, 8); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffLongNtimesTtooLarge() { Diff.values(_dataLong, 8); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffFloatNull() { Diff.values(_dataNullFloat); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffLongNull() { Diff.values(_dataNullLong); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffDoubleNtimesDoubleNull() { Diff.values(_dataNullDouble, 1); }