I need c++ code for inverse of nxn matrix ,if available please help me
c++ code for inverse of NXN matrix
Collapse
X
-
I do not know if it is exists for general case. For the 2X2 matrix there is the gsl library. If you have matlab you can call matlab to invert the matrix from your c++ code...Originally posted by drsunilI need c++ code for inverse of nxn matrix ,if available please help me -
Never invert a square matric explicitly: it is highly numerically unstable. A much
better method is to find two triangular matrixes L and U (lower and upper triangular
respectively where L has just ones (1) on its diagonal such that L.U == P.A
where P is a row permutation matrix, Given L, U and P it is extremely easy
to solve the linear system A.x == b.
P.A.x == P.b (swap the elements in b)
L.U.x == P.b
L.y == P.b (by using a simple backward substitution)
U.x == y (by using a simple forward substitution).
Calculate x for the unit vectors b and voila.
Google for "LUP decomposition" for the gory details.
kind regards,
JosComment
Comment