Compute cosine similarity between two vectors.
Returns a value in [-1, 1]:
1.0
0.0
-1.0
Returns 0 for empty arrays, mismatched dimensions, or zero-magnitude vectors.
0
First vector.
Second vector (must have same length as a).
a
Cosine similarity in [-1, 1].
Compute cosine similarity between two vectors.
Returns a value in [-1, 1]:
1.0= identical direction0.0= orthogonal (no linear similarity)-1.0= opposite directionReturns
0for empty arrays, mismatched dimensions, or zero-magnitude vectors.