# p?gerqf

Computes the RQ factorization of a general rectangular matrix.

## Syntax

call psgerqf( m, n, a, ia, ja, desca, tau, work, lwork, info)

call pdgerqf( m, n, a, ia, ja, desca, tau, work, lwork, info)

call pcgerqf( m, n, a, ia, ja, desca, tau, work, lwork, info)

call pzgerqf( m, n, a, ia, ja, desca, tau, work, lwork, info)

## Description

The routine forms the Q R factorization of a general m-by-n distributed matrix `sub(A)= A(ia:ia+m-1,ja:ja+n-1)` as

`A= R*Q`

## Input Parameters

m

  (global) INTEGER. The number of rows in the distributed submatrix sub(A); `(m≥0)`.

n

  (global) INTEGER. The number of columns in the distributed submatrix sub(A); `(n≥0)`.

a

  (local)

  REAL for psgeqrf

  DOUBLE PRECISION for pdgeqrf

  COMPLEX for pcgeqrf

  DOUBLE COMPLEX for pzgeqrf.

  Pointer into the local memory to an array of local dimension `(lld_a, LOCc(ja+n-1))`.

  Contains the local pieces of the distributed matrix sub(A) to be factored.

ia, ja

  (global) INTEGER. The row and column indices in the global array a indicating the first row and the first column of the submatrix A(ia:ia+m-1,ja:ja+n-1), respectively.

desca

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix A

work

  (local).

  REAL for psgeqrf

  DOUBLE PRECISION for pdgeqrf.

  COMPLEX for pcgeqrf.

  DOUBLE COMPLEX for pzgeqrf

  Workspace array of dimension lwork.

lwork

  (local or global) INTEGER, dimension of work, must be at least `lwork ≥ mb_a*(mp0+nq0+mb_a)`, where

  `iroff = mod(ia-1, mb_a)`,

  `icoff = mod(ja-1, nb_a)`,

  `iarow = indxg2p(ia, mb_a, MYROW, rsrc_a, NPROW)`,

  `iacol = indxg2p(ja, nb_a, MYCOL, csrc_a, NPCOL)`,

  `mp0 = numroc(m+iroff, mb_a, MYROW, iarow, NPROW)`,

  `nq0 = numroc(n+icoff, nb_a, MYCOL, iacol, NPCOL)` and numroc, indxg2p are ScaLAPACK tool functions; MYROW, MYCOL, NPROW and NPCOL can be determined by calling the subroutine blacs_gridinfo.

  If `lwork = -1`, then lwork is global input and a workspace query is assumed; the routine only calculates the minimum and optimal size for all work arrays. Each of these values is returned in the first entry of the corresponding work array, and no error message is issued by pxerbla.

## Output Parameters

a

  On exit, if `m≤n`, the upper triangle of `A(ia:ia+m-1, ja:ja+n-1)` 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 (see Application Notes below).

tau

  (local)

  REAL for psgeqrf

  DOUBLE PRECISION for pdgeqrf

  COMPLEX for pcgeqrf

  DOUBLE COMPLEX for pzgeqrf.

  Array, DIMENSION `LOCr(ia+m-1)`.

  Contains the scalar factor tau of elementary reflectors. tau is tied to the distributed matrix A.

`work(1)`

  On exit, `work(1)` contains the minimum value of lwork required for optimum performance.

info

  (global) INTEGER.

  `= 0`, the execution is successful.

  `< 0`, if the i-th argument is an array and the j-entry had an illegal value, then `info = -(i* 100+j)`, if the i-th argument is a scalar and had an illegal value, then `info = -i`.

## Application Notes

The matrix Q is represented as a product of elementary reflectors

`Q = H(ia)*H(ia+1)*...*H(ia+k-1)`,

where `k = min(m,n)`.

Each H(i) has the form

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

where tau is a real/complex scalar, and v is a real/complex vector with `v(n-k+i+1:n) = 0` and `v(n-k+i) = 1; v(1:n-k+i-1)/conjg (v(1:n-k+i-1))` is stored on exit in `A(ia+m-k+i-1,ja:ja+n-k+i-2)`, and tau in `tau(ia+m-k+i-1)`.

Parent topic: Orthogonal Factorizations