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,

Jos