You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lectures/linear_algebra.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,15 +246,25 @@ Continuing on from the previous example, the inner product and norm can be compu
246
246
follows
247
247
248
248
```{code-cell} python3
249
-
np.sum(x * y) # Inner product of x and y
249
+
np.sum(x * y) # Inner product of x and y, method 1
250
250
```
251
251
252
+
```{code-cell} python3
253
+
x @ y # Inner product of x and y, method 2 (preferred)
254
+
```
255
+
256
+
The `@` operator is preferred because it uses optimized BLAS libraries that implement fused multiply-add operations, providing better performance and numerical accuracy compared to the separate multiply and sum operations.
0 commit comments