@Test public void testDistance() { System.out.println("distance"); int[] x = {3, 3, 4, 0}; int[] y = {2, 5, 4, 3}; LeeDistance instance = new LeeDistance(6); assertEquals(6.0, instance.d(x, y), 1E-9); }
@Override public 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)); } int dist = 0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); dist += Math.min(d, q-d); } return dist; }
LeeDistance implements Metric<int[]> { @Override public 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)); } int dist = 0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); dist += Math.min(d, q-d); } return dist; } }
LeeDistance implements Metric<int[]> { @Override public 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)); } int dist = 0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); dist += Math.min(d, q-d); } return dist; } LeeDistance(int q); }
LeeDistance implements Metric<int[]> { @Override public 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)); } int dist = 0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); dist += Math.min(d, q-d); } return dist; } LeeDistance(int q); @Override String toString(); @Override double d(int[] x, int[] y); }
LeeDistance implements Metric<int[]> { @Override public 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)); } int dist = 0; for (int i = 0; i < x.length; i++) { double d = Math.abs(x[i] - y[i]); dist += Math.min(d, q-d); } return dist; } LeeDistance(int q); @Override String toString(); @Override double d(int[] x, int[] y);  }