@Override
    public double d(double[] x, double[] y) {
        if (x.length != sigma.nrow()) {
            throw new IllegalArgumentException(String.format("Array x[%d] has different dimension with Sigma[%d][%d].", x.length, sigma.nrow(), sigma.ncol()));
        }

        if (y.length != sigma.nrow()) {
            throw new IllegalArgumentException(String.format("Array y[%d] has different dimension with Sigma[%d][%d].", y.length, sigma.nrow(), sigma.ncol()));
        }

        int n = x.length;
        double[] z = new double[n];
        for (int i = 0; i < n; i++)
            z[i] = x[i] - y[i];

        double dist = sigmaInv.xAx(z);
        return Math.sqrt(dist);
    }
@Test
    public void testDistance() {
        System.out.println("distance");
        double[] x = {1.2793, -0.1029, -1.5852};
        double[] y = {-0.2676, -0.1717, -1.8695};

        MahalanobisDistance instance = new MahalanobisDistance(sigma);
        assertEquals(2.703861, instance.d(x, y), 1E-6);
    }