@Test public void testSum() { double[] da = {1, 2, 0, -1, -3}; double[] da2 = {0.5, -2, 30, 1, -30}; Assert.assertTrue(inDelta(DoubleArrays.sum(da), -1)); Assert.assertTrue(inDelta(DoubleArrays.sum(da, da2), new double[]{1.5, 0, 30, 0, -33})); DoubleArrays.addToFirst(da, da2); Assert.assertTrue(inDelta(da, new double[]{1.5, 0, 30, 0, -33})); }
public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } private  DoubleArrays(); }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } private  DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] input); static double[] convert(float[] input); static boolean arrayEqualsInRange(double[] d1, double[] d2, double range); static boolean arrayEquals(double[] d1, double[] d2); static double[] appendZeros(double[] darray, int zeroAmountToAppend); static double[] normalize16bitLittleEndian(byte[] bytez); static double[] normalize16bitLittleEndian(byte[] bytez, int amount); static byte[] denormalize16BitLittleEndian(double[] input); static int[] toUnsignedInteger(double[] input, int max); static double max(double... input); static double min(double... input); static void validateArray(double... input); static int maxIndex(double... input); static int minIndex(double... input); static double sum(double... input); static double[] sum(double[] a1, double[] a2); static void addToFirst(double[] first, double[] second); static void addToAll(double[] data, double valueToAdd); static void addToFirstScaled(double[] first, double[] second, double scale); static double[] square(double... input); static void squareInPlace(double... input); static double[] subtract(double[] a1, double[] a2); static void subtractFromFirst(double[] first, double[] second); static double[] multiply(double[] a1, double[] a2); static double dotProduct(double[] a1, double[] a2); static void multiplyToFirst(double[] first, double[] second); static double[] scale(double[] a1, double b); static void scaleInPlace(double[] a1, double b); static double mean(double... input); static double absoluteSumOfDifferences(double[] a, double[] b); static double[] absoluteDifference(double[] a, double[] b); static void validateArrays(double[] a1, double[] a2); static double squaredSum(double[] array); static double squaredSumOfDifferences(double[] a, double[] b); static double variance(double[] input); static double standardDeviation(double[] a); static boolean containsNaN(double[] a); static void floorInPlace(double[] var, double minValue); static void nonZeroFloorInPlace(double[] data, double floor); static void normalizeInPlace(double[] data); static void serialize(DataOutputStream dos, double[] data); static void serializeRaw(DataOutputStream dos, double[] data); static void serialize(DataOutputStream dos, double[][] data); static void serializeRaw(DataOutputStream dos, double[][] data); static double[] deserialize(DataInputStream dis); static double[] deserializeRaw(DataInputStream dis, int amount); static void deserializeRaw(DataInputStream dis, double[] result); static double[][] deserialize2d(DataInputStream dis); static void deserialize2DRaw(DataInputStream dis, double[][] result); static double[][] clone2D(double[][] result); static double[] fromString(String str, String delimiter); static String format(double... input); static String format(int fractionDigits, String delimiter, double... input); static String format(int rightPad, int fractionDigits, String delimiter, double... input); static double[] reduceFractionDigits(double[] arr, int digitCount); static float[] fromDelimitedString(String input, String delimiter); }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } private  DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] input); static double[] convert(float[] input); static boolean arrayEqualsInRange(double[] d1, double[] d2, double range); static boolean arrayEquals(double[] d1, double[] d2); static double[] appendZeros(double[] darray, int zeroAmountToAppend); static double[] normalize16bitLittleEndian(byte[] bytez); static double[] normalize16bitLittleEndian(byte[] bytez, int amount); static byte[] denormalize16BitLittleEndian(double[] input); static int[] toUnsignedInteger(double[] input, int max); static double max(double... input); static double min(double... input); static void validateArray(double... input); static int maxIndex(double... input); static int minIndex(double... input); static double sum(double... input); static double[] sum(double[] a1, double[] a2); static void addToFirst(double[] first, double[] second); static void addToAll(double[] data, double valueToAdd); static void addToFirstScaled(double[] first, double[] second, double scale); static double[] square(double... input); static void squareInPlace(double... input); static double[] subtract(double[] a1, double[] a2); static void subtractFromFirst(double[] first, double[] second); static double[] multiply(double[] a1, double[] a2); static double dotProduct(double[] a1, double[] a2); static void multiplyToFirst(double[] first, double[] second); static double[] scale(double[] a1, double b); static void scaleInPlace(double[] a1, double b); static double mean(double... input); static double absoluteSumOfDifferences(double[] a, double[] b); static double[] absoluteDifference(double[] a, double[] b); static void validateArrays(double[] a1, double[] a2); static double squaredSum(double[] array); static double squaredSumOfDifferences(double[] a, double[] b); static double variance(double[] input); static double standardDeviation(double[] a); static boolean containsNaN(double[] a); static void floorInPlace(double[] var, double minValue); static void nonZeroFloorInPlace(double[] data, double floor); static void normalizeInPlace(double[] data); static void serialize(DataOutputStream dos, double[] data); static void serializeRaw(DataOutputStream dos, double[] data); static void serialize(DataOutputStream dos, double[][] data); static void serializeRaw(DataOutputStream dos, double[][] data); static double[] deserialize(DataInputStream dis); static double[] deserializeRaw(DataInputStream dis, int amount); static void deserializeRaw(DataInputStream dis, double[] result); static double[][] deserialize2d(DataInputStream dis); static void deserialize2DRaw(DataInputStream dis, double[][] result); static double[][] clone2D(double[][] result); static double[] fromString(String str, String delimiter); static String format(double... input); static String format(int fractionDigits, String delimiter, double... input); static String format(int rightPad, int fractionDigits, String delimiter, double... input); static double[] reduceFractionDigits(double[] arr, int digitCount); static float[] fromDelimitedString(String input, String delimiter); static final double[] ZERO_LENGTH_ARRAY; }