Numerical Methods Library in Excel VBA
Carries out an LU factorisation of a real matrix.
Description The spreadsheet contains the VBA source files for carrying out a LU factorisation of a real square
, so that
is a lower-triangular matrix (with diagonal elements set to 1) and
is an upper-triangular matrix and
is a permutation matrix. Interface Sub LUfac(a, n, perm, lfail) real a: on input the nxn matrix A, on output L and U integer n: the dimension of the matrix/vector integer perm: an n-vector, the column index of the permutation matrix P logical lfail: returns 'true' if the method fails, otherwise 'false'
Note the output matrix ‘a’ is such that th
e diagonal and upper-triangular
elements is the ‘U’ matrix and the lower
-triangular elements together
with 1s on the diagonal is the matrix ‘U’.
On exit ‘perm’ records the row exchanges that have occurred as a result
of pivoting, otherwise known as a permutation matrix P. It would be wasteful of computer memory to store the permutation matrix as an nxn array. P is taken to be made up of all zeros, except for P[j,i]=1 when perm(i)=j. Web source of code. http://www.numerical-methods.com/Excel_VBA/LU.xlsm
(key ‘Developer’ then ‘Visual Basic’ and then ‘LUfac_module’)