Confusion about matrix multiplication order (>2 matrices)

Hello,
I am performing some matrix multiplication and I am a bit confused about the results.
Specifically, I have a sparse matrix H 390x331 and a diagonal matrix R 390x390.
I want to calculate G = transpose(H)*inv(R)*H and I thought julia would by default perform the multiplications in the right order. However, I noticed that
transpose(H)*inv(R)*H is different from transpose(H)*(inv(R)*H). The difference is non-negligible I would say, and I am just wondering whether it is something numerical or whether I missed something about matrix multiplication in julia.

1 Like

An orthogonal comment: You typically shouldn’t use inv(R) but left or right-division, i.e. \ or /, instead. Constructing the full inverse is almost never what you want to do.

4 Likes