# GEQP3 QR Factorization of a Rectangular Matrix

GEQP3 is a FORTRAN90 library which contains the portion of the LAPACK library that carries out the QR factorization, with column pivoting, of an M by N rectangular matrix, with N <= M.

The factorization can be written as

```       A = Q *  R0 * P'

= Q * (R) * P',
(0)
```
where
• Q is an M by M orthogonal matrix;
• R0 is an M by N upper trapezoidal matrix, which is guaranteed to include a final M-N by N block of zeros.
• R is an N by N upper triangular matrix, whose diagonal elements are in descending magnitude, and some of which may be zero if the system does not have full column rank N.
• P is an N by N permutation matrix that reflects the column pivoting;

The rank of A can be estimated by the rank of R, which, in turn, can be estimated by taking a tolerance T, and comparing the consecutive diagonal elements of R to T * R(1,1). If K is the last diagonal element which is at least T * R(1,1) in magnitude, we estimate the rank as K.

Thereafter, a least squares soluation of the linear system A*X=B can be determined by:

```        X = P * ( inv ( R(1:k,1:k) ) * ( Q' * B )(1:k,1:k) )
( 0                                        )
```

### Languages:

GEQP3 is available in a FORTRAN77 version and a FORTRAN90 version.

### Related Programs:

BAND_QR, a FORTRAN90 library which computes the QR factorization of a banded matrix, and can solve related linear systems, by Alfredo Remon, Enrique Quintana-Orti, Gregorio Quintana-Orti.

LAPACK_EXAMPLES, a FORTRAN90 program which demonstrates the use of the LAPACK linear algebra library.

LINPACK, a FORTRAN90 library which solves linear systems for a variety of matrix storage schemes, real or complex arithmetic, and single or double precision. It includes a routine for computing the singular value decomposition (SVD) of a rectangular matrix. The original version of this library is by Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart.

QR_SOLVE, a FORTRAN90 library which computes the least squares solution of a linear system A*x=b.

### References:

1. Edward Anderson, Zhaojun Bai, Christian Bischof, Susan Blackford, James Demmel, Jack Dongarra, Jeremy DuCroz, Anne Greenbaum, Sven Hammarling, Alan McKenney, Danny Sorensen,
LAPACK User's Guide,
Third Edition,
SIAM, 1999,
ISBN: 0898714478,
LC: QA76.73.F25L36

### List of Routines:

• DCOPY copies a vector X to a vector Y.
• DGEMM computes C = alpha * A * B and related operations.
• DGEMV computes y := alpha * A * x + beta * y for general matrix A.
• DGEQP3 computes a QR factorization with column pivoting using Level 3 BLAS.
• DGEQRF computes a QR factorization of a real M by N matrix A = Q * R.
• DGEQR2 computes a QR factorization of a real M by N matrix A = Q * R.
• DGER computes A := alpha*x*y' + A.
• DLAMC3 forces A and B to be stored prior to doing the addition.
• DLAMCH determines real ( kind = 8 ) machine parameters.
• DLAPY2 returns sqrt ( X^2 + Y^2 ), while avoiding unnecessary overflow.
• DLAQP2 QR factors with column pivoting the block A(OFFSET+1:M,1:N).
• DLAQPS computes a step of QR factorization with column pivoting.
• DLARF applies a real elementary reflector to an M by N matrix.
• DLARFB applies a block reflector to a general rectangular matrix.
• DLARFG generates a real elementary reflector H of order N.
• DLARFT forms the triangular factor T of a real block reflector H of order N.
• DNRM2 returns the euclidean norm of a vector.
• DORM2R overwrites M by N matrix C with Q*C, Q'*C, C*Q or C*Q'.
• DORMQR replaces the rectangular matrix C by Q*C, Q'*C, C*Q or C*Q'.
• DSCAL scales a vector by a constant.
• DSWAP interchanges two vectors.
• DTRMM performs B:=A*B or B:=B*A, A triangular, B rectangular.
• DTRMV computes x: = A*x or x = A'*x for a triangular matrix A.
• DTRSM performs B:=inv(A)*C or B:=C*inv(A), B and C rectangular, A triangular.
• IDAMAX indexes the array element of maximum absolute value.
• IEEECK verifies that infinity and NAN arithmetic are safe.
• ILADLC scans matrix A for its last nonzero column.
• ILADLR returns the index of the last nonzero row of a matrix.
• ILAENV returns problem-dependent parameters.
• IPARMQ sets problem and machine dependent parameters.
• LSAME returns TRUE if CA is the same letter as CB regardless of case.
• XERBLA is an error handler for the LAPACK routines.

You can go up one level to the FORTRAN90 source codes.

Last revised on 24 March 2014.