# p?sytd2/p?hetd2

Reduces a symmetric/Hermitian matrix to real symmetric tridiagonal form by an orthogonal/unitary similarity transformation (local unblocked algorithm).

## Syntax

call pssytd2(uplo, n, a, ia, ja, desca, d, e, tau, work, lwork, info)

call pdsytd2(uplo, n, a, ia, ja, desca, d, e, tau, work, lwork, info)

call pchetd2(uplo, n, a, ia, ja, desca, d, e, tau, work, lwork, info)

call pzhetd2(uplo, n, a, ia, ja, desca, d, e, tau, work, lwork, info)

## Description

The routine p?sytd2/p?hetd2 reduces a real symmetric/complex Hermitian matrix sub(A) to symmetric/Hermitian tridiagonal form T by an orthogonal/unitary similarity transformation:

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

## Input Parameters

uplo

  (global) CHARACTER.

  Specifies whether the upper or lower triangular part of the symmetric/Hermitian matrix sub(A) is stored:

  = 'U': upper triangular

  = 'L': lower triangular

n

  (global) INTEGER.

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

a

  (local)

  REAL for pssytd2

  DOUBLE PRECISION for pdsytd2

  COMPLEX for pchetd2

  COMPLEX*16 for pzhetd2.

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

  On entry, this array contains the local pieces of the n-by-n symmetric/Hermitian distributed matrix sub(A).

  If `uplo = 'U'`, the leading n-by-n upper triangular part of sub(A) contains the upper triangular part of the matrix, and the strictly lower triangular part of sub(A) is not referenced.

  If `uplo = 'L'`, the leading n-by-n lower triangular part of sub(A) contains the lower triangular part of the matrix, and the strictly upper triangular part of sub(A) is not referenced.

ia, ja

  (global) INTEGER.

  The row and column indices in the global array A indicating the first row and the first column of the sub(A), respectively.

desca

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

work

  (local)

  REAL for pssytd2

  DOUBLE PRECISION for pdsytd2

  COMPLEX for pchetd2

  COMPLEX*16 for pzhetd2.

  The array work is a temporary workspace array of DIMENSION lwork.

## Output Parameters

a

  On exit, if `uplo = 'U'`, the diagonal and first superdiagonal of sub(A) are overwritten by the corresponding elements of the tridiagonal matrix T, and the elements above the first superdiagonal, with the array tau, represent the orthogonal/unitary matrix Q as a product of elementary reflectors;

  if `uplo = 'L'`, the diagonal and first subdiagonal of A are overwritten by the corresponding elements of the tridiagonal matrix T, and the elements below the first subdiagonal, with the array tau, represent the orthogonal/unitary matrix Q as a product of elementary reflectors. See the Application Notes below.

d

  (local)

  REAL for pssytd2/pchetd2

  DOUBLE PRECISION for pdsytd2/pzhetd2.

  Array, DIMENSION`(LOCc(ja+n-1))`. The diagonal elements of the tridiagonal matrix T:

  `d(i) = a(i,i)`; d is tied to the distributed matrix A.

e

  (local)

  REAL for pssytd2/pchetd2

  DOUBLE PRECISION for pdsytd2/pzhetd2.

  Array, DIMENSION`(LOCc(ja+n-1))`,

  if `uplo = 'U'`, `LOCc(ja+n-2)` otherwise.

  The off-diagonal elements of the tridiagonal matrix T:

  `e(i) = a(i,i+1)` if `uplo = 'U'`,

  `e(i) = a(i+1,i)` if `uplo = 'L'`.

  e is tied to the distributed matrix A.

tau

  (local)

  REAL for pssytd2

  DOUBLE PRECISION for pdsytd2

  COMPLEX for pchetd2

  COMPLEX*16 for pzhetd2.

  Array, DIMENSION`(LOCc(ja+n-1))`.

  The scalar factors of the elementary reflectors. tau is tied to the distributed matrix A.

`work(1)`

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

lwork

  (local or global) INTEGER.

  The dimension of the workspace array work.

  lwork is local input and must be at least `lwork ≥ 3n`.

  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.

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)`,

  if the i-th argument is a scalar and had an illegal value,

  then `info = -i`.

## Application Notes

If uplo = 'U', the matrix Q is represented as a product of elementary reflectors

`Q = H(n-1)*...*H(2)*H(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(i+1:n) = 0` and `v(i) = 1; v(1:i-1)` is stored on exit in `A(ia:ia+i-2, ja+i)`, and tau in `TAU(ja+i-1)`.

If `uplo = 'L'`, the matrix Q is represented as a product of elementary reflectors

`Q = H(1)*H(2)*...*H(n-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` and `v(i+1) = 1`; `v(i+2:n)` is stored on exit in `A(ia+i+1:ia+n-1`, `ja+i-1)`, and tau in `TAU(ja+i-1)`.

The contents of sub (A) on exit are illustrated by the following examples with `n = 5`:

where d and e denotes diagonal and off-diagonal elements of T, and vi denotes an element of the vector defining H(i).

### Note

The distributed submatrix sub(A) must verify some alignment properties, namely the following expression should be true:

`( mb_a.eq.nb_a .AND. iroffa.eq.icoffa )` with `iroffa = mod(ia - 1, mb_a)` and `icoffa = mod(ja -1, nb_a)`.

Parent topic: Auxiliary Routines