Home · Pages · Index · Overviews

LU_Factor Class Reference

An LU decomposition of a matrix: inversion, determinants, linear equations. More...

 #include <linear.algebra.h>

Visible Fields

lu_mat : Double_Matrix *
perm : int *
sign : int
LU decomposion: L is below the diagonal and U is on and above it
Permutation of the original rows of m due to pivoting
Sign to apply to the determinant due to pivoting (+1 or -1)

Routines

LU_Factor * LU_DecomposeG (Double_Matrix *m S, boolean *stable O)
Double_Vector * LU_Solve (Double_Vector *b RM, LU_Factor *f)
double LU_Determinant (LU_Factor *f)
Double_Matrix * LU_Invert (LU_Factor *f, boolean transpose)
void Show_LU_Factor (FILE *file, LU_Factor *f)

Detailed Description

An LU Factor object realizes an LU decomposition (Press, Vetterling, Teukolsky and Flannery, Numerical Recipes in C (Cambridge University Press, 1992), Chapter 2.3) of a square matrix m and such an object is generated by calling LU_Decompose. Given an LU decomposition one can then solve the system of equations mx = b for any b with LU_Solve, one can obtain the determinant of m with a call to LU_Determinant, and one can generate the right-inverse m-1 by calling LU_Invert. Finally for debug purposes it is possible to produce a print out of the decomposition, for small matrices, with Show_LU_Factor.


Visible Fields Documentation

lu_mat: Double_Matrix *
perm: int *
sign: int

The fields of an LU decomposition of a matrix are made available for those that may wish to use them directly. The field lu_mat is a square matrix where the triangular L-matrix is in the lower triangular portion not including the diagonal, and the triangular U-matrix is in the upper triangular portion including the diagonal. The method involves pivoting: perm gives the permutation of the original order of rows in the matrix. Finally, sign is +1 or -1 according to whether the number of pivots is odd or even (each pivot changes the sign of the determinant).


Routine Documentation

LU_Factor * LU_DecomposeG (Double_Matrix *m S, boolean *stable O)

Given a double-valued square matrix m, LU_Decompose builds an LU_Factor object that models the LU decomposition of m. The matrix m is itself reused to hold the LU decomposition and subsumed by the newly generated LU_Factor object (as its lu_mat field). If the matrix is singular then the return value is NULL. If the matrix appears unstable, in that the algorithm uses a very nearly zero pivot, then the boolean pointed at by stable will be set to false, otherwise it is set to true.

Double_Vector * LU_Solve (Double_Vector *b RM, LU_Factor *f)

Given a right hand side double-valued vector b, solve the system of equations mx = b and return the result in b. The matrix m is the original matrix represented by the LU_Factor object f.

double LU_Determinant (LU_Factor *f)

Returns the determinant of the matrix represented by f.

Double_Matrix * LU_Invert (LU_Factor *f, boolean transpose)

Generate a square matrix that is the right inverse of the matrix m represented by f. That is, the matrix m-1 such that m · m-1 = I where I is the identity matrix. If transpose is true than the transpose of the inverse, or equivalently the left inverse of m is produced. If you simply need the columns of the inverse one at a time, note that you can instead call LU_Solve with b = [ 0k-1 1 0n-k] to get the kth column of the right inverse.

void Show_LU_Factor (FILE *file, LU_Factor *f)

Prints a textual representation of the LU decomposition of f for debug purposes. Only useful on small arrays.