Next: quitting Up: MacAnova Help File Previous: putascii()   Contents

qr()

Usage:
qr(x [,pivot:T, ronly:T]), x a REAL matrix



Keywords: matrix algebra
qr(x) computes the elements of a QR decomposition of matrix x

The value returned is structure(qr:Qr, qraux:Qraux), where Qr is a REAL
vector of length P and Qraux is a REAL n by p matrix, as computed by
Linpack subroutine dqrdc.  The elements of Qr on and above the diagonal
constitute the upper triangular matrix R of the QR decomposition, and
the remaining elements, together with the elements of Qraux contain
enough information to compute Q.  No pivoting is performed with this
usage of qr().

qr(x,pivot:T) or simply qr(x,T) does the same computation, with possible
reordering of columns.  The result is a structure(qr:Qr,qraux:Qraux,
pivot:Pivot), where Pivot is a vector of length p containing the column
numbers in x corresponding to the successive columns of q and r.

qr(x,ronly:T) returns a p by p upper triangular matrix consisting of the
R matrix in the QR decomposition, computed without pivoting.  For
example, both parts of the QR decomposition can be computed by
  Cmd> R <- qr(x,ronly:T) ; Q <- x %/% R # x %*% solve(R)

The columns of Q are orthogonal and x - Q %*% R will be zero except for
rounding error.

An alternative way to get the full QR decomposition is by macro
qrdcomp() in macro file math.mac which uses the information in Qraux.
Type help(qrdcomp) for details.

See also cholesky().


Gary Oehlert 2003-01-15