Created
April 27, 2023 07:54
-
-
Save marmakoide/d582c15c4586eb4e9e845d27e514a98f to your computer and use it in GitHub Desktop.
Build an orthogonal projection that projects vectors on U's subspace
This file contains hidden or 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
import numpy | |
def get_orthogonal_projection(U): | |
M = numpy.random.randn(U.shape[1], U.shape[1]) | |
M[:U.shape[0]] = U | |
Q, R = numpy.linalg.qr(M.T) | |
M[U.shape[0]:] = Q.T[U.shape[0]:] | |
Q, R = numpy.linalg.qr(M.T) | |
return Q.T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment