

   RReeccoonnssttrruucctt tthhee QQ,, RR,, oorr XX MMaattrriicceess ffrroomm aa QQRR OObbjjeecctt

        qr.X(qrstr, complete=FALSE, ncol=)
        qr.Q(qrstr, complete=FALSE, Dvec=1)
        qr.R(qrstr, complete=FALSE)

   AArrgguummeennttss::

      qrstr: object representing a QR decomposition.  This will
             typically have come from a previous call to `qr'
             or `lsfit'.

   complete: logical expression of length 1.  Indicates whether
             an arbitrary  orthogonal completion of the Q or X
             matrices is to be made, or whether the R matrix is
             to be completed  by binding zero-value rows
             beneath the square upperl triangle.
                                    d
                                    {
       ncol: integer in the range `1:Xnrow(qrstr$qr)'.  The num-
             ber of columns to be in}the reconstructed X.  The
             default when `complete==}FALSE' is the original X
             from which the qr object' was constructed.   The
             default when `complete==iTRUE' is a square matrix
             with the original `\qn{n `ncol(X)' columns and an
             arbitrary orthogonal cotmpletion (unitary comple-
             tion in the complex cashe) in the remaining
             columns.               e
                                    f
                                    i
       Dvec: vector (not matrix) of rdiagonal values.  Each col-
             umn of the returned Q wsill be multiplied by the
             corresponding diagonal tvalue.

   DDeessccrriippttiioonn::

        Returns the original matrix from which the object was
        constructed or the components of the decomposition.

   VVaalluuee::

        `qr.X' returns X, the original matrix from which the qr
        object was constructed.  If `complete==TRUE' or the
        argument `ncol' is greater than `ncol(X)', additional
        columns from an arbitrary orthogonal (unitary) comple-
        tion of `X' are returned.

        `qr.Q' returns Q, the order-nrow(X) orthogonal (uni-
        tary) transformation represented by qrstr.  If `com-
        plete==TRUE', Q has `nrow(X)' columns.  If `com-
        plete==FALSE', Q has `ncol(X)' columns.  When `Dvec' is
        specified, each column of Q is multiplied by the corre-
        sponding value in `Dvec'.

        `qr.R' returns R, the `c(ncol(X),ncol(X))' upper trian-
        gular matrix such that `X == Q %*% R'.  If `com-
        plete==TRUE', R has `nrow(X)' rows.  If `com-
        plete==FALSE', R has `ncol(X)' rows.

   EExxaammpplleess::

        data(savings)
        p <- ncol(x <- savings[,-1]) # not the 'sr'
        qrstr <- qr(x)   # dim(x) == c(n,p)
        qrstr $ rank # = 4 = p
        Q <- qr.Q(qrstr) # dim(Q) == dim(x)
        R <- qr.R(qrstr) # dim(R) == ncol(x)
        X <- qr.X(qrstr) # X == x
        range(X - as.matrix(x))# ~ < 6e-12

        ## X == Q %*% R :
        all((1 - X /( Q %*% R))< 100*.Machine$double.eps)#TRUE

        dim(Qc <- qr.Q(qrstr, complete=TRUE)) # Square: dim(Qc) == rep(nrow(x),2)
        all((crossprod(Qc) - diag(nrow(x))) < 10*.Machine $double.eps)

        QD <- qr.Q(qrstr, D=1:p)      # QD == Q %*% diag(1:p)
        all(QD - Q %*% diag(1:p)  < 8* .Machine$double.eps)

        dim(Rc <- qr.R(qrstr, complete=TRUE)) # == dim(x)
        dim(Xc <- qr.X(qrstr, complete=TRUE)) # square: nrow(x) ^ 2
        all(Xc[,1:p] == X)

