Search code examples
pythonnumpymatrixvector

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


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


Solution

  • 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.