from_arrayd/
from_arrayd.rs1use matten_ndarray::from_arrayd;
8use ndarray::{ArrayD, IxDyn};
9
10fn main() {
11 let arr = ArrayD::from_shape_vec(IxDyn(&[2, 3]), vec![1., 2., 3., 4., 5., 6.]).unwrap();
12
13 let t = from_arrayd(arr.clone()).expect("contiguous converts");
14 println!(
15 "from contiguous: shape {:?} data {:?}",
16 t.shape(),
17 t.as_slice()
18 );
19
20 let tt = from_arrayd(arr.t().to_owned()).expect("transposed converts");
22 println!(
23 "from transposed: shape {:?} data {:?}",
24 tt.shape(),
25 tt.as_slice()
26 );
27 assert_eq!(tt.shape(), &[3, 2]);
28 assert_eq!(tt.as_slice(), &[1.0, 4.0, 2.0, 5.0, 3.0, 6.0]);
29 println!("ok");
30}