@Test public void testCalDistanceVecMatrix(){ FastDistanceMatrixData matrixData = initMatrixData(); FastDistanceVectorData vectorData = distance.prepareVectorData(Row.of(0, sparseVector1), 1); double[] predict = distance.calc(matrixData, vectorData).getData(); double[] expect = new double[]{5.47, 8.38}; for(int i = 0; i < expect.length; i++){ Assert.assertEquals(expect[i], predict[i], 0.01); } predict = distance.calc(vectorData, matrixData).getData(); for(int i = 0; i < expect.length; i++){ Assert.assertEquals(expect[i], predict[i], 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);  }