From 7b13a377a6db6365f76afa6e8560a39733cf542d Mon Sep 17 00:00:00 2001 From: Christoph Groth Date: Mon, 9 Feb 2026 12:03:27 +0100 Subject: Catch up with upstream (merge of Array and Tensor) --- Cargo.toml | 2 +- src/main.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 28c60c7..5dca1af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2024" [dependencies] -mdarray = "0.7.2" +mdarray = "0.8.0" diff --git a/src/main.rs b/src/main.rs index ed21626..20d0275 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::mem::MaybeUninit; -use mdarray::{view, tensor, Slice, Dim, Const, expr::{self, Expression}}; +use mdarray::{view, darray, Slice, Dim, Const, expr::{self, Expression}}; use mdarray as md; // Indexing convention: C_ij <- A_ik * B_kj @@ -20,13 +20,14 @@ fn matmul( fn main() { let a = view![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]]; - let b = md::Array::, Const::<2>)>::from_fn( + let b = md::Array::::from_fn( + (Const::<2>, Const::<2>), |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(): - let mut c: mdarray::Tensor = tensor![[0.0; 2]; 3].into_dyn(); + let mut c = darray![[0.0; 2]; 3].into_dyn(); matmul(&a.reshape((3, Const::<2>)), &b, &mut c.remap_mut()); @@ -42,13 +43,13 @@ fn main() { assert_eq!(c.permute([1, 0]), c.transpose()); // Arrays with rank > 6: - let d: md::DTensor = (0..128).map(f64::from).collect::>().into(); + let d: md::DArray = (0..128).map(f64::from).collect::>().into(); let d = d.into_dyn(); let d = d.reshape(&[2; 7]); let d = d.permute(&[6, 5, 4, 3, 2, 1, 0]); // Working with uninitialized memory. - let mut e = tensor![[MaybeUninit::::uninit(); 3]; 3]; + let mut e = darray![[MaybeUninit::::uninit(); 3]; 3]; for (i, val) in e.iter_mut().enumerate() { val.write(i as f64); } @@ -69,7 +70,7 @@ fn main() { dbg!(&i); } - for i in expr::zip(tensor![0, 1, 2], tensor![3, 4, 5]) { + for i in expr::zip(darray![0, 1, 2], darray![3, 4, 5]) { dbg!(&i); } } -- cgit v1.2.3-74-g4815