Function extendr_api::prelude::mat::from_column_major_slice
pub fn from_column_major_slice<E>(
slice: <<E as Entity>::Group as ForType>::FaerOf<&[<E as Entity>::Unit]>,
nrows: usize,
ncols: usize,
) -> MatRef<'_, E>where
E: Entity,
Expand description
Creates a MatRef
from slice views over the matrix data, and the matrix dimensions.
The data is interpreted in a column-major format, so that the first chunk of nrows
values from the slices goes in the first column of the matrix, the second chunk of nrows
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 slice = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0_f64];
let view = mat::from_column_major_slice::<f64>(&slice, 3, 2);
let expected = mat![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
assert_eq!(expected, view);