def principal_angle(A,B):
from numpy.linalg import qr, svd<EOL>qA, _ = qr(A)<EOL>qB, _ = qr(B)<EOL>U,S,V = svd(qA.T.dot(qB))<EOL>return np.arccos(min(S.min(), <NUM_LIT:1.0>))<EOL>
Find the principal angle between two subspaces
spanned by columns of A and B