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

Using LU Decomposition to find inverse

Tags: None
(comma "," separated)
PsiPhiDan
Registered Member
Posts
1
Karma
0
Hi Everyone,

I'm building an algorithm that requires an inverse to be taken of an nxn matrix, where n could range from 2 to 200 (roughly). I am very new to Eigen, so when I first did this I just took my matrix (let's call it [A]), and did L = A.inverse(); to find the inverse and store it as [L]. That inverse command, from what I'm reading on the tutorial, is best reserved for small matrices (like 2x2, 3x3, 4x4). I'd like to try and use the LU decomposition to find the inverse instead, but I simply cannot understand how to do that after reading all the tutorials and things. What sort of commands would I need to type in to get the LU decomposition and then USE that to find the inverse? Thanks so much, and I apologize if this is a dumb question. I've scoured the internet and found no help, so this is my last attempt to figure this out!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
It is already using LU internally, but computing explicitly the inverse is rarely recommended for two reasons:
- it is expensive t compute
- you might end up with numerical issues unless the matrix is very well conditioned.
In most cases, the inverse is applied to some vectors, like: "A^-1 * v" and in such cases it is much better to factorize A once, and then apply the inverse in factored form:

PartialPivLU<MatrixXd> lu(A);
lu.solve(v)


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]