# p?gehrd

Reduces a general matrix to upper Hessenberg form.

## Syntax

call psgehrd( n, ilo, ihi, a, ia, ja, desca, tau, work, lwork, info)

call pdgehrd( n, ilo, ihi, a, ia, ja, desca, tau, work, lwork, info)

call pcgehrd( n, ilo, ihi, a, ia, ja, desca, tau, work, lwork, info)

call pzgehrd( n, ilo, ihi, a, ia, ja, desca, tau, work, lwork, info)

## Description

The routine reduces a real/complex general distributed matrix sub (A) to upper Hessenberg form H by an orthogonal or unitary similarity transformation

`Q'*sub(A)*Q = H`,

where `sub(A) = A(ia+n-1:ia+n-1, ja+n-1:ja+n-1)`.

## Input Parameters

n

  (global) INTEGER. The order of the distributed matrix sub(A) `(n≥0)`.

ilo, ihi

  (global) INTEGER.

  It is assumed that sub(A) is already upper triangular in rows `ia:ia+ilo-2` and `ia+ihi:ia+n-1` and columns `ja:ja+ilo-2` and `ja+ihi:ja+n-1`. (See Application Notes below).

  If `n > 0, 1≤ilo≤ihi≤n`; otherwise set `ilo = 1, ihi = n`.

a

  (local) REAL for psgehrd

  DOUBLE PRECISION for pdgehrd

  COMPLEX for pcgehrd

  DOUBLE COMPLEX for pzgehrd.

  Pointer into the local memory to an array of dimension `(lld_a, LOCc(ja+n-1))`. On entry, this array contains the local pieces of the n-by-n general distributed matrix sub(A) to be reduced.

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, respectively.

desca

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

work

  (local)

  REAL for psgehrd

  DOUBLE PRECISION for pdgehrd

  COMPLEX for pcgehrd

  DOUBLE COMPLEX for pzgehrd.

  Workspace array of dimension lwork.

lwork

  (local or global) INTEGER, dimension of the array work. lwork is local input and must be at least

  `lwork≥NB*NB + NB*max(ihip+1, ihlp+inlq)`

  where `NB = mb_a = nb_a`,

  `iroffa = mod(ia-1, NB)`,

  `icoffa = mod(ja-1, NB)`,

  `ioff = mod(ia+ilo-2, NB), iarow = indxg2p(ia, NB, MYROW, rsrc_a, NPROW), ihip = numroc(ihi+iroffa, NB, MYROW, iarow, NPROW)`,

  `ilrow = indxg2p(ia+ilo-1, NB, MYROW, rsrc_a, NPROW)`,

  `ihlp = numroc(ihi-ilo+ioff+1, NB, MYROW, ilrow, NPROW)`,

  `ilcol = indxg2p(ja+ilo-1, NB, MYCOL, csrc_a, NPCOL)`,

  `inlq = numroc(n-ilo+ioff+1, NB, MYCOL, ilcol, NPCOL)`,

  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

a

  On exit, the upper triangle and the first subdiagonal of sub(A)are overwritten with the upper Hessenberg matrix H, and the elements below the first subdiagonal, with the array tau, represent the orthogonal/unitary matrix Q as a product of elementary reflectors (see Application Notes below).

tau

  (local). REAL for psgehrd

  DOUBLE PRECISION for pdgehrd

  COMPLEX for pcgehrd

  DOUBLE COMPLEX for pzgehrd.

  Array, DIMENSION at least `max(ja+n-2)`.

  The scalar factors of the elementary reflectors (see Application Notes below). Elements ja:ja+ilo-2 and ja+ihi:ja+n-2 of tau are set to zero. 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 (ihi-ilo) elementary reflectors

`Q = H(ilo)*H(ilo+1)*...*H(ihi-1)`.

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(1:i)= 0, v(i+1)= 1` and `v(ihi+1:n)= 0; v(i+2:ihi)` is stored on exit in `a(ia+ilo+i:ia+ihi-1,ja+ilo+i-2)`, and `tau in tau(ja+ilo+i-2)`. The contents of `a(ia:ia+n-1,ja:ja+n-1)` are illustrated by the following example, with `n = 7`, `ilo = 2` and `ihi = 6`:

on entry

on exit

where a denotes an element of the original matrix sub(A), H denotes a modified element of the upper Hessenberg matrix H, and vi denotes an element of the vector defining `H(ja+ilo+i-2)`.

Parent topic: Nonsymmetric Eigenvalue Problems