LUDCMP Procedure

Replaces a real n-by-n matrix, a, with the LU decomposition of a row-wise permutation of itself. For complex matrices, see the PV‑WAVE IMSL Mathematics Reference procedure LUFAC.

Usage

    LUDCMP, a, index, d

Input Parameters

a—An n-by-n matrix.

Output Parameters

a—On output, a is replaced by the LU decomposition of a row-wise permutation of itself.

index—Vector which records the row permutation effected by the partial pivoting. The values returned for index are needed in the call to LUBKSB.

d—An indicator of the number of row interchanges:

  • +1— Indicates the number was even.

  • –1— Indicates the number was odd.

Keywords

None.

Discussion

When you apply LUDCMP to a complex matrix, it only executes LU decomposition on the real part of the matrix.

Example

The preferred method of solving the linear set of equations Bq = r is:

b = [[1.0, -1.0, 3.0], [2.0, 1.0, 3.0], [3.0, 3.0, 1.0]]
r = [3.0, 0.0, 6.0]
PM, Title='Matrix b', b
PM, Title='Vector r', r
PM, 'Make copies of b and r since they will get overwritten;'
a = b
q = r
PM, 'Find the LU factors of b;'
LUDCMP, a, i, d
PM, 'Use the LU factors to solve the system b#x=r;'
LUBKSB, a, i, q
PM, Title='Solution vector', q
PM, Title='Verify the solution by printing b#q', b#q

See Also

LUBKSB,  MPROVE

LUDCMP is based on the routine of the same name in Numerical Recipes in C: The Art of Scientific Computing, by Flannery, Press, Teukolsky, and Vetterling, Cambridge University Press, Cambridge, MA, 1988. It is used by permission.