F08NFF (DORGHR) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08NFF (DORGHR)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08NFF (DORGHR) generates the real orthogonal matrix $Q$ which was determined by F08NEF (DGEHRD) when reducing a real general matrix $A$ to Hessenberg form.

## 2  Specification

 SUBROUTINE F08NFF ( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)
 INTEGER N, ILO, IHI, LDA, LWORK, INFO REAL (KIND=nag_wp) A(LDA,*), TAU(*), WORK(max(1,LWORK))
The routine may be called by its LAPACK name dorghr.

## 3  Description

F08NFF (DORGHR) is intended to be used following a call to F08NEF (DGEHRD), which reduces a real general matrix $A$ to upper Hessenberg form $H$ by an orthogonal similarity transformation: $A=QH{Q}^{\mathrm{T}}$. F08NEF (DGEHRD) represents the matrix $Q$ as a product of ${i}_{\mathrm{hi}}-{i}_{\mathrm{lo}}$ elementary reflectors. Here ${i}_{\mathrm{lo}}$ and ${i}_{\mathrm{hi}}$ are values determined by F08NHF (DGEBAL) when balancing the matrix; if the matrix has not been balanced, ${i}_{\mathrm{lo}}=1$ and ${i}_{\mathrm{hi}}=n$.
This routine may be used to generate $Q$ explicitly as a square matrix. $Q$ has the structure:
 $Q = I 0 0 0 Q22 0 0 0 I$
where ${Q}_{22}$ occupies rows and columns ${i}_{\mathrm{lo}}$ to ${i}_{\mathrm{hi}}$.
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrix $Q$.
Constraint: ${\mathbf{N}}\ge 0$.
2:     $\mathrm{ILO}$ – INTEGERInput
3:     $\mathrm{IHI}$ – INTEGERInput
On entry: these must be the same parameters ILO and IHI, respectively, as supplied to F08NEF (DGEHRD).
Constraints:
• if ${\mathbf{N}}>0$, $1\le {\mathbf{ILO}}\le {\mathbf{IHI}}\le {\mathbf{N}}$;
• if ${\mathbf{N}}=0$, ${\mathbf{ILO}}=1$ and ${\mathbf{IHI}}=0$.
4:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: details of the vectors which define the elementary reflectors, as returned by F08NEF (DGEHRD).
On exit: the $n$ by $n$ orthogonal matrix $Q$.
5:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08NFF (DORGHR) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
6:     $\mathrm{TAU}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array TAU must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}-1\right)$.
On entry: further details of the elementary reflectors, as returned by F08NEF (DGEHRD).
7:     $\mathrm{WORK}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)\right)$ – REAL (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
8:     $\mathrm{LWORK}$ – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08NFF (DORGHR) is called, unless ${\mathbf{LWORK}}=-1$, in which case a workspace query is assumed and the routine only calculates the optimal dimension of WORK (using the formula given below).
Suggested value: for optimal performance LWORK should be at least $\left({\mathbf{IHI}}-{\mathbf{ILO}}\right)×nb$, where $nb$ is the block size.
Constraint: ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{IHI}}-{\mathbf{ILO}}\right)$ or ${\mathbf{LWORK}}=-1$.
9:     $\mathrm{INFO}$ – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.

## 7  Accuracy

The computed matrix $Q$ differs from an exactly orthogonal matrix by a matrix $E$ such that
 $E2 = Oε ,$
where $\epsilon$ is the machine precision.

## 8  Parallelism and Performance

F08NFF (DORGHR) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
F08NFF (DORGHR) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

The total number of floating-point operations is approximately $\frac{4}{3}{q}^{3}$, where $q={i}_{\mathrm{hi}}-{i}_{\mathrm{lo}}$.
The complex analogue of this routine is F08NTF (ZUNGHR).

## 10  Example

This example computes the Schur factorization of the matrix $A$, where
 $A = 0.35 0.45 -0.14 -0.17 0.09 0.07 -0.54 0.35 -0.44 -0.33 -0.03 0.17 0.25 -0.32 -0.13 0.11 .$
Here $A$ is general and must first be reduced to Hessenberg form by F08NEF (DGEHRD). The program then calls F08NFF (DORGHR) to form $Q$, and passes this matrix to F08PEF (DHSEQR) which computes the Schur factorization of $A$.

### 10.1  Program Text

Program Text (f08nffe.f90)

### 10.2  Program Data

Program Data (f08nffe.d)

### 10.3  Program Results

Program Results (f08nffe.r)

F08NFF (DORGHR) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual