# p?gebd2

Reduces a general rectangular matrix to real bidiagonal form by an orthogonal/unitary transformation (unblocked algorithm).

## Syntax

call psgebd2(m, n, a, ia, ja, desca, d, e, tauq, taup, work, lwork, info)

call pdgebd2(m, n, a, ia, ja, desca, d, e, tauq, taup, work, lwork, info)

call pcgebd2(m, n, a, ia, ja, desca, d, e, tauq, taup, work, lwork, info)

call pzgebd2(m, n, a, ia, ja, desca, d, e, tauq, taup, work, lwork, info)

## Description

The p?gebd2 routine reduces a real/complex general m-by-n distributed matrix sub(A) = A`(ia:ia+m-1, ja:ja+n-1)` to upper or lower bidiagonal form B by an orthogonal/unitary transformation:

`Q'*sub(A)*P = B.`

If `m ≥ n`, B is the upper bidiagonal; if `m<n`, B is the lower bidiagonal.

## Input Parameters

m

(global) INTEGER.

The number of rows of the distributed matrix sub(A). `(m≥0)`.

n

(global) INTEGER.

The number of columns in the distributed matrix sub(A). (n0).

a

(local).

REAL for psgebd2

DOUBLE PRECISION for pdgebd2

COMPLEX for pcgebd2

COMPLEX*16 for pzgebd2.

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

On entry, this array contains the local pieces of the general distributed matrix sub(A).

ia, ja

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

desca

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

work

(local).

REAL for psgebd2

DOUBLE PRECISION for pdgebd2

COMPLEX for pcgebd2

COMPLEX*16 for pzgebd2.

This is a workspace array of size lwork.

lwork

(local or global) INTEGER.

The size of the array work.

lwork is local input and must be at least `lwork ≥ max(mpa0, nqa0)`,

where `nb = mb_a = nb_a, iroffa = mod(ia-1, nb),`

`iarow = indxg2p(ia, nb, myrow, rsrc_a, nprow)`,

`iacol = indxg2p(ja, nb, mycol, csrc_a, npcol),`

`mpa0 = numroc(m+iroffa, nb, myrow, iarow, nprow),`

`nqa0 = numroc(n+icoffa, nb, mycol, iacol, 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

(local).

On exit, if `m ≥ n`, the diagonal and the first superdiagonal of sub(A) are overwritten with the upper bidiagonal matrix B; the elements below the diagonal, with the array tauq, represent the orthogonal/unitary matrix Q as a product of elementary reflectors, and the elements above the first superdiagonal, with the array taup, represent the orthogonal matrix P as a product of elementary reflectors. If `m < n`, the diagonal and the first subdiagonal are overwritten with the lower bidiagonal matrix B; the elements below the first subdiagonal, with the array tauq, represent the orthogonal/unitary matrix Q as a product of elementary reflectors, and the elements above the diagonal, with the array taup, represent the orthogonal matrix P as a product of elementary reflectors. See Applications Notes below.

d

(local)

REAL for psgebd2

DOUBLE PRECISION for pdgebd2

COMPLEX for pcgebd2

COMPLEX*16 for pzgebd2.

Array of size `LOCc(ja+min(m,n)-1)` if `m ≥ n`; `LOCr(ia+min(m,n)-1)` otherwise. The distributed diagonal elements of the bidiagonal matrix B: `d(i) = a(i,i)`. d is tied to the distributed matrix A.

e

(local)

REAL for psgebd2

DOUBLE PRECISION for pdgebd2

COMPLEX for pcgebd2

COMPLEX*16 for pzgebd2.

Array of size `LOCc(ja+min(m,n)-1)` if `m ≥ n`; `LOCr(ia+min(m,n)-2)` otherwise. The distributed diagonal elements of the bidiagonal matrix B:

if `m ≥ n, e(i) = a(i, i+1)` for `i = 1, 2, ... , n-1;`

if `m < n, e(i) = a(i+1, i)` for `i = 1, 2, ..., m-1`. e is tied to the distributed matrix A.

tauq

(local).

REAL for psgebd2

DOUBLE PRECISION for pdgebd2

COMPLEX for pcgebd2

COMPLEX*16 for pzgebd2.

Array of size `LOCc(ja+min(m,n)-1)`. The scalar factors of the elementary reflectors which represent the orthogonal/unitary matrix Q. tauq is tied to the distributed matrix A.

taup

(local).

REAL for psgebd2

DOUBLE PRECISION for pdgebd2

COMPLEX for pcgebd2

COMPLEX*16 for pzgebd2.

Array of size `LOCr(ia+min(m,n)-1)`. The scalar factors of the elementary reflectors which represent the orthogonal/unitary matrix P. taup is tied to the distributed matrix A.

work

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

info

(local)

INTEGER.

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

if `info < 0`: If the i-th argument is an array and the j-th 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 matrices Q and P are represented as products of elementary reflectors:

If `m≥n`,

`Q = H(1)*H(2)*...*H(n), and P = G(1)*G(2)*...*G(n-1)`

Each H(i) and G(i) has the form:

`H(i) = I - tauq*v*v', and G(i) = I - taup*u*u'`,

where tauq and taup are real/complex scalars, and v and u are real/complex vectors. `v(1: i-1) = 0`, `v(i) = 1`, and `v(i+i:m)` is stored on exit in

`A(ia+i-ia+m-1, ja+i-1)`;

`u(1:i) = 0, u(i+1) = 1`, and `u(i+2:n)` is stored on exit in `A(ia+i-1`, `ja+i+1:ja+n-1)`;

tauq is stored in `tauq(ja+i-1)` and taup in `taup(ia+i-1)`.

If `m < n`,

`v(1: i) = 0`, `v(i+1) = 1`, and `v(i+2:m)` is stored on exit in `A(ia+i+1: ia+m-1, ja+i-1);`

`u(1: i-1) = 0`, `u(i) = 1`, and `u(i+1 :n)` is stored on exit in `A(ia+i-1,ja+i:ja+n-1)`;

tauq is stored in `tauq(ja+i-1)` and taup in `taup(ia+i-1)`.

The contents of sub(A) on exit are illustrated by the following examples:

where d and e denote diagonal and off-diagonal elements of B, vi denotes an element of the vector defining `H(i)`, and ui an element of the vector defining `G(i)`.