F01 Chapter Contents
F01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF01RKF

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

F01RKF returns the first $\ell$ rows of the $n$ by $n$ unitary matrix ${P}^{\mathrm{H}}$, where $P$ is given as the product of Householder transformation matrices.
This routine is intended for use following F01RJF.

## 2  Specification

 SUBROUTINE F01RKF ( WHERET, M, N, NROWP, A, LDA, THETA, WORK, IFAIL)
 INTEGER M, N, NROWP, LDA, IFAIL COMPLEX (KIND=nag_wp) A(LDA,*), THETA(*), WORK(max(M-1,NROWP-M,1)) CHARACTER(1) WHERET

## 3  Description

$P$ is assumed to be given by
 $P = Pm P m-1 ⋯ P1 ,$
where
 $Pk=I-γkukukH, uk= wk ζk 0 zk$
${\gamma }_{k}$ is a scalar for which $\mathrm{Re}\left({\gamma }_{k}\right)=1.0$, ${\zeta }_{k}$ is a real scalar, ${w}_{k}$ is a $\left(k-1\right)$ element vector and ${z}_{k}$ is an $\left(n-m\right)$ element vector. ${w}_{k}$ must be supplied in the $k$th row of A in elements ${\mathbf{A}}\left(k,1\right),\dots ,{\mathbf{A}}\left(k,k-1\right)$. ${z}_{k}$ must be supplied in the $k$th row of A in elements ${\mathbf{A}}\left(k,m+1\right),\dots ,{\mathbf{A}}\left(k,n\right)$ and ${\theta }_{k}$, given by
 $θk=ζk,Imγk,$
must be supplied either in ${\mathbf{A}}\left(k,k\right)$ or in ${\mathbf{THETA}}\left(k\right)$, depending upon the parameter WHERET.

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford

## 5  Parameters

1:     WHERET – CHARACTER(1)Input
On entry: indicates where the elements of $\theta$ are to be found.
${\mathbf{WHERET}}=\text{'I'}$ (In A)
The elements of $\theta$ are in A.
${\mathbf{WHERET}}=\text{'S'}$ (Separate)
The elements of $\theta$ are separate from A, in THETA.
Constraint: ${\mathbf{WHERET}}=\text{'I'}$ or $\text{'S'}$.
2:     M – INTEGERInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{M}}\ge 0$.
3:     N – INTEGERInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{N}}\ge {\mathbf{M}}$.
4:     NROWP – INTEGERInput
On entry: $\ell$, the required number of rows of $P$.
If ${\mathbf{NROWP}}=0$, an immediate return is effected.
Constraint: $0\le {\mathbf{NROWP}}\le {\mathbf{N}}$.
5:     A(LDA,$*$) – COMPLEX (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: the leading $m$ by $m$ strictly lower triangular part of the array A, and the $m$ by $\left(n-m\right)$ rectangular part of A with top left-hand corner at element ${\mathbf{A}}\left(1,{\mathbf{M}}+1\right)$ must contain details of the matrix $P$. In addition, if ${\mathbf{WHERET}}=\text{'I'}$, the diagonal elements of A must contain the elements of $\theta$.
On exit: the first NROWP rows of the array A are overwritten by the first NROWP rows of the $n$ by $n$ unitary matrix ${P}^{\mathrm{H}}$.
6:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F01RKF is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}},{\mathbf{NROWP}}\right)$.
7:     THETA($*$) – COMPLEX (KIND=nag_wp) arrayInput
Note: the dimension of the array THETA must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$ if ${\mathbf{WHERET}}=\text{'S'}$, and at least $1$ otherwise.
On entry: if ${\mathbf{WHERET}}=\text{'S'}$, the array THETA must contain the elements of $\theta$. If ${\mathbf{THETA}}\left(k\right)=0.0$, ${P}_{k}$ is assumed to be $I$, if ${\mathbf{THETA}}\left(k\right)=\alpha$ and $\mathrm{Re}\left(\alpha \right)<0.0$, ${P}_{k}$ is assumed to be of the form
 $Pk= I 0 0 0 α 0 0 0 I ,$
otherwise ${\mathbf{THETA}}\left(k\right)$ is assumed to contain ${\theta }_{k}$ given by
 $θk=ζk,Imγk.$
If ${\mathbf{WHERET}}=\text{'I'}$, the array THETA is not referenced.
8:     WORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{M}}-1,{\mathbf{NROWP}}-{\mathbf{M}},1\right)$) – COMPLEX (KIND=nag_wp) arrayWorkspace
9:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=-1$
 On entry, ${\mathbf{WHERET}}\ne \text{'I'}$ or $\text{'S'}$, or ${\mathbf{M}}<0$, or ${\mathbf{N}}<{\mathbf{M}}$, or ${\mathbf{NROWP}}<0$ or ${\mathbf{NROWP}}>{\mathbf{N}}$, or ${\mathbf{LDA}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}},{\mathbf{NROWP}}\right)$.

## 7  Accuracy

The computed matrix $P$ satisfies the relation
 $P=Q+E,$
where $Q$ is an exactly unitary matrix and
 $E≤cε,$
where $\epsilon$ the machine precision (see X02AJF), $c$ is a modest function of $n$, and $‖.‖$ denotes the spectral (two) norm. See also Section 7 in F01RJF.

## 8  Further Comments

The approximate number of floating point operations is given by
 $83n3n-m2ℓ-m-mℓ-m, if ​ℓ≥m, and ​ 83ℓ23n-ℓ, if ​ℓ

## 9  Example

This example obtains the $5$ by $5$ unitary matrix $P$ following the $RQ$ factorization of the $3$ by $5$ matrix $A$ given by
 $A = -0.5i 0.4-0.3i 0.4i+0.0 0.3-0.4i 0.3i -0.5-1.5i 0.9-1.3i -0.4-0.4i 0.1-0.7i 0.3-0.3i -1.0-1.0i 0.2-1.4i 1.8i+0.0 0.0i+0.0 -2.4i .$

### 9.1  Program Text

Program Text (f01rkfe.f90)

### 9.2  Program Data

Program Data (f01rkfe.d)

### 9.3  Program Results

Program Results (f01rkfe.r)