From 22a5aa82f4f2b14313238de770923d0ece8d906a Mon Sep 17 00:00:00 2001 From: Christoph Groth Date: Thu, 24 Oct 2024 13:57:03 +0200 Subject: Switch inner loop to run over rows --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 31d810b..edd202d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,10 @@ use mdarray::{view, tensor, DSlice, Expression}; +// Indexing convention: C_ij <- A_ik * B_kj fn matmul(a: &DSlice, b: &DSlice, c: &mut DSlice) { - for (mut cj, bj) in c.cols_mut().zip(b.cols()) { - for (ak, bkj) in a.cols().zip(bj) { - for (cij, aik) in cj.expr_mut().zip(ak) { + for (mut ci, ai) in c.rows_mut().zip(a.rows()) { + for (aik, bk) in ai.zip(b.rows()) { + for (cij, bkj) in ci.expr_mut().zip(bk) { *cij = aik.mul_add(*bkj, *cij); } } -- cgit v1.2.3-74-g4815