summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 7 insertions, 6 deletions
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<DI: Dim, DK: Dim, DJ: Dim>(
fn main() {
let a = view![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
- let b = md::Array::<f64, (Const::<2>, Const::<2>)>::from_fn(
+ let b = md::Array::<f64, _>::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<f64> = 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<f64, 1> = (0..128).map(f64::from).collect::<Vec<_>>().into();
+ let d: md::DArray<f64, 1> = (0..128).map(f64::from).collect::<Vec<_>>().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::<f64>::uninit(); 3]; 3];
+ let mut e = darray![[MaybeUninit::<f64>::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);
}
}