Closed seanxnie closed 1 month ago
Hi! The matrix multiplication result is correct.
Note that nalgebra stores matrices in column-major format, so the result printed as a flat array might look transposed to you if you are used to row-major storage. I recommend printing the matrices with {}
instead of {:?}
to get a 2D view of the matrix array.
Thank you very much for the reply. As a newbie, I didn't notice that nalgebra
's matrix is column-major based. If possible, please put more emphasis on the column-major underlying data in the documentation since it's a bit contradictory to commonsense. I appreciate that.
@seanxnie: you're completely right, this is very confusing, and we need to address it. The way to resolve this is for our Debug
implementation to use the same syntax as the matrix!
family of macros, namely to use semi-colons to delimit rows. For example:
[ 1, 2, 3;
4, 5, 6 ]
This way, it's unambiguous what the output means, and you can copy the output directly into a matrix!
(or dmatrix!
) invocation.
There's been work in #1119 to try to make Debug
and Display
output more consistent across many nalgebra
types, but unfortunately the work stalled and nobody's been able to pick it up.
Hi, there I tried matrix multiplications with
DMatrix
and produced the wrong result. Here is a simple code for testing.The output:
The result of T was supposed to be
[1.0 2.0 0.0 2.0]
. However, if we swap matrixA
andP
in this operation, ie,T = P*A
, the result is correct. Therefore, I suspect the implementation of matrix multiplication is reversed. If this the case, kindly request to correct this issue. Thanks.