private static double computeCosineSimilarity(
        DoubleTuple t0, DoubleTuple t1)
    {
        Utils.checkForEqualSize(t0, t1);
        double dot = DoubleTuples.dot(t0, t1);
        final double epsilon = 1e-10;
        if (Math.abs(dot) < epsilon)
        {
            return 0;
        }
        double tt0 = DoubleTuples.computeL2(t0);
        double tt1 = DoubleTuples.computeL2(t1);
        double tt = tt0 * tt1;
        double result = clamp(dot / tt, -1.0, 1.0);
        return result;
    }
private static double computeCosineSimilarity ( DoubleTuple t0 , DoubleTuple t1 ) { Utils . checkForEqualSize ( t0 , t1 ) ; double dot = DoubleTuples . dot ( t0 , t1 ) ; final double epsilon = 1e-10 ; if ( Math . abs ( dot ) < epsilon ) { return 0 ; } double tt0 = DoubleTuples . computeL2 ( t0 ) ; double tt1 = DoubleTuples . computeL2 ( t1 ) ; double tt = tt0 * tt1 ; double result = clamp ( dot / tt , - 1.0 , 1.0 ) ; return result ; }
Computes the cosine similarity between the given tuples

@param t0 The first tuple
@param t1 The second tuple
@return The cosine similarity
@throws IllegalArgumentException If the given tuples do not
have the same {@link Tuple#getSize() size}