@Test public void testL1Norm() throws Exception { Assert.assertEquals(0, ArrayMath.l1norm(new double[]{}), 0); Assert.assertEquals(0, ArrayMath.l1norm(new double[] {0}), 0); Assert.assertEquals(2, ArrayMath.l1norm(new double[] {1, -1}), 0); Assert.assertEquals(55, ArrayMath.l1norm(new double[] {1, -2, 3, -4, 5, -6, 7, -8, 9, -10}), 0); }
public static double l1norm(double[] v) { double norm = 0; for (int i = 0; i < v.length; i++) norm += StrictMath.abs(v[i]); return norm; }
ArrayMath { public static double l1norm(double[] v) { double norm = 0; for (int i = 0; i < v.length; i++) norm += StrictMath.abs(v[i]); return norm; } }
ArrayMath { public static double l1norm(double[] v) { double norm = 0; for (int i = 0; i < v.length; i++) norm += StrictMath.abs(v[i]); return norm; }  }
ArrayMath { public static double l1norm(double[] v) { double norm = 0; for (int i = 0; i < v.length; i++) norm += StrictMath.abs(v[i]); return norm; }  static double innerProduct(double[] vecA, double[] vecB); static double l1norm(double[] v); static double l2norm(double[] v); static double invL2norm(double[] v); static double logSumOfExps(double[] x); static double max(double[] x); static int argmax(double[] x); static void sumFeatures(Context[] context, float[] values, double[] prior); static double[] toDoubleArray(List<Double> list); static int[] toIntArray(List<Integer> list); }
ArrayMath { public static double l1norm(double[] v) { double norm = 0; for (int i = 0; i < v.length; i++) norm += StrictMath.abs(v[i]); return norm; }  static double innerProduct(double[] vecA, double[] vecB); static double l1norm(double[] v); static double l2norm(double[] v); static double invL2norm(double[] v); static double logSumOfExps(double[] x); static double max(double[] x); static int argmax(double[] x); static void sumFeatures(Context[] context, float[] values, double[] prior); static double[] toDoubleArray(List<Double> list); static int[] toIntArray(List<Integer> list);  }