inverse of a matrix

May 3, 2010 at 6:23am
how should i write a prog to get an inverse of a matrix
it comes in what area of c++
May 3, 2010 at 6:50am
Hi rahulmm,

there are several ways of doing this. But the first question is, what kind of representation you have?

One way of doing this is to use the gaussian elimination on the matrix. That way you got an complexity with O(n^3) in a fairly easy way.

If you already have a way to calculate the determinant of a matrix (which you proberbly could use to test if a matrix even is invertible; Not all are! But gaussian does the test too..) you can use the equation

A^-1 = det(A)^-1 * adj(A)
May 3, 2010 at 11:15am
Then you may check validity and compare performance with LAPACK library. Matrix inverse goes by two steps there:
1. LU factorization - GETRF
2. Inverse of LU-factorized matrix - GETRI

Of course, whether inverse is correct might be checked on a small matrix "by hands".
May 19, 2010 at 11:21pm
Hi!

here is a link where the invertion algorithm is well explained:

http://www.wikihow.com/Inverse-a-3X3-Matrix

Hope it help,

May 20, 2010 at 11:46am
IIRC the inverse of a matrix is an unstable operation with many caveats when implementing it. I'm guessing that if you need the inverse you might also need more matrix operations and thats why i'd advise you to use a library. If on the other hand the sole purpose is to practice creating this operation then follow the links above.
May 20, 2010 at 11:51am
To RedX ..
what is the name of the library that can be used in our program for matrix operation ?
May 20, 2010 at 12:00pm
I'm not very familiar with matrix libraries but lapak http://www.netlib.org/lapack/ supports some matrices.

Then there's http://sourceforge.net/apps/wordpress/itpp/ but not sure how well it handles matrices but it certainly has support for them. It also uses syntax very similar to MATLAB when creating and manipulating data.
Topic archived. No new replies allowed.