Function rerun::external::ndarray::aview_mut2
source · pub fn aview_mut2<A, const N: usize>(
xs: &mut [[A; N]]
) -> ArrayBase<ViewRepr<&mut A>, Dim<[usize; 2]>>
Expand description
Create a two-dimensional read-write 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 because slices cannot contain more than isize::MAX
number of bytes).
§Example
use ndarray::aview_mut2;
// The inner (nested) and outer arrays can be of any length.
let mut data = [[0.; 2]; 128];
{
// Make a 128 x 2 mut array view then turn it into 2 x 128
let mut a = aview_mut2(&mut data).reversed_axes();
// Make the first row ones and second row minus ones.
a.row_mut(0).fill(1.);
a.row_mut(1).fill(-1.);
}
// look at the start of the result
assert_eq!(&data[..3], [[1., -1.], [1., -1.], [1., -1.]]);