1 | initial version |
The method to use ndarray::stack to construct a matrix from an iterator that contains column vectors is:
Here's an example code snippet that constructs a 3x2 matrix by stacking three 3x1 column vectors vertically:
use ndarray::stack;
let col_vecs = vec![array![1, 2, 3], array![4, 5, 6], array![7, 8, 9]];
let stacked_matrix = stack(Axis(0), &col_vecs).unwrap();
assert_eq!(stacked_matrix, array![[1, 4, 7], [2, 5, 8], [3, 6, 9]]);
In this example, the Axis(0) argument specifies that the column vectors should be stacked vertically. The &col_vecs argument is a reference to the iterator of column vectors that we want to stack. The resulting stacked matrix is a 3x2 array.