@Test public void testInnerProduct() throws Exception { Assert.assertEquals(0, ArrayMath.innerProduct(new double[] {}, new double[] {}), 0); Assert.assertEquals(-1, ArrayMath.innerProduct(new double[] {1}, new double[] {-1}), 0); Assert.assertEquals(14, ArrayMath.innerProduct(new double[] {1, 2, 3}, new double[] {1, 2, 3}), 0); }
public static double innerProduct(double[] vecA, double[] vecB) { if (vecA == null || vecB == null || vecA.length != vecB.length) return Double.NaN; double product = 0.0; for (int i = 0; i < vecA.length; i++) { product += vecA[i] * vecB[i]; } return product; }
ArrayMath { public static double innerProduct(double[] vecA, double[] vecB) { if (vecA == null || vecB == null || vecA.length != vecB.length) return Double.NaN; double product = 0.0; for (int i = 0; i < vecA.length; i++) { product += vecA[i] * vecB[i]; } return product; } }
ArrayMath { public static double innerProduct(double[] vecA, double[] vecB) { if (vecA == null || vecB == null || vecA.length != vecB.length) return Double.NaN; double product = 0.0; for (int i = 0; i < vecA.length; i++) { product += vecA[i] * vecB[i]; } return product; }  }
ArrayMath { public static double innerProduct(double[] vecA, double[] vecB) { if (vecA == null || vecB == null || vecA.length != vecB.length) return Double.NaN; double product = 0.0; for (int i = 0; i < vecA.length; i++) { product += vecA[i] * vecB[i]; } return product; }  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 innerProduct(double[] vecA, double[] vecB) { if (vecA == null || vecB == null || vecA.length != vecB.length) return Double.NaN; double product = 0.0; for (int i = 0; i < vecA.length; i++) { product += vecA[i] * vecB[i]; } return product; }  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);  }