# p?ormr2/p?unmr2

Multiplies a general matrix by the orthogonal/unitary matrix from an RQ factorization determined by p?gerqf (unblocked algorithm).

## Syntax

call psormr2(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, l work, info)

call pdormr2(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, l work, info)

call pcunmr2(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, l work, info)

call pzunmr2(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, l work, info)

## Description

The routine p?ormr2/p?unmr2 overwrites the general real/complex m-by-n distributed matrix sub `(C)=C(ic:ic+m-1, jc:jc+n-1)` with

`Q*sub(C)` if `side = 'L'` and `trans = 'N'`, or

`QT*sub(C)` / `QH*sub(C)` if `side = 'L'` and `trans = 'T'` (for real flavors) or `trans = 'C'` (for complex flavors), or

`sub(C)*Q` if `side = 'R`' and `trans = 'N'`, or

`sub(C)*QT` / `sub(C)*QH` if `side = 'R'` and `trans = 'T'` (for real flavors) or `trans = 'C'` (for complex flavors).

where Q is a real orthogonal or complex unitary distributed matrix defined as the product of k elementary reflectors

`Q = H(1)*H(2)*...*H(k)` (for real flavors)

`Q = (H(1))H*(H(2))H*...*(H(k))H` (for complex flavors)

as returned by p?gerqf . Q is of order m if `side = 'L'` and of order n if `side = 'R'`.

## Input Parameters

side

  (global) CHARACTER.

  = 'L': apply Q or QT for real flavors (QH for complex flavors) from the left,

  = 'R': apply Q or QT for real flavors (QH for complex flavors) from the right.

trans

  (global) CHARACTER.

  = 'N': apply Q (no transpose)

  = 'T': apply QT (transpose, for real flavors)

  = 'C': apply QH (conjugate transpose, for complex flavors)

m

  (global) INTEGER.

  The number of rows to be operated on, that is, the number of rows of the distributed submatrix sub(C). `m ≥ 0`.

n

  (global) INTEGER.

  The number of columns to be operated on, that is, the number of columns of the distributed submatrix sub(C). `n ≥ 0`.

k

  (global) INTEGER.

  The number of elementary reflectors whose product defines the matrix Q.

  If `side = 'L'`, `m ≥ k ≥ 0;`

  if `side = 'R'`, `n ≥ k ≥ 0`.

a

  (local)

  REAL for psormr2

  DOUBLE PRECISION for pdormr2

  COMPLEX for pcunmr2

  COMPLEX*16 for pzunmr2.

  Pointer into the local memory to an array, DIMENSION

  `(lld_a, LOCc(ja+m-1)` if `side='L'`,

  `(lld_a, LOCc(ja+n-1)` if side='R',

  where `lld_a ≥ max (1, LOCr(ia+k-1))`.

  On entry, the i-th row must contain the vector that defines the elementary reflector `H(i), ia ≤ i ≤ ia+k-1`, as returned by p?gerqf in the k rows of its distributed matrix argument `A(ia:ia+k-1, ja:*)`.

  The argument `A(ia:ia+k-1, ja:*)` is modified by the routine but restored on exit.

ia

  (global) INTEGER.

  The row index in the global array A indicating the first row of sub(A).

ja

  (global) INTEGER.

  The column index in the global array A indicating the first column of sub(A).

desca

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

tau

  (local)

  REAL for psormr2

  DOUBLE PRECISION for pdormr2

  COMPLEX for pcunmr2

  COMPLEX*16 for pzunmr2.

  Array, DIMENSION `LOCc(ia+k-1)`. This array contains the scalar factors tau(i) of the elementary reflector H(i), as returned by p?gerqf. This array is tied to the distributed matrix A.

c

  (local)

  REAL for psormr2

  DOUBLE PRECISION for pdormr2

  COMPLEX for pcunmr2

  COMPLEX*16 for pzunmr2.

  Pointer into the local memory to an array, DIMENSION`(lld_c, LOCc(jc+n-1))`. On entry, the local pieces of the distributed matrix sub (C).

ic

  (global) INTEGER.

  The row index in the global array C indicating the first row of sub(C).

jc

  (global) INTEGER.

  The column index in the global array C indicating the first column of sub(C).

descc

  (global and local) INTEGER array of DIMENSION (dlen_). The array descriptor for the distributed matrix C.

work

  (local)

  REAL for psormr2

  DOUBLE PRECISION for pdormr2

  COMPLEX for pcunmr2

  COMPLEX*16 for pzunmr2.

  Workspace array, DIMENSION (lwork).

lwork

  (local or global) INTEGER.

  The dimension of the array work.

  lwork is local input and must be at least

  if `side = 'L'`, `lwork ≥ mpc0 + max(max(1, nqc0), numroc(numroc(m+iroffc, mb_a, 0, 0, nprow), mb_a, 0, 0, lcmp))`,

  if `side = 'R'`, `lwork ≥ nqc0 + max(1, mpc0)`,

  where `lcmp = lcm/nprow`,

  `lcm = iclm(nprow, npcol)`,

  `iroffc = mod(ic-1, mb_c),`

  `icoffc = mod(jc-1, nb_c)`,

  `icrow = indxg2p(ic, mb_c, myrow, rsrc_c, nprow)`,

  `iccol = indxg2p(jc, nb_c, mycol, csrc_c, npcol)`,

  `Mpc0 = numroc(m+iroffc, mb_c, myrow, icrow, nprow)`,

  `Nqc0 = numroc(n+icoffc, nb_c, mycol, iccol, npcol)`,

  ilcm, indxg2p and numroc 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

c

  On exit, c is overwritten by `Q*sub(C)`, or `QT*sub(C)`/ `QH*sub(C)`, or `sub(C)*Q`, or `sub(C)*QT` / `sub(C)*QH`

work

  On exit, `work(1)` returns the minimal and optimal lwork.

info

  (local) INTEGER.

  `= 0`: successful exit

  `< 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`.

### Note

The distributed submatrices `A(ia:*, ja:*)` and `C(ic:ic+m-1,jc:jc+n-1)` must verify some alignment properties, namely the following expressions should be true:

If `side = 'L'`, `( nb_a.eq.mb_c .AND. icoffa.eq.iroffc )`

If `side = 'R'`, `( nb_a.eq.nb_c .AND. icoffa.eq.icoffc .AND. iacol.eq.iccol )`.

Parent topic: Auxiliary Routines