...

Commits (3)
 ... ... @@ -570,9 +570,9 @@ public class NumericUtils { * and downsample rates by dividing the timeseries intervals * by this value * * @param source Initially, one of two frequencies to calculate * @param target Initially, one of two frequencies to calculate * @return The GCD of the two frequencies * @param source Sampling interval * @param target Sampling interval * @return The GCD of the two sampling intervals */ public static long euclidGCD(long source, long target) { ... ... @@ -586,6 +586,21 @@ public class NumericUtils { return euclidGCD(target, rem); } /** * Use {@link #euclidGCD} to calculate the least common multiple of sampling intervals. * This is done in order to get the lowest-common frequency among these intervals, for cases * in which any upsampling in the process of decimation is unwanted. * In these cases the LCM of two intervals represents the greatest common denominator * of the sample rate. * @param source Sampling interval * @param target Sampling interval * @return The LCM of the two sampling intervals */ public static long euclidLCM(long source, long target) { long gcd = euclidGCD(source, target); return (source * target) / gcd; } /** * Return the calculation of the arithmetic mean (using a recursive definition for stability) * ... ...
 ... ... @@ -170,6 +170,14 @@ public class NumericUtilsTest { assertEquals(2L, NumericUtils.euclidGCD(2147483612, 2137483646)); } @Test public final void euclidLCM_basicTest() { assertEquals(100L, NumericUtils.euclidLCM(100, 50)); assertEquals(100L, NumericUtils.euclidLCM(50, 100)); assertEquals(34965L, NumericUtils.euclidLCM(999, 105)); assertEquals(2295105550351504676L, NumericUtils.euclidLCM(2147483612, 2137483646)); } @Test public final void downsample_thirdOfFrequency() { double[] in = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; ... ...