c_qrdecomp - Calculate the QR decomposition of an n_row by n_col matrix.
SYNTAX
FUNCTION c_qrdecomp (matrix, n_row, n_col, work, flag)
double *matrix;
long n_row;
long n_col;
double *work;
long flag;
PARAMETERS
matrix (input/output, double)
The original matrix which is to have the QR decomposition applied. The
results of the QR decomposition are returned in this n_row by n_col array.
If flag is FALSE, matrix must be in column major form.
n_row (input, long)
The number of rows in the input matrix.
n_col (input, long)
The number of columns in the input matrix.
work (output, double)
The work vector. This one dimensional array must be dimensioned as large as
n_row. This will return a portion of the results of the QR
decomposition. These results should be passed into c_qrsolve().
flag (input, long)
A boolean flag. If this is TRUE, matrix will be reformatted to be in
column major form. If this is FALSE, no reformatting is done to matrix.
DESCRIPTION
This routine is used to perform a QR decomposition on a matrix. The work
vector is returned with values. Both the matrix and the work vector must
be passed into the c_qrsolve() routine after running c_qrdecomp(),
to find a least squares fit.
The QR least squares approximation process is described below.
Ax = b Given A and b, find x.
A = QR There exists Q and R such that Q is orthogonal
and R is an upper triangular matrix.
QT = INVERSE(Q) Q transpose is equivalent to Q inverse.
Rx = QTb At this point x is found using the facts
that (Q transpose)b is known and R is an upper
triangular matrix.
References:
1. "Matrix Computations (2nd ed.)", Gene H. Golub & Charles F. Van Loan,
John Hopkins University Press, Baltimore 1989 ISBN 0-8018-3739-1
RETURN VALUE
c_qrdecomp() has no return values.
SPECIAL CONSIDERATIONS:
The c_qrdecomp() call is for C only.