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
#!/usr/bin/env python | |
import numpy as np | |
import numpy.linalg as la | |
def orthogonalize(U, eps=1e-15): | |
""" | |
Orthogonalizes the matrix U (d x n) using Gram-Schmidt Orthogonalization. | |
If the columns of U are linearly dependent with rank(U) = r, the last n-r columns | |
will be 0. | |