summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Groth <christoph.groth@cea.fr>2024-10-24 13:57:03 +0200
committerChristoph Groth <christoph.groth@cea.fr>2025-01-09 13:58:20 +0100
commit22a5aa82f4f2b14313238de770923d0ece8d906a (patch)
treeac1f0a4dbb15844903d28c42551e372eeb86d9cb
parent91882899908ed62ff37636d1670e8e46df48a9d4 (diff)
Switch inner loop to run over rows
-rw-r--r--src/main.rs7
1 files changed, 4 insertions, 3 deletions
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<f64, 2>, b: &DSlice<f64, 2>, c: &mut DSlice<f64, 2>) {
- 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);
}
}