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:


It compiles & runs under both Ubuntu & Cygwin.

See also:

* * *

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


Cygwin is a collection of tools which provide a Linux look and feel environment for Windows.

It is also a DLL (cygwin1.dll) which acts as a Linux Application Programming Interface (API) layer providing substantial Linux API functionality.

Cygwin is not a way to run native Linux apps on Windows. You must rebuild your application from source if you want it to run on Windows.

Further information and installation instructions are given at:

* * *


The following command can be used to determine the version of Cygwin on your PC.

$ uname -a

Determine GNU Compiler Collection (GCC) version

$ gcc –version

The Cygwin file directory can be accessed by the following path or similar:


The directory contents can be displayed via:

$ ls -lt

* * *

XEmacs is text editor for Cygwin.  It may be downloaded from:

* * *

Blas & Lapack are available packages in Cygwin.

The library files are:   libblas.a & liblapack.a

Further informat on Cygwin packages is given at:

* * *

Tom Irvine