public static double squaredDistance(int[] a, int[] b) {
        double d = 0.0;

        int p1 = 0, p2 = 0;
        while (p1 < a.length && p2 < b.length) {
            int i1 = a[p1];
            int i2 = b[p2];
            if (i1 == i2) {
                p1++;
                p2++;
            } else if (i1 > i2) {
                d++;
                p2++;
            } else {
                d++;
                p1++;
            }
        }

        d += a.length - p1;
        d += b.length - p2;

        return d;
    }
@Test
    public void testSquaredDistance_doubleArr_doubleArr() {
        System.out.println("squaredDistance");
        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(5.867547, MathEx.squaredDistance(x, y), 1E-6);
    }