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

Matrix division: X=A/B. where A has dimension of (m,n)

Tags: None
(comma "," separated)
wendingmai
Registered Member
Posts
16
Karma
0
Hi,

The question is X=A/B, while A(m,n),B(n,n),hoping X has(m,n) dimension.
Direct inverse proves to be unstable. However, Eigen's solvers like householderQr() etc. requires m=n.

In Matlab, I use X=A/B, it works great. I need suggestion how should I do in Eigen.

Thank you.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
In devel branch you can "solve on the right" as follows:

X = A * B.lu().inverse();

This won't compute the inverse explicitly, but appropriately apply the LU factors to A. You can also transpose the pb:

WhateverDecomposition<MatrixXd> dec(B.transpose());
X.transpose() = dec.solve(A.transpose());

where WhateverDecomposition is PartialPivLU, HouseolderQR, etc.
wendingmai
Registered Member
Posts
16
Karma
0
ggael wrote:In devel branch you can "solve on the right" as follows:

X = A * B.lu().inverse();

This won't compute the inverse explicitly, but appropriately apply the LU factors to A. You can also transpose the pb:

WhateverDecomposition<MatrixXd> dec(B.transpose());
X.transpose() = dec.solve(A.transpose());

where WhateverDecomposition is PartialPivLU, HouseolderQR, etc.


Thank you,ggael,

Prob. solved.


Bookmarks



Who is online

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