class CosineDistance extends FastDistance {

    @Override
    public double calc(double[] array1, double[] array2) {
        double dot = BLAS.dot(array1, array2);
        double cross = Math.sqrt(BLAS.dot(array1, array1) * BLAS.dot(array2, array2));
        return 1.0 - (cross > 0.0 ? dot / cross : 0.0);
    }

}