Python Solve a System of Linear Equations


The script on this page requires the utility module

* * *

Python Script

The following script solves a system of equations of the form Ax=b

The key lines are

from scipy import linalg

x = linalg.solve(A, b)

* * *


A Fortran program for this problem is: SLE.F

The program is compiled via

gfortran -o SLE SLE.F -llapack

It uses the Lapack subroutine DGESV.

* * *

Tom Irvine

Python Matrix Inversion


The scripts on this page require the utility module

* * *

Python Scripts

A script for calculating the inverse of a square matrix is given at:

The script uses the function: from numpy import linalg

Here is a script which calculates the pseudo inverse of a singular matrix:

* * *

Fortran Program

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 -lblas

The program uses the subroutines: DGETRF & DGETRI

It compiles & runs under both Ubuntu & Cygwin.

* * *

See also:

Tom Irvine