Skip to content

Commit b023165

Browse files
authored
Replace np.sum(a * b) with a @ b
1 parent f63761a commit b023165

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lectures/orth_proj.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def gram_schmidt(X):
790790
791791
# The first col of U is just the normalized first col of X
792792
v1 = X[:,0]
793-
U[:, 0] = v1 / np.sqrt(np.sum(v1 * v1))
793+
U[:, 0] = v1 / np.sqrt(v1 @ v1)
794794
795795
for i in range(1, k):
796796
# Set up
@@ -802,7 +802,7 @@ def gram_schmidt(X):
802802
u = M @ b
803803
804804
# Normalize
805-
U[:, i] = u / np.sqrt(np.sum(u * u))
805+
U[:, i] = u / np.sqrt(u @ u)
806806
807807
return U
808808
```

0 commit comments

Comments
 (0)