Package 'QR'

Title: QR Factorization without Pivoting
Description: This function performs QR factorization without pivoting to a real or complex matrix. It is based on Anderson. E. and ten others (1999) "LAPACK Users' Guide". Third Edition. SIAM.
Authors: Juan Claramunt Gonzalez [aut, cre, cph]
Maintainer: Juan Claramunt Gonzalez <[email protected]>
License: GPL-3
Version: 0.1.3
Built: 2024-11-20 06:55:43 UTC
Source: CRAN

Help Index


QR factorization without pivoting

Description

This function performs QR factorization without pivoting to a numeric matrix A.

Usage

QR(A, complete = FALSE)

Arguments

A

a numeric matrix whose QR decomposition is to be computed.

complete

boolean that indicates if the R matrix should be completed with 0s to its full rank.

Details

This method is an alternative to the default qr function of base R. The default function returns a pivoted solution in many cases, which is not always the desired solution. In this function, we returned the unpivoted solution for the QR factorization using the LAPACK routine DGEQRF. Currently, the function only works for real numbers.

Value

Returns a list with the following components:

qr

a matrix with the same dimensions as A. The upper triangle contains the R of the decomposition and the lower triangle contains information on the Q of the decomposition (stored in compact form).

qraux

a vector of length ncol(A) which contains additional information on Q.

Q

an orthogonal matrix such that Q*R is the input matrix.

R

an upper triangular matrix such that Q*R is the input matrix.

Source

LAPACK routine DGEQRF is used for the QR factorization without pivoting.

References

Anderson. E. and ten others (1999) LAPACK Users' Guide. Third Edition. SIAM. Available on-line at http://www.netlib.org/lapack/lug/lapack_lug.html.

Examples

set.seed(2)
A<-matrix(sample(-20:20, size = 25, replace = TRUE),5,5)
qres<-QR(A)

#Inspect the main results of the factorization:
qres$Q
qres$R

QR factorization without pivoting

Description

This function performs QR factorization without pivoting to a complex matrix A.

Usage

QRcomp(A, complete = FALSE)

Arguments

A

a complex matrix whose QR decomposition is to be computed.

complete

boolean that indicates if the R matrix should be completed with 0s to its full rank.

Details

This method is an alternative to the default qr function of base R. The default function returns a pivoted solution in many cases, which is not always the desired solution. In this function, we returned the unpivoted solution for the QR factorization using the LAPACK routine ZGEQRF. This function works with real and complex matrices.

Value

Returns a list with the following components:

qr

a matrix with the same dimensions as A. The upper triangle contains the R of the decomposition and the lower triangle contains information on the Q of the decomposition (stored in compact form).

qraux

a vector of length ncol(A) which contains additional information on Q.

Q

an orthogonal matrix such that Q*R is the input matrix.

R

an upper triangular matrix such that Q*R is the input matrix.

Source

LAPACK routine ZGEQRF is used for the QR factorization without pivoting.

References

Anderson. E. and ten others (1999) LAPACK Users' Guide. Third Edition. SIAM. Available on-line at http://www.netlib.org/lapack/lug/lapack_lug.html.

Examples

set.seed(2)
A<-matrix(c(complex(real=1,imaginary = 1),
complex(real=3,imaginary = -2), complex(real=2,imaginary = 1),
complex(real=0,imaginary = 3)),2,2)
qres<-QRcomp(A)

#Inspect the main results of the factorization:
qres$Q
qres$R