Matrix Inversion in LAPACK

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

2 thoughts on “Matrix Inversion in LAPACK

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s