def vector_angle_cos(u, v):
u = np.asarray(u)<EOL>v = np.asarray(v)<EOL>return (u * v).sum(<NUM_LIT:0>) / np.sqrt((u ** <NUM_LIT:2>).sum(<NUM_LIT:0>) * (v ** <NUM_LIT:2>).sum(<NUM_LIT:0>))<EOL>
vector_angle_cos(u, v) yields the cosine of the angle between the two vectors u and v. If u
or v (or both) is a (d x n) matrix of n vectors, the result will be a length n vector of the
cosines.