@Test public void test6() { double[] v1 = new double[] { 10.233, 37.87, -30.806 }; double[] v2 = new double[] { 11.69, -24.556, 72.158 }; Asserts.assertEqualLength(v1, v2); double res = Angular.distance(v1, v2); Asserts.assertEquals(res, 2.479339066); }
public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); if(v1==v2){ return 0; } double res; res=CommonStats.dotProduct(v1, v2)/(CommonStats.norm(v1)*CommonStats.norm(v2)); Asserts.assertBetween1andMinus1(res); return Math.acos(res); }
Angular { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); if(v1==v2){ return 0; } double res; res=CommonStats.dotProduct(v1, v2)/(CommonStats.norm(v1)*CommonStats.norm(v2)); Asserts.assertBetween1andMinus1(res); return Math.acos(res); } }
Angular { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); if(v1==v2){ return 0; } double res; res=CommonStats.dotProduct(v1, v2)/(CommonStats.norm(v1)*CommonStats.norm(v2)); Asserts.assertBetween1andMinus1(res); return Math.acos(res); }  }
Angular { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); if(v1==v2){ return 0; } double res; res=CommonStats.dotProduct(v1, v2)/(CommonStats.norm(v1)*CommonStats.norm(v2)); Asserts.assertBetween1andMinus1(res); return Math.acos(res); }  static double distance(double[] v1,double[] v2); }
Angular { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); if(v1==v2){ return 0; } double res; res=CommonStats.dotProduct(v1, v2)/(CommonStats.norm(v1)*CommonStats.norm(v2)); Asserts.assertBetween1andMinus1(res); return Math.acos(res); }  static double distance(double[] v1,double[] v2);  }