# ?gerq2

Computes the RQ factorization of a general rectangular matrix using an unblocked algorithm.

## Syntax

call sgerq2( m, n, a, lda, tau, work, info )

call dgerq2( m, n, a, lda, tau, work, info )

call cgerq2( m, n, a, lda, tau, work, info )

call zgerq2( m, n, a, lda, tau, work, info )

## Description

The routine computes a RQ factorization of a real/complex m-by-n matrix A as `A = R*Q`.

The routine does not form the matrix Q explicitly. Instead, Q is represented as a product of min(m, n) elementary reflectors :

`Q = H(1)*H(2)* ... *H(k)`, where `k = min(m, n)`

Each H(i) has the form

`H(i) = I - tau*v*v'`

where tau is a real/complex scalar stored in tau(i), and v is a real/complex vector with `v(n-k+i+1:n) = 0` and `v(n-k+i) = 1`.

On exit, `v(1:n-k+i-1)` is stored in `a(m-k+i, 1:n-k+i-1)`.

## Input Parameters

m

  INTEGER. The number of rows in the matrix A (`m ≥ 0`).

n

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

a, work

  REAL for sgerq2

  DOUBLE PRECISION for dgerq2

  COMPLEX for cgerq2

  COMPLEX*16 for zgerq2.

  Arrays:

  `a(lda,*)` contains the m-by-n matrix A.

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

  work(m) is a workspace array.

lda

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

## Output Parameters

a

  Overwritten by the factorization data as follows:

  on exit, if `m ≤ n`, the upper triangle of the subarray `a(1:m, n-m+1:n )` contains the m-by-m upper triangular matrix R; if `m > n`, the elements on and above the (m-n)-th subdiagonal contain the m-by-n upper trapezoidal matrix R; the remaining elements, with the array tau, represent the orthogonal/unitary matrix Q as a product of elementary reflectors.

tau

  REAL for sgerq2

  DOUBLE PRECISION for dgerq2

  COMPLEX for cgerq2

  COMPLEX*16 for zgerq2.

  Array, DIMENSION at least `max(1, min(m, n))`.

  Contains scalar factors of the elementary reflectors.

info

  INTEGER.

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

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

Parent topic: Auxiliary Routines