Created
January 5, 2016 16:01
-
-
Save fish830617/ae6b124a717cf7553dfe to your computer and use it in GitHub Desktop.
Calculate the null space of a matrix by QR factorization.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# null.py | |
import numpy as np | |
from scipy.linalg import qr | |
def qr_null(A, tol=None): | |
Q, R, P = qr(A.T, mode='full', pivoting=True) | |
tol = np.max(A) * np.finfo(R.dtype).eps if tol is None else tol | |
rnk = min(A.shape) - np.abs(np.diag(R))[::-1].searchsorted(tol) | |
return Q[:, rnk:].conj() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment