Here is a Fortran program which performs matrix inversion using the LU decomposition method: INVERSE_MATRIX.F
It is compiled via:
gfortran -o INVERSE_MATRIX INVERSE_MATRIX.F -llapack
It compiles & runs under both Ubuntu & Cygwin.
See also: http://www.nag.com/numeric/fl/nagdoc_fl23/examples/source/f07ajfe.f90
* * *
The INVERSE_MATRIX.F program uses the subroutines: DGETRF & DGETRI
DGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
DGETRI computes the inverse of a matrix using the LU factorization computed by DGETRF.
This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A).
* * *
Here is a similar C++ program: matrix_inverse.cpp
It is compiled as:
gcc -o matrix_inverse matrix_inverse.cpp -llapack -lstdc++
* * *
See also: Python Matrix Inversion
* * *
Tom Irvine