summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorChristoph Groth <christoph.groth@cea.fr>2025-03-06 11:40:22 +0100
committerChristoph Groth <christoph.groth@cea.fr>2025-03-06 11:40:22 +0100
commit5da8670c2715315a9b86a1e4168699e6f6d81693 (patch)
tree0ed361bb31027e549e175735eab05ed2b1eba563 /src/main.rs
parente7480f9232f6a09c5ffa94c29e0d4e875e1d93b4 (diff)
Use from_fn
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 796d0e4..e8f7740 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use mdarray::{view, array, tensor, Slice, Dim, Const, expr::Expression};
+use mdarray::{view, tensor, Slice, Dim, Const, expr::Expression};
use mdarray as md;
// Indexing convention: C_ij <- A_ik * B_kj
@@ -17,7 +17,9 @@ fn matmul<D0: Dim, D1: Dim, D2: Dim>(
fn main() {
let a = view![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
- let b = array![[0.0, 1.0], [1.0, 1.0]];
+ let b = md::Array::<f64, (Const::<2>, Const::<2>)>::from_fn(
+ |i| if i[0] == 0 && i[1] == 0 { 0.0 } else { 1.0 }
+ );
let b = b.reshape((Const::<2>, !0));
// .into_dyn() replaces .reshape(DynRank::from_dims(&[2, 3])).into():