# NAG CL Interfacef08ngc (dormhr)

Settings help

CL Name Style:

## 1Purpose

f08ngc multiplies an arbitrary real matrix $C$ by the real orthogonal matrix $Q$ which was determined by f08nec when reducing a real general matrix to Hessenberg form.

## 2Specification

 #include
 void f08ngc (Nag_OrderType order, Nag_SideType side, Nag_TransType trans, Integer m, Integer n, Integer ilo, Integer ihi, const double a[], Integer pda, const double tau[], double c[], Integer pdc, NagError *fail)
The function may be called by the names: f08ngc, nag_lapackeig_dormhr or nag_dormhr.

## 3Description

f08ngc is intended to be used following a call to f08nec, which reduces a real general matrix $A$ to upper Hessenberg form $H$ by an orthogonal similarity transformation: $A=QH{Q}^{\mathrm{T}}$. f08nec 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 f08nhc when balancing the matrix; if the matrix has not been balanced, ${i}_{\mathrm{lo}}=1$ and ${i}_{\mathrm{hi}}=n$.
This function may be used to form one of the matrix products
 $QC , QTC , CQ ​ or ​ CQT ,$
overwriting the result on $C$ (which may be any real rectangular matrix).
A common application of this function is to transform a matrix $V$ of eigenvectors of $H$ to the matrix $\mathit{QV}$ of eigenvectors of $A$.

## 4References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{side}$Nag_SideType Input
On entry: indicates how $Q$ or ${Q}^{\mathrm{T}}$ is to be applied to $C$.
${\mathbf{side}}=\mathrm{Nag_LeftSide}$
$Q$ or ${Q}^{\mathrm{T}}$ is applied to $C$ from the left.
${\mathbf{side}}=\mathrm{Nag_RightSide}$
$Q$ or ${Q}^{\mathrm{T}}$ is applied to $C$ from the right.
Constraint: ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_RightSide}$.
3: $\mathbf{trans}$Nag_TransType Input
On entry: indicates whether $Q$ or ${Q}^{\mathrm{T}}$ is to be applied to $C$.
${\mathbf{trans}}=\mathrm{Nag_NoTrans}$
$Q$ is applied to $C$.
${\mathbf{trans}}=\mathrm{Nag_Trans}$
${Q}^{\mathrm{T}}$ is applied to $C$.
Constraint: ${\mathbf{trans}}=\mathrm{Nag_NoTrans}$ or $\mathrm{Nag_Trans}$.
4: $\mathbf{m}$Integer Input
On entry: $m$, the number of rows of the matrix $C$; $m$ is also the order of $Q$ if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$.
Constraint: ${\mathbf{m}}\ge 0$.
5: $\mathbf{n}$Integer Input
On entry: $n$, the number of columns of the matrix $C$; $n$ is also the order of $Q$ if ${\mathbf{side}}=\mathrm{Nag_RightSide}$.
Constraint: ${\mathbf{n}}\ge 0$.
6: $\mathbf{ilo}$Integer Input
7: $\mathbf{ihi}$Integer Input
On entry: these must be the same arguments ilo and ihi, respectively, as supplied to f08nec.
Constraints:
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and ${\mathbf{m}}>0$, $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{m}}$;
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and ${\mathbf{m}}=0$, ${\mathbf{ilo}}=1$ and ${\mathbf{ihi}}=0$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ and ${\mathbf{n}}>0$, $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{n}}$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ and ${\mathbf{n}}=0$, ${\mathbf{ilo}}=1$ and ${\mathbf{ihi}}=0$.
8: $\mathbf{a}\left[\mathit{dim}\right]$const double Input
Note: the dimension, dim, of the array a must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{m}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$.
On entry: details of the vectors which define the elementary reflectors, as returned by f08nec.
9: $\mathbf{pda}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraints:
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
10: $\mathbf{tau}\left[\mathit{dim}\right]$const double Input
Note: the dimension, dim, of the array tau must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}-1\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$.
On entry: further details of the elementary reflectors, as returned by f08nec.
11: $\mathbf{c}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, of the array c must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdc}}×{\mathbf{n}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pdc}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $C$ is stored in
• ${\mathbf{c}}\left[\left(j-1\right)×{\mathbf{pdc}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{c}}\left[\left(i-1\right)×{\mathbf{pdc}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $m×n$ matrix $C$.
On exit: c is overwritten by $QC$ or ${Q}^{\mathrm{T}}C$ or $CQ$ or $C{Q}^{\mathrm{T}}$ as specified by side and trans.
12: $\mathbf{pdc}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array c.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
13: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_ENUM_INT_3
On entry, ${\mathbf{side}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{side}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_ENUM_INT_4
On entry, ${\mathbf{side}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{ilo}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ihi}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and ${\mathbf{m}}>0$, $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{m}}$;
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and ${\mathbf{m}}=0$, ${\mathbf{ilo}}=1$ and ${\mathbf{ihi}}=0$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ and ${\mathbf{n}}>0$, $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{n}}$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ and ${\mathbf{n}}=0$, ${\mathbf{ilo}}=1$ and ${\mathbf{ihi}}=0$.
NE_INT
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}>0$.
On entry, ${\mathbf{pdc}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdc}}>0$.
NE_INT_2
On entry, ${\mathbf{pdc}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
On entry, ${\mathbf{pdc}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 7Accuracy

The computed result differs from the exact result by a matrix $E$ such that
 $‖E‖2 = O(ε) ‖C‖2 ,$
where $\epsilon$ is the machine precision.

## 8Parallelism and Performance

f08ngc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f08ngc 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The total number of floating-point operations is approximately $2n{q}^{2}$ if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and $2m{q}^{2}$ if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, where $q={i}_{\mathrm{hi}}-{i}_{\mathrm{lo}}$.
The complex analogue of this function is f08nuc.

## 10Example

This example computes all the eigenvalues 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 ) ,$
and those eigenvectors which correspond to eigenvalues $\lambda$ such that $\mathrm{Re}\left(\lambda \right)<0$. Here $A$ is general and must first be reduced to upper Hessenberg form $H$ by f08nec. The program then calls f08pec to compute the eigenvalues, and f08pkc to compute the required eigenvectors of $H$ by inverse iteration. Finally f08ngc is called to transform the eigenvectors of $H$ back to eigenvectors of the original matrix $A$.

### 10.1Program Text

Program Text (f08ngce.c)

### 10.2Program Data

Program Data (f08ngce.d)

### 10.3Program Results

Program Results (f08ngce.r)