


                                LU Decomposition
                                    Dr. D'nar
                                  13 March 2010



====== Basic Usage =============================================================
This program performs an LU Decomposition on a matrix.  Enter the matrix to
decompose into matrix [A] and then run the program.  The program will attempt to
find a decomposition.  If it works, the upper matrix U will be displayed, and
the matrices L and U can be found in Matrices [C] and [B], respectively.


====== Errors ==================================================================
The program will produce an error if there is a problem, such as:
 - The matrix is not square.  The program performs no explicit check for
   squareness, but may produce an error when it tries to access a nonexistent
   element from the source matrix.  Or it might produce no error.
 - The matrix contains a zero along its diagonal in an inopportune place during
   the decomposition process.  A key point here is that the program uses row
   operations to perform the decomposition, and that the row operations chosen
   can produce a zero where there was no zero previously, and that zeros along
   the diagonal may be made non-zero again by a row operation.  There is one
   place you certainly cannot have a zero: row 1, column 1.
If the program emits an error, check to make sure the matrix can be LU
decomposed.  You may be able to perform the LU decomposition with another tool
or by hand.  If the program produces an error, the matrices [C] and [B] may
still contain a partially completed decomposition. However, the program may have
produced the error in the process of modifying [C] and [B] and they may not
both be in the same step in the decomposition process; you need to multiply
[C][B] and make sure the decomposition is equal to [A].

The program also requires enough free RAM to produce two additional matrices the
same size as [A], which shouldn't be a problem if you don't do much with your
calculator.


====== Algorithm ===============================================================
This program uses a rather naive algorithm (i.e. that which I came up with in a
few spare minutes in class) for find a LU decomposition.  The algorithm is based
on the following idea: If you have a matrix in the form
	[a - - ...]
	[b c - ...]
	[d e f ...]
	[...   ...] (entries marked - are not important here)
you can use a series of row operations to produce zeros in the entries below the
diagonal.  To produce a zero in b, for example, using a row operation, you need
to solve the following equation:
	ax + b = 0
=	ax = -b
=	x = -b / a
Then, you multiply row 1 by x and add that to row 2 and you get a zero in b.
(If you have a zero in a, the algorithm fails.)  And, to get a zero in d,
	x = -d / a
So, in general, for each column c and row r in the matrix M, process each row, 
starting with row c+1, as follows:
	-Mrc/Mcc * Mc + Mr
where Mmn is row m column n of matrix M, and Mn is row n of matrix M.  This
produces the matrix U.  For the matrix L, start with L = I and then for each
operation performed on M,
	L = L * (Mrc/Mcc * Ic + Ir)
Note that instead of calculating the inverse of the elementary matrix, the
program negates the value -Mrc/Mcc to get the inverse without using the inverse
operator.
