Never explicitly calculate the inverse of a matrix; it's numerically unstable. Use
a LUP decomposition instead: let L and U be lower and upper triangular matrixes
and let P be a row permutation matrix such that LU = PA. A permutation matrix
has exactly one 1 per row and column (all the other elements are zero).
Finding matrixes L and U is just a repeated Gauss row operation and P takes
care that the largest absolute pivot element is used.
For a linear system Ax= b:
PAx= Pb (permute the elements of vector b) -->
(Pb= b') LUx= b' -->
Ly = b' (find y by backward substitution) -->
Ux = y (find x by forward substitution).
Google is your friend:
LUP decomposition.
kind regards,
Jos