# ?orgbr

Generates the real orthogonal matrix Q or PT determined by ?gebrd.

## Syntax

FORTRAN 77:

call sorgbr(vect, m, n, k, a, lda, tau, work, lwork, info)

call dorgbr(vect, m, n, k, a, lda, tau, work, lwork, info)

Fortran 95:

call orgbr(a, tau [,vect] [,info])

## Description

The routine generates the whole or part of the orthogonal matrices Q and PT formed by the routines sgebrd/dgebrd. Use this routine after a call to sgebrd/dgebrd. All valid combinations of arguments are described in Input parameters. In most cases you need the following:

To compute the whole m-by-m matrix Q:
`call ?orgbr('Q', m, m, n, a ... )`

(note that the array a must have at least m columns).

To form the n leading columns of Q if `m > n`:
`call ?orgbr('Q', m, n, n, a ... )`

To compute the whole n-by-n matrix PT:
`call ?orgbr('P', n, n, m, a ... )`

(note that the array a must have at least n rows).

To form the m leading rows of PT if `m < n`:
`call ?orgbr('P', m, n, m, a ... )`

## Input Parameters

vect

  CHARACTER*1. Must be 'Q' or 'P'.

  If `vect = 'Q'`, the routine generates the matrix Q.

  If `vect = 'P'`, the routine generates the matrix PT.

m

  INTEGER. The number of required rows of Q or PT.

n

  INTEGER. The number of required columns of Q or PT.

k

  INTEGER. One of the dimensions of A in ?gebrd:

  If `vect = 'Q'`, the number of columns in A;

  If `vect = 'P'`, the number of rows in A.

  Constraints: m ≥ 0, n ≥ 0, k ≥ 0.

  For `vect = 'Q'`: `k ≤ n ≤ m` if `m > k`, or `m = n` if m ≤ k.

  For `vect = 'P'`: `k ≤ m ≤ n` if `n > k`, or `m = n` if n ≤ k.

a, work

  REAL for sorgbr

  DOUBLE PRECISION for dorgbr.

  Arrays:

  a(lda,*) is the array a as returned by ?gebrd.

  The second dimension of a must be at least max(1, n).

  work is a workspace array, its dimension `max(1, lwork)`.

lda

  INTEGER. The first dimension of a; at least max(1, m).

tau

  REAL for sorgbr

  DOUBLE PRECISION for dorgbr.

  For `vect = 'Q'`, the array tauq as returned by ?gebrd. For `vect = 'P'`, the array taup as returned by ?gebrd.

  The dimension of tau must be at least max(1, min(m, k)) for `vect = 'Q'`, or max(1, min(m, k)) for `vect = 'P'`.

lwork

  INTEGER. The size of the work array.

  If `lwork = -1`, then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array, and no error message related to lwork is issued by xerbla.

  See Application Notes for the suggested value of lwork.

## Output Parameters

a

  Overwritten by the orthogonal matrix Q or PT (or the leading rows or columns thereof) as specified by vect, m, and n.

`work(1)`

  If `info = 0`, on exit `work(1)` contains the minimum value of lwork required for optimum performance. Use this lwork for subsequent runs.

info

  INTEGER.

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

  If `info = -i`, the i-th parameter had an illegal value.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or restorable arguments, see Fortran 95 Interface Conventions.

Specific details for the routine orgbr interface are the following:

a

  Holds the matrix A of size (m,n).

tau

  Holds the vector of length min(m,k) where

  `k = m`, if `vect = 'P'`,

  `k = n`, if `vect = 'Q'`.

vect

  Must be 'Q' or 'P'. The default value is 'Q'.

## Application Notes

For better performance, try using `lwork = min(m,n)*blocksize`, where blocksize is a machine-dependent value (typically, 16 to 64) required for optimum performance of the blocked algorithm.

If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set `lwork = -1`.

If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array work on exit. Use this value (`work(1)`) for subsequent runs.

If you set `lwork = -1`, the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work). This operation is called a workspace query.

Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

The computed matrix Q differs from an exactly orthogonal matrix by a matrix E such that `||E||2 = O(ε)`.

The approximate numbers of floating-point operations for the cases listed in Description are as follows:

To form the whole of Q:

`(4/3)*n*(3m2 - 3m*n + n2)` if `m > n`;

`(4/3)*m3` if `m ≤ n`.

To form the n leading columns of Q when `m > n`:

`(2/3)*n2*(3m - n2)` if `m > n`.

To form the whole of PT:

`(4/3)*n3` if `m ≥ n`;

`(4/3)*m*(3n2 - 3m*n + m2)` if m < n.

To form the m leading columns of PT when `m < n`:

`(2/3)*n2*(3m - n2)` if `m > n`.

The complex counterpart of this routine is ?ungbr.

Parent topic: Singular Value Decomposition