@Test public void testL2Norm() throws Exception { Assert.assertEquals(0, ArrayMath.l2norm(new double[] {}), 0); Assert.assertEquals(0, ArrayMath.l2norm(new double[] {0}), 0); Assert.assertEquals(1.41421, ArrayMath.l2norm(new double[] {1, -1}), 0.001); Assert.assertEquals(0.54772, ArrayMath.l2norm(new double[] {0.1, -0.2, 0.3, -0.4}), 0.001); }
public static double l2norm(double[] v) { return StrictMath.sqrt(innerProduct(v, v)); }
ArrayMath { public static double l2norm(double[] v) { return StrictMath.sqrt(innerProduct(v, v)); } }
ArrayMath { public static double l2norm(double[] v) { return StrictMath.sqrt(innerProduct(v, v)); }  }
ArrayMath { public static double l2norm(double[] v) { return StrictMath.sqrt(innerProduct(v, v)); }  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 l2norm(double[] v) { return StrictMath.sqrt(innerProduct(v, v)); }  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);  }