@Test public void testCalDistanceVecVec(){ DenseMatrix denseResult = distance.calc(distance.prepareVectorData(Tuple2.of(denseVector1, null)), (FastDistanceData)distance.prepareVectorData(Tuple2.of( denseVector2, null))); Assert.assertEquals(denseResult.get(0, 0), 6.0, 0.01); DenseMatrix sparseResult = distance.calc(distance.prepareVectorData(Tuple2.of(sparseVector1, null)), (FastDistanceData)distance.prepareVectorData(Tuple2.of( sparseVector2, null))); Assert.assertEquals(sparseResult.get(0, 0), 0.5, 0.01); }
@Override public double calc(double[] array1, double[] array2) { double s = 0.; for (int i = 0; i < array1.length; i++) { double d = array1[i] - array2[i]; s += d * d; } return Math.sqrt(s); }
EuclideanDistance extends FastDistance { @Override public double calc(double[] array1, double[] array2) { double s = 0.; for (int i = 0; i < array1.length; i++) { double d = array1[i] - array2[i]; s += d * d; } return Math.sqrt(s); } }
EuclideanDistance extends FastDistance { @Override public double calc(double[] array1, double[] array2) { double s = 0.; for (int i = 0; i < array1.length; i++) { double d = array1[i] - array2[i]; s += d * d; } return Math.sqrt(s); }  }
EuclideanDistance extends FastDistance { @Override public double calc(double[] array1, double[] array2) { double s = 0.; for (int i = 0; i < array1.length; i++) { double d = array1[i] - array2[i]; s += d * d; } return Math.sqrt(s); }  @Override double calc(double[] array1, double[] array2); @Override double calc(Vector vec1, Vector vec2); @Override void updateLabel(FastDistanceData data); }
EuclideanDistance extends FastDistance { @Override public double calc(double[] array1, double[] array2) { double s = 0.; for (int i = 0; i < array1.length; i++) { double d = array1[i] - array2[i]; s += d * d; } return Math.sqrt(s); }  @Override double calc(double[] array1, double[] array2); @Override double calc(Vector vec1, Vector vec2); @Override void updateLabel(FastDistanceData data);  }