QRFAC Procedure
Computes the QR factorization of a real matrix A.
Usage
QRFAC, a[, pivot[, auxqr, qr]]
Input Parameters
a—Two-dimensional matrix containing the coefficient matrix. Element A(i,j) contains the jth coefficient of the ith equation.
Input/Output Keywords
pivot—One-dimensional matrix containing the desired variable order and usage information.
*On input, if pivot (k) > 0, then column k of A is an initial column. If pivot (k) = 0, then the column of A is a free column and can be interchanged in the column pivoting. If pivot (k) < 0, then column k of A is a final column. If all columns are specified as initial (or final) columns, then no pivoting is performed. (The permutation matrix P is the identity matrix in this case.) Default: pivot (*) = 0
*On output, pivot (k) contains the index of the column of the original matrix that has been interchanged into column k.
Output Parameters
auxqr—Matrix containing the scalars τk of the Householder transformations that define the decomposition.
qr—Matrix containing the Householder transformations that define the decomposition.
Input Keywords
Double—If present and nonzero, double precision is used.
Tolerance—Nonnegative tolerance used to determine the subset of columns of A to be included in the solution. Default: Tolerance = SQRT(ε), where ε is machine precision
Output Keywords
Basis—Named variable into which an integer containing the number of columns used in the solution is stored. The value Basis = k,
if |rk,k| < Tolerance*|r0,0| and |ri,i| Tolerance*|r0,0| for i = 0, 1, ..., k – 1. For more information on the use of this option, see the Discussion section which follows.
AP—Specifies a named variable into which the product AP of the identity
AP = QR is stored. This keyword is useful when attempting to compute the residual AP – QR.
Q—Specifies a named variable in which the two-dimensional matrix containing the orthogonal matrix of the AP = QR factorization is stored.
R—Specifies a named variable in which the two-dimensional matrix containing the upper-triangular matrix of the AP = QR decomposition is stored.
Discussion
The QRFAC procedure computes a QR factorization of the matrix AP, where P is the permutation matrix defined by the pivoting and computes the smallest integer k satisfying |rk,k| < Tolerance*|r0,0| to the output keyword Basis.
Householder transformations:
Qk = IτkukukT, k = 0, ..., min(m – 1, n) – 1
compute the factorization. The decomposition is computed in the form Qmin (m – 1, n) – 1 ... Q0AP = R, so AP = QR where Q = Q0 ... Qmin (m – 1, n) – 1. Since each Householder vector uk has zeros in the first k + 1 entries, it is stored as part of column k of Qr. The upper-trapezoidal matrix R is stored in the upper-trapezoidal part of the first min(m, n) rows of Qr.
When computing the factorization, the procedure computes the QR factorization of AP with P defined by the input pivot and by column pivoting among “free” columns. Before the factorization, initial columns are moved to the beginning of the array A and the final columns to the end. Neither initial nor final columns are permuted further during the computation. Only the free columns are moved.
Example
Using the same data as the first example given for function QRSOL, the QR factorization of the coefficient matrix is computed. Using keywords, the factorization is returned in the full matrices, rather than the default condensed format.
; Define the coefficient matrix.
RM, a, 4, 3
row 0:  1 2 4
row 1:  1 4 16
row 2:  1 6 36
row 3:  1 8 64
; Call QRFAC using keywords Q, R, and AP.
QRFAC, a, pvt, Q = q, R = r, AP = ap
; Output the results.
PM, q, Title = 'Q', Format = '(4f12.6)'
; PV-WAVE prints the following:
; Q
; -0.500000    0.670820    0.500000    0.223607
; -0.500000    0.223607   -0.500000   -0.670820
; -0.500000   -0.223607   -0.500000    0.670820
; -0.500000   -0.670820    0.500000   -0.223607
PM, r, Title = 'R', Format = '(3f12.6)'
; PV-WAVE prints the following:
; R
; -2.000000  -10.000000  -60.000000
; 0.000000   -4.472136  -44.721359
; 0.000000    0.000000    8.000001
; 0.000000    0.000000    0.000000
PM, pvt, Title = 'Pvt'
; PV-WAVE prints the following:
; Pvt
; 1
; 2
; 3
PM, q # r - ap, Title = 'Residual', Format = '(3f12.6)'
; PV-WAVE prints the following:
; Residual
; 0.000000    0.000000    0.000002
; 0.000000    0.000000   -0.000002
; 0.000000    0.000000    0.000000
; 0.000000    0.000000    0.000000
Fatal Errors
MATH_SINGULAR_TRI_MATRIX—Input triangular matrix is singular. The index of the first zero diagonal term is #.