pub const fn aview2<A, const N: usize>(
xs: &[[A; N]]
) -> ArrayBase<ViewRepr<&A>, Dim<[usize; 2]>>
Expand description
Create a two-dimensional array view with elements borrowing xs
.
Panics if the product of non-zero axis lengths overflows isize
(This
can only occur if A is zero-sized or if N
is zero, because slices cannot
contain more than isize::MAX
number of bytes).
use ndarray::{aview2, ArrayView2};
let data = vec![[1., 2., 3.], [4., 5., 6.]];
let view = aview2(&data);
assert_eq!(view.sum(), 21.);
// Create a const 2D array view
const C: ArrayView2<'static, f64> = aview2(&[[1., 2., 3.], [4., 5., 6.]]);
assert_eq!(C.sum(), 21.);