f01 Chapter Contents
f01 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_real_form_q (f01qec)

## 1  Purpose

nag_real_form_q (f01qec) returns the first $\mathit{ncolq}$ columns of the real $m$ by $m$ orthogonal matrix $Q$, where $Q$ is given as the product of Householder transformation matrices. This function is intended for use following nag_real_qr (f01qcc).

## 2  Specification

 #include #include
 void nag_real_form_q (Nag_WhereElements wheret, Integer m, Integer n, Integer ncolq, double a[], Integer tda, const double zeta[], NagError *fail)

## 3  Description

$Q$ is assumed to be given by
 $Q = Q n Q n-1 ⋯ Q 1 T ,$
${Q}_{k}$ being given in the form
 $Q k = I 0 0 T k$
where
 $T k = I - u k ukT$
 $u k = ζ k z k ,$
${\zeta }_{k}$ is a scalar and ${z}_{k}$ is an $\left(m-k\right)$ element vector. ${z}_{k}$ must be supplied in the $\left(k-1\right)$th column of a in elements ${\mathbf{a}}\left[\left(k\right)×{\mathbf{tda}}+k-1\right],\dots ,{\mathbf{a}}\left[\left(m-1\right)×{\mathbf{tda}}+k-1\right]$ and ${\zeta }_{k}$ must be supplied either in ${\mathbf{a}}\left[\left(k-1\right)×{\mathbf{tda}}+k-1\right]$ or in ${\mathbf{zeta}}\left[k-1\right]$, depending upon the argument 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  Arguments

1:     wheretNag_WhereElementsInput
On entry: indicates where the elements of $\zeta$ are to be found as follows:
• ${\mathbf{wheret}}=\mathrm{Nag_ElementsIn}$, the elements of $\zeta$ are in a.
• ${\mathbf{wheret}}=\mathrm{Nag_ElementsSeparate}$, the elements of $\zeta$ are separate from a, in zeta.
Constraint: wheret must be Nag_ElementsIn or Nag_ElementsSeparate.
2:     mIntegerInput
On entry: $n$, the number of rows of $A$.
Constraint: ${\mathbf{m}}\ge {\mathbf{n}}$.
3:     nIntegerInput
On entry: $n$, the number of columns of $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     ncolqIntegerInput
On entry: $\mathit{ncolq}$, the required number of columns of $Q$. When ${\mathbf{ncolq}}=0$ then an immediate return is effected.
Constraint: $0\le {\mathbf{ncolq}}\le {\mathbf{m}}$.
5:     a[${\mathbf{m}}×{\mathbf{tda}}$]doubleInput/Output
On entry: the leading $m$ by $n$ strictly lower triangular part of the array a must contain details of the matrix $Q$. In addition, when ${\mathbf{wheret}}=\mathrm{Nag_ElementsIn}$, then the diagonal elements of a must contain the elements of $\zeta$ as described under the argument zeta.
On exit: the first ncolq columns of the array a are overwritten by the first ncolq columns of the $m$ by $m$ orthogonal matrix $Q$. When ${\mathbf{n}}=0$ then the first ncolq columns of a are overwritten by the first ncolq columns of the identity matrix.
6:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{ncolq}}\right)$.
7:     zeta[n]const doubleInput
On entry: if ${\mathbf{wheret}}=\mathrm{Nag_ElementsSeparate}$, the array zeta must contain the elements of $\zeta$. If ${\mathbf{zeta}}\left[k-1\right]=0.0$ then ${T}_{k}$ is assumed to be $I$ otherwise ${\mathbf{zeta}}\left[k-1\right]$ is assumed to contain ${\zeta }_{k}$. When ${\mathbf{wheret}}=\mathrm{Nag_ElementsIn}$, zeta is not referenced and may be set to the null pointer, i.e., (double *)0.
8:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_2_INT_ARG_GT
On entry, ${\mathbf{ncolq}}=〈\mathit{\text{value}}〉$ while ${\mathbf{m}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{ncolq}}\le {\mathbf{m}}$.
NE_2_INT_ARG_LT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{m}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{ncolq}}\right)=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{ncolq}}\right)$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument wheret had an illegal value.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{ncolq}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ncolq}}\ge 0$.

## 7  Accuracy

The computed matrix $Q$ satisfies the relation
 $Q = P + E$
where $P$ is an exactly orthogonal matrix and $‖E‖\le c\epsilon$, $\epsilon$ is the machine precision, $c$ is a modest function of $m$ and $‖.‖$ denotes the spectral (two) norm. See also Section 8.

The approximate number of floating point operations required is given by
 $2 3 n 3 m - n 2 ncolq - n - n ncolq - n ncolq > n 2 3 ncolq 2 3 m - ncolq ncolq ≤ n .$

## 9  Example

To obtain the 5 by 5 orthogonal matrix $Q$ following the $QR$ factorization of the 5 by 3 matrix $A$ given by
 $A = 2.0 -2.5 -2.5 2.0 -2.5 -2.5 1.6 -0.4 -2.8 2.0 -0.5 -0.5 1.2 -0.3 -2.9 .$

### 9.1  Program Text

Program Text (f01qece.c)

### 9.2  Program Data

Program Data (f01qece.d)

### 9.3  Program Results

Program Results (f01qece.r)