pub fn matrix_init<F, T, const L: usize, const H: usize>(
initializer: F,
) -> [[T; L]; H]
Expand description
Initialize a matrix given an initializer expression. The initializer is given the row- and collumn-indices of the cell. It is allowed to mutate external state; we will always initialize the cells in order.
ยงExamples
let a: [[f64; 3]; 3] = matrix_init(|r, c| (r * c) as f64);
assert!(arr.iter().enumerate().all(|(r, ar)| ar.iter().enumerate().all(|(c, &arc)| arc == (r * c) as f64)));