0

The following code:

let m: SMatrix<f64, 2, 3> = SMatrix::from_iterator((1..).map(|x| x as f64));
println!("{:?}", m);

produces the following output:

[[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]

The matrix outputed has 3 rows, and each row has 2 columns. In the definition of the matrix however, I asked for 2 rows that each have 3 columns following the nalgebra documentation.

Expected output:

[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]

Did I misunderstand what the correct behaviour should be ? If not is this an issue from the nalgebra crate ?

rochard4u
  • 629
  • 3
  • 17
  • 2
    `SMatrix` equals to `Matrix, Const, ArrayStorage>` with one to one generic argument mapping, as you can see matrix data stored as [ArrayStorage](https://docs.rs/nalgebra/latest/nalgebra/base/struct.ArrayStorage.html) You can see it from the definition, outer array represent the columns, so there is no problem ^^ – Ömer Erden Sep 20 '22 at 13:28
  • Thank you. First time I see this convention so I was confused. – rochard4u Sep 20 '22 at 13:40

0 Answers0