Function from_row_major_slice_mut
pub fn from_row_major_slice_mut<E>(
slice: &mut [E],
nrows: usize,
ncols: usize,
) -> MatMut<'_, E>where
E: SimpleEntity,
Expand description
Creates a MatMut
from slice views over the matrix data, and the matrix dimensions.
The data is interpreted in a row-major format, so that the first chunk of ncols
values from the slices goes in the first column of the matrix, the second chunk of ncols
values goes in the second column, and so on.
§Panics
The function panics if any of the following conditions are violated:
nrows * ncols == slice.len()
§Example
use faer::mat;
let mut slice = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0_f64];
let view = mat::from_row_major_slice_mut::<f64>(&mut slice, 3, 2);
let expected = mat![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
assert_eq!(expected, view);