np.linalg.qr(A) or scipy.linalg.orth(A) for finding the orthogonal basis (python)

Viewed 4945

If I have a vector space spanned by five vectors v1....v5, to find the orthogonal basis for A where A=[v1,v2...v5] and A is 5Xn

should I use np.linalg.qr(A) or scipy.linalg.orth(A)??

Thanks in advance

2 Answers

Note that sp.linalg.orth uses the SVD while np.linalg.qr uses a QR factorization. Both factorizations are obtained via wrappers for LAPACK functions.

I don't think there is a strong preference for one over the other. The SVD will be slightly more stable but also a bit slower to compute. In practice I don't think you will really see much of a difference.

You'll want to use:

scipy.linalg.orth(A)

The generally accepted rule is to use scipy.linalg - because it covers more functionality than np.linalg. Hope that helps!

Related