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

Cygwin

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:

http://cygwin.org/

* * *

Tips:

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:

c:\cygwin\home\(yourname)

The directory contents can be displayed via:

$ ls -lt

* * *

XEmacs is text editor for Cygwin.  It may be downloaded from:  http://www.xemacs.org/

* * *

Blas & Lapack are available packages in Cygwin.

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

Further informat on Cygwin packages is given at:  http://cygwin.com/packages/

* * *

Tom Irvine