# ?ggqrf

Computes the generalized QR factorization of two matrices.

## Syntax

FORTRAN 77:

call sggqrf(n, m, p, a, lda, taua, b, ldb, taub, work, lwork, info)

call dggqrf(n, m, p, a, lda, taua, b, ldb, taub, work, lwork, info)

call cggqrf(n, m, p, a, lda, taua, b, ldb, taub, work, lwork, info)

call zggqrf(n, m, p, a, lda, taua, b, ldb, taub, work, lwork, info)

Fortran 95:

call ggqrf(a, b [,taua] [,taub] [,info])

## Description

The routine forms the generalized QR factorization of an n-by-m matrix A and an n-by-p matrix B as `A = Q*R`, `B = Q*T*Z`, where Q is an n-by-n orthogonal/unitary matrix, Z is a p-by-p orthogonal/unitary matrix, and R and T assume one of the forms:

or

where R11 is upper triangular, and

where T12 or T21 is a p-by-p upper triangular matrix.

In particular, if B is square and nonsingular, the GQR factorization of A and B implicitly gives the QR factorization of B-1A as:

`B-1*A = ZH*(T-1*R)`

## Input Parameters

n

  INTEGER. The number of rows of the matrices A and B (`n ≥ 0`).

m

  INTEGER. The number of columns in A (`m ≥ 0`).

p

  INTEGER. The number of columns in B (`p ≥ 0`).

a, b, work

  REAL for sggqrf

  DOUBLE PRECISION for dggqrf

  COMPLEX for cggqrf

  DOUBLE COMPLEX for zggqrf.

  Arrays: a(lda,*) contains the matrix A.

  The second dimension of a must be at least max(1, m).

  b(ldb,*) contains the matrix B.

  The second dimension of b must be at least max(1, p).

  work is a workspace array, its dimension `max(1, lwork)`.

lda

  INTEGER. The first dimension of a; at least max(1, n).

ldb

  INTEGER. The first dimension of b; at least max(1, n).

lwork

  INTEGER. The size of the work array; must be at least max(1, n, m, p).

  If `lwork = -1`, then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array, and no error message related to lwork is issued by xerbla.

  See Application Notes for the suggested value of lwork.

## Output Parameters

a, b

  Overwritten by the factorization data as follows:

  on exit, the elements on and above the diagonal of the array a contain the min(n,m)-by-m upper trapezoidal matrix R (R is upper triangular if `n ≥ m`);the elements below the diagonal, with the array taua, represent the orthogonal/unitary matrix Q as a product of min(n,m) elementary reflectors ;

  if n ≤ p, the upper triangle of the subarray b(1:n, p-n+1:p ) contains the n-by-n upper triangular matrix T;

  if n > p, the elements on and above the (n-p)th subdiagonal contain the n-by-p upper trapezoidal matrix T; the remaining elements, with the array taub, represent the orthogonal/unitary matrix Z as a product of elementary reflectors.

taua, taub

  REAL for sggqrf

  DOUBLE PRECISION for dggqrf

  COMPLEX for cggqrf

  DOUBLE COMPLEX for zggqrf.

  Arrays, DIMENSION at least max (1, min(n, m)) for taua and at least max (1, min(n, p)) for taub. The array taua contains the scalar factors of the elementary reflectors which represent the orthogonal/unitary matrix Q.

  The array taub contains the scalar factors of the elementary reflectors which represent the orthogonal/unitary matrix Z.

`work(1)`

  If `info = 0`, on exit `work(1)` contains the minimum value of lwork required for optimum performance. Use this lwork for subsequent runs.

info

  INTEGER.

  If `info = 0`, the execution is successful.

  If `info = -i`, the i-th parameter had an illegal value.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or restorable arguments, see Fortran 95 Interface Conventions.

Specific details for the routine ggqrf interface are the following:

a

  Holds the matrix A of size (n,m).

b

  Holds the matrix B of size (n,p).

taua

  Holds the vector of length min(n,m).

taub

  Holds the vector of length min(n,p).

## Application Notes

For better performance, try using `lwork ≥ max(n,m, p)*max(nb1,nb2,nb3)`, where nb1 is the optimal blocksize for the QR factorization of an n-by-m matrix, nb2 is the optimal blocksize for the RQ factorization of an n-by-p matrix, and nb3 is the optimal blocksize for a call of ?ormqr/?unmqr.

If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set `lwork = -1`.

If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array work on exit. Use this value (`work(1)`) for subsequent runs.

If you set `lwork = -1`, the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work). This operation is called a workspace query.

Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

Parent topic: Orthogonal Factorizations