# NAG CL Interfacef08acc (dgemqrt)

Settings help

CL Name Style:

## 1Purpose

f08acc multiplies an arbitrary real matrix $C$ by the real orthogonal matrix $Q$ from a $QR$ factorization computed by f08abc.

## 2Specification

 #include
 void f08acc (Nag_OrderType order, Nag_SideType side, Nag_TransType trans, Integer m, Integer n, Integer k, Integer nb, const double v[], Integer pdv, const double t[], Integer pdt, double c[], Integer pdc, NagError *fail)
The function may be called by the names: f08acc, nag_lapackeig_dgemqrt or nag_dgemqrt.

## 3Description

f08acc is intended to be used after a call to f08abc which performs a $QR$ factorization of a real matrix $A$. The orthogonal matrix $Q$ is represented as a product of elementary reflectors.
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 in solving linear least squares problems, as described in the F08 Chapter Introduction and illustrated in Section 10 in f08abc.

## 4References

Golub G H and Van Loan C F (2012) Matrix Computations (4th 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$.
Constraint: ${\mathbf{m}}\ge 0$.
5: $\mathbf{n}$Integer Input
On entry: $n$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{n}}\ge 0$.
6: $\mathbf{k}$Integer Input
On entry: $k$, the number of elementary reflectors whose product defines the matrix $Q$. Usually ${\mathbf{k}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({m}_{A},{n}_{A}\right)$ where ${m}_{A}$, ${n}_{A}$ are the dimensions of the matrix $A$ supplied in a previous call to f08abc.
Constraints:
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{m}}\ge {\mathbf{k}}\ge 0$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{n}}\ge {\mathbf{k}}\ge 0$.
7: $\mathbf{nb}$Integer Input
On entry: the block size used in the $QR$ factorization performed in a previous call to f08abc; this value must remain unchanged from that call.
Constraints:
• ${\mathbf{nb}}\ge 1$;
• if ${\mathbf{k}}>0$, ${\mathbf{nb}}\le {\mathbf{k}}$.
8: $\mathbf{v}\left[\mathit{dim}\right]$const double Input
Note: the dimension, dim, of the array v must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdv}}×{\mathbf{k}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pdv}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ and ${\mathbf{side}}=\mathrm{Nag_LeftSide}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdv}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ and ${\mathbf{side}}=\mathrm{Nag_RightSide}$.
On entry: details of the vectors which define the elementary reflectors, as returned by f08abc in the first $k$ columns of its array argument a.
9: $\mathbf{pdv}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array v.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
10: $\mathbf{t}\left[\mathit{dim}\right]$const double Input
Note: the dimension, dim, of the array t must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdt}}×{\mathbf{k}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nb}}×{\mathbf{pdt}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $T$ is stored in
• ${\mathbf{t}}\left[\left(j-1\right)×{\mathbf{pdt}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{t}}\left[\left(i-1\right)×{\mathbf{pdt}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: further details of the orthogonal matrix $Q$ as returned by f08abc. The number of blocks is $b=⌈\frac{k}{{\mathbf{nb}}}⌉$, where $k=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ and each block is of order nb except for the last block, which is of order $k-\left(b-1\right)×{\mathbf{nb}}$. For the $b$ blocks the upper triangular block reflector factors ${\mathbit{T}}_{1},{\mathbit{T}}_{2},\dots ,{\mathbit{T}}_{b}$ are stored in the ${\mathbf{nb}}×n$ matrix $T$ as $\mathbit{T}=\left[{\mathbit{T}}_{1}|{\mathbit{T}}_{2}|\cdots |{\mathbit{T}}_{b}\right]$.
11: $\mathbf{pdt}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array t.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdt}}\ge {\mathbf{nb}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
12: $\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.
13: $\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)$.
14: $\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{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{m}}\ge {\mathbf{k}}\ge 0$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{n}}\ge {\mathbf{k}}\ge 0$.
On entry, ${\mathbf{side}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{pdv}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
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$.
NE_INT_2
On entry, ${\mathbf{nb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nb}}\ge 1$ and
if ${\mathbf{k}}>0$, ${\mathbf{nb}}\le {\mathbf{k}}$.
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)$.
On entry, ${\mathbf{pdt}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
On entry, ${\mathbf{pdt}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nb}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdt}}\ge {\mathbf{nb}}$.
On entry, ${\mathbf{pdv}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\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

The total number of floating-point operations is approximately $2nk\left(2m-k\right)$ if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and $2mk\left(2n-k\right)$ if ${\mathbf{side}}=\mathrm{Nag_RightSide}$.