@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 testDiffDoubleNtimesTtooSmall() { Diff.values(_dataDouble, -1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffIntegerNtimesTtooLarge() { Diff.values(_dataInteger, 8); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffLongNtimesTtooSmall() { Diff.values(_dataLong, -1); }
@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 testDiffDoubleNtimesDoubleNull() { Diff.values(_dataNullDouble, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffFloatNtimesTtooLarge() { Diff.values(_dataFloat, 8); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffIntegerNtimesIntegerNull() { Diff.values(_dataNullInteger, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffIntegerNtimesTtooSmall() { Diff.values(_dataInteger, -1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDiffLongNtimesLongNull() { Diff.values(_dataNullLong, 1); }
/** * Finds the t^{th} numerical difference between value at position (i+1) and (i) * (effectively recurses #values "t" times). * * @param v the vector * @param t the number of differences to be taken (t positive) * @return the numerical difference between adjacent elements in v */ public static int[] values(int[] v, int t) { ArgChecker.notNull(v, "v"); ArgChecker.isTrue((t > -1), "Invalid number of differences requested, t must be positive or 0, but was {}", t); ArgChecker.isTrue((t < v.length), "Invalid number of differences requested, 't' is greater than the number of " + "elements in 'v'. The given 't' was: {} and 'v' contains {} elements", t, v.length); int[] tmp; if (t == 0) { // no differencing done tmp = new int[v.length]; System.arraycopy(v, 0, tmp, 0, v.length); } else { tmp = values(v); for (int i = 0; i < t - 1; i++) { tmp = values(tmp); } } return tmp; }
/** * Finds the t^{th} numerical difference between value at position (i+1) and (i) * (effectively recurses #values "t" times). * * @param v the vector * @param t the number of differences to be taken (t positive) * @return the numerical difference between adjacent elements in v */ public static float[] values(float[] v, int t) { ArgChecker.notNull(v, "v"); ArgChecker.isTrue((t > -1), "Invalid number of differences requested, t must be positive or 0, but was {}", t); ArgChecker.isTrue((t < v.length), "Invalid number of differences requested, 't' is greater than the number of " + "elements in 'v'. The given 't' was: {} and 'v' contains {} elements", t, v.length); float[] tmp; if (t == 0) { // no differencing done tmp = new float[v.length]; System.arraycopy(v, 0, tmp, 0, v.length); } else { tmp = values(v); for (int i = 0; i < t - 1; i++) { tmp = values(tmp); } } return tmp; }
/** * Finds the t^{th} numerical difference between value at position (i+1) and (i) * (effectively recurses #values "t" times). * * @param v the vector * @param t the number of differences to be taken (t positive) * @return the numerical difference between adjacent elements in v */ public static long[] values(long[] v, int t) { ArgChecker.notNull(v, "v"); ArgChecker.isTrue((t > -1), "Invalid number of differences requested, t must be positive or 0, but was {}", t); ArgChecker.isTrue((t < v.length), "Invalid number of differences requested, 't' is greater than the number of " + "elements in 'v'. The given 't' was: {} and 'v' contains {} elements", t, v.length); long[] tmp; if (t == 0) { // no differencing done tmp = new long[v.length]; System.arraycopy(v, 0, tmp, 0, v.length); } else { tmp = values(v); for (int i = 0; i < t - 1; i++) { tmp = values(tmp); } } return tmp; }
/** * Finds the t^{th} numerical difference between value at position (i+1) and (i) * (effectively recurses #values "t" times). * * @param v the vector * @param t the number of differences to be taken (t positive) * @return the numerical difference between adjacent elements in v */ public static double[] values(double[] v, int t) { ArgChecker.notNull(v, "v"); ArgChecker.isTrue((t > -1), "Invalid number of differences requested, t must be positive or 0, but was {}", t); ArgChecker.isTrue((t < v.length), "Invalid number of differences requested, 't' is greater than the number of " + "elements in 'v'. The given 't' was: {} and 'v' contains {} elements", t, v.length); double[] tmp; if (t == 0) { // no differencing done tmp = new double[v.length]; System.arraycopy(v, 0, tmp, 0, v.length); } else { tmp = values(v); for (int i = 0; i < t - 1; i++) { tmp = values(tmp); } } return tmp; }