@Test public void testDistance() { System.out.println("distance"); double[] x = {-2.1968219, -0.9559913, -0.0431738, 1.0567679, 0.3853515}; double[] y = {-1.7781325, -0.6659839, 0.9526148, -0.9460919, -0.3925300}; assertEquals(2.00286, new ChebyshevDistance().d(x, y), 1E-5); }
public static double d(int[] x, int[] y) { if (x.length != y.length) { throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); } double dist = 0.0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); if (dist < d) dist = d; } return dist; }
ChebyshevDistance implements Metric<double[]> { public static double d(int[] x, int[] y) { if (x.length != y.length) { throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); } double dist = 0.0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); if (dist < d) dist = d; } return dist; } }
ChebyshevDistance implements Metric<double[]> { public static double d(int[] x, int[] y) { if (x.length != y.length) { throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); } double dist = 0.0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); if (dist < d) dist = d; } return dist; } ChebyshevDistance(); }
ChebyshevDistance implements Metric<double[]> { public static double d(int[] x, int[] y) { if (x.length != y.length) { throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); } double dist = 0.0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); if (dist < d) dist = d; } return dist; } ChebyshevDistance(); @Override String toString(); static double d(int[] x, int[] y); static double d(float[] x, float[] y); @Override double d(double[] x, double[] y); }
ChebyshevDistance implements Metric<double[]> { public static double d(int[] x, int[] y) { if (x.length != y.length) { throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); } double dist = 0.0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); if (dist < d) dist = d; } return dist; } ChebyshevDistance(); @Override String toString(); static double d(int[] x, int[] y); static double d(float[] x, float[] y); @Override double d(double[] x, double[] y);  }