QRGS {lazy.mat}R Documentation

QR decomposition of X matrix by the Gram Schmidt orthogonalization or
Finding non redundant columns of X

Description

QR decomposition of X matrix by the Gram Schmidt orthogonalization or
Finding non redundant columns of X

Usage

QRGS(X, orth = 0, epsg = 1e-09, print = 0)

Arguments

X

The input matrix.
This matrix is decomposed as X = Q %*% R where Q is the nrow(X) x rank(X) matrix and R is the rank(X) times ncol(X) upper triangular matrix.

orth


If orth = 0 Q will contains non redundant rows of X
If orth = 1 Q will be orthogonalized using Gram-Schumidt.
If orth = 2 Q will be orthonormalized using Gram-Schumidt.

epsg

crit for zero

print

= 1 to print the result

Details

Rduction is performed from left to right.
Q may contain all zero rows.
The Q matrix can be given by native qr function as
qr=qr(X)
Qfromqr=qr.qy(qr,diag(nrow(X)))[,1:ncol(X)]
Qfromqr=Qfromqr[,1:qr$rank,drop=F]
Rfromqr=solve(t(Qfromqr)%*%Qfromqr) %*% t(Qfromqr) %*% X
Xhat=Qfromqr %*% Rfromqr
This should always give X-Xhat == 0.

When X has all zeros rows/columns, native qr works a bit strangely.
Try qr with this X:
b=matrix(1,8,2); b[1,2]=0
X=diag(8)-b %*% matSwp( t(b)%*%b ) %*% t(b)

Value

A list of
Q n x r matrix
R r x p upper triangle matrix
P p x r upper triangle matrix to calculate Q as Q=X rank rank of X: # of independent columns of X
maxadX max( abs( X - Q %*% R ) )

Examples

( resQRGS <- QRGS(demomat(4,3)) )
demomat(4,3) - resQRGS$Q %*% resQRGS$R
resQRGS$Q - demomat(4,3) %*% resQRGS$P

[Package lazy.mat version 0.1.3 Index]