Skip to content

Commit 02e5bb2

Browse files
suda-yugammcky
andauthored
Replace np.sum(a * b) with a @ b (#210)
Co-authored-by: Matt McKay <[email protected]>
1 parent f62b10a commit 02e5bb2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lectures/dyn_stack.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ We'll compute it two ways and get the same answer.
10431043
In addition to being a useful check on the accuracy of our coding, computing things in these two ways helps us think about the structure of the problem.
10441044
10451045
```{code-cell} python3
1046-
v_leader_forward = np.sum(βs * π_leader)
1046+
v_leader_forward = βs @ π_leader
10471047
v_leader_direct = -yt[:, 0].T @ P @ yt[:, 0]
10481048
10491049
# Display values
@@ -1380,8 +1380,8 @@ u2 = (- F2 @ z).flatten()
13801380
π_1 = p * q1 - γ * (u1) ** 2
13811381
π_2 = p * q2 - γ * (u2) ** 2
13821382
1383-
v1_forward = np.sum(βs * π_1)
1384-
v2_forward = np.sum(βs * π_2)
1383+
v1_forward = βs @ π_1
1384+
v2_forward = βs @ π_2
13851385
13861386
v1_direct = (- z[:, 0].T @ P1 @ z[:, 0])
13871387
v2_direct = (- z[:, 0].T @ P2 @ z[:, 0])

0 commit comments

Comments
 (0)