class Gaussian {

    public double mahalanobis(double[] query) {
        double[] delta = new double[k];

        for (int i = 0; i < k; i++) {
            delta[i] = query[i] - mean[i];
        }

        double diagSum = 0, nonDiagSum = 0;

        for (int d1 = 0; d1 < k; ++d1) {
            for (int d2 = d1; d2 < k; ++d2) {
                double v = delta[d1] * delta[d2] * inverseCov[d1][d2];
                if (d1 == d2) {
                    diagSum += v;
                } else {
                    nonDiagSum += v;
                }
            }
        }

        return diagSum + 2 * nonDiagSum;
    }

    public  Gaussian();
    public  Gaussian(double[] mean, RealMatrix cov);

}