This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Product of triangular matrix and diagonal matrix

Tags: None
(comma "," separated)
KorbiS
Registered Member
Posts
4
Karma
0
Hi,

we implemented a UDU^T decomposition AddOn for MatrixBase with U as upper unit triangular matrix and D as diagonal matrix. The result is saved in the upper triangular part and the diagonal of the same matrix.

When I want to do the recomposition:

Code: Select all
Matrix<double,6,6> M_ud;
M_ud = M_ud.triangularView<UnitUpper>() * M_ud.diagonal().asDiagonal() * M_ud.triangularView<UnitUpper>().transpose();


I get a compiler error:
error: no match for ‘operator*’ ...

What I can do is:

Code: Select all
Matrix<double, 3, 3> M_ud;
Matrix<double, 3, 3> M2;
M2 = M_ud.diagonal().asDiagonal();

M_ud = M_ud.triangularView<UnitUpper>() * M2 * M_ud.triangularView<UnitUpper>().transpose();


But in this way I would loose the optimization I could get with the knowledge of M2 beeing diagonal (and I would have to create a temporal...).

Is there another way?

Cheers Korbi
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
it seems your decomposition is just a variant of the LDLT we have in the Cholesky mode but without pivoting.

To reconstruct the original matrix you can do:

M_ud = M_ud.triangularView<UnitUpper>();
M_ud = (M_ud * M_ud.diagonal().asDiagonal()) * M_ud.triangularView<UnitUpper>().transpose();

Yes that's not optimal but still better than converting the diagonal into a full matrix.
KorbiS
Registered Member
Posts
4
Karma
0
Thank you ggael for the idea. It's apparently the best solution without modifying eigen.

You are right, the UDU^T is just a modified Cholesky decomposition that is used for square root filters (without square roots :)

Would it make sense to add a mult operator to the triangular wrapper to multiply with diagonal matrices and one to diagonal matrices the other way around. Is this an already requested feature?

Cheers
Korbi


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]