From ee1f88f45ec8f15fab9cae3dae97984eaadce67e Mon Sep 17 00:00:00 2001 From: suda-yuga Date: Wed, 25 Jun 2025 21:08:15 +0900 Subject: [PATCH 1/2] Replace np.sum(a * b) with np.vdot(a, b) --- lectures/opt_transport.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/opt_transport.md b/lectures/opt_transport.md index e6d1ab348..30dc9ae5c 100644 --- a/lectures/opt_transport.md +++ b/lectures/opt_transport.md @@ -681,7 +681,7 @@ X Sure enough, we have the same solution and the same cost ```{code-cell} ipython3 -total_cost = np.sum(X * C) +total_cost = np.vdot(X, C) total_cost ``` From 1f661bfe1a8499e9954bc5737e03a1caa07c3af8 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 21 Jul 2025 15:10:59 +1000 Subject: [PATCH 2/2] add @oyamad suggestion to mention the use of vdot --- lectures/opt_transport.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lectures/opt_transport.md b/lectures/opt_transport.md index 30dc9ae5c..a97955718 100644 --- a/lectures/opt_transport.md +++ b/lectures/opt_transport.md @@ -685,6 +685,8 @@ total_cost = np.vdot(X, C) total_cost ``` +Here we use [np.vdot](https://numpy.org/doc/stable/reference/generated/numpy.vdot.html) for the trace inner product of X and C + ### A Larger Application Now let's try using the same package on a slightly larger application.