Skip to content

Instantly share code, notes, and snippets.

@oisincar
Last active September 24, 2020 01:15
Show Gist options
  • Save oisincar/f25fdc738efbd67af5204e10c3016ae7 to your computer and use it in GitHub Desktop.
Save oisincar/f25fdc738efbd67af5204e10c3016ae7 to your computer and use it in GitHub Desktop.
import numpy as np
# A simple, no-frills gram schmidt implementation
def gram_schmidt(A):
for k in range(0, A.shape[1]):
# Normalize
A[:, k] /= np.linalg.norm(A[:, k])
# Subtract from vecs below
for j in range(k+1, A.shape[1]):
r = np.dot(A[:, k], A[:, j])
A[:, j] -= r*A[:, k]
return A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment