# NAG C Library Function Document

## 1Purpose

nag_dtpmqrt (f08bcc) multiplies an arbitrary real matrix $C$ by the real orthogonal matrix $Q$ from a $QR$ factorization computed by nag_dtpqrt (f08bbc).

## 2Specification

 #include #include
 void nag_dtpmqrt (Nag_OrderType order, Nag_SideType side, Nag_TransType trans, Integer m, Integer n, Integer k, Integer l, Integer nb, const double v[], Integer pdv, const double t[], Integer pdt, double c1[], Integer pdc1, double c2[], Integer pdc2, NagError *fail)

## 3Description

nag_dtpmqrt (f08bcc) is intended to be used after a call to nag_dtpqrt (f08bbc) which performs a $QR$ factorization of a triangular-pentagonal matrix containing an upper triangular matrix $A$ over a pentagonal matrix $B$. The orthogonal matrix $Q$ is represented as a product of elementary reflectors.
This function may be used to form the matrix products
 $QC , QTC , CQ ​ or ​ CQT ,$
where the real rectangular ${m}_{c}$ by ${n}_{c}$ matrix $C$ is split into component matrices ${C}_{1}$ and ${C}_{2}$.
If $Q$ is being applied from the left ($QC$ or ${Q}^{\mathrm{T}}C$) then
 $C = C1 C2$
where ${C}_{1}$ is $k$ by ${n}_{c}$, ${C}_{2}$ is ${m}_{v}$ by ${n}_{c}$, ${m}_{c}=k+{m}_{v}$ is fixed and ${m}_{v}$ is the number of rows of the matrix $V$ containing the elementary reflectors (i.e., m as passed to nag_dtpqrt (f08bbc)); the number of columns of $V$ is ${n}_{v}$ (i.e., n as passed to nag_dtpqrt (f08bbc)).
If $Q$ is being applied from the right ($CQ$ or $C{Q}^{\mathrm{T}}$) then
 $C = C1 C2$
where ${C}_{1}$ is ${m}_{c}$ by $k$, and ${C}_{2}$ is ${m}_{c}$ by ${m}_{v}$ and ${n}_{c}=k+{m}_{v}$ is fixed.
The matrices ${C}_{1}$ and ${C}_{2}$ are overwriten by the result of the matrix product.
A common application of this routine is in updating the solution of a linear least squares problem as illustrated in Section 10 in nag_dtpqrt (f08bbc).

## 4References

Golub G H and Van Loan C F (2012) Matrix Computations (4th Edition) Johns Hopkins University Press, Baltimore

## 5Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
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.3.1.3 in How to Use the NAG Library and its Documentation 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_SideTypeInput
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_TransTypeInput
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}$IntegerInput
On entry: the number of rows of the matrix ${C}_{2}$, that is,
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$
then ${m}_{v}$, the number of rows of the matrix $V$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$
then ${m}_{c}$, the number of rows of the matrix $C$.
Constraint: ${\mathbf{m}}\ge 0$.
5:    $\mathbf{n}$IntegerInput
On entry: the number of columns of the matrix ${C}_{2}$, that is,
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$
then ${n}_{c}$, the number of columns of the matrix $C$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$
then ${n}_{v}$, the number of columns of the matrix $V$.
Constraint: ${\mathbf{n}}\ge 0$.
6:    $\mathbf{k}$IntegerInput
On entry: $k$, the number of elementary reflectors whose product defines the matrix $Q$.
Constraint: ${\mathbf{k}}\ge 0$.
7:    $\mathbf{l}$IntegerInput
On entry: $l$, the number of rows of the upper trapezoidal part of the pentagonal composite matrix $V$, passed (as b) in a previous call to nag_dtpqrt (f08bbc). This must be the same value used in the previous call to nag_dtpqrt (f08bbc) (see l in nag_dtpqrt (f08bbc)).
Constraint: $0\le {\mathbf{l}}\le {\mathbf{k}}$.
8:    $\mathbf{nb}$IntegerInput
On entry: $\mathit{nb}$, the blocking factor used in a previous call to nag_dtpqrt (f08bbc) to compute the $QR$ factorization of a triangular-pentagonal matrix containing composite matrices $A$ and $B$.
Constraints:
• ${\mathbf{nb}}\ge 1$;
• if ${\mathbf{k}}>0$, ${\mathbf{nb}}\le {\mathbf{k}}$.
9:    $\mathbf{v}\left[\mathit{dim}\right]$const doubleInput
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}$.
The $\left(i,j\right)$th element of the matrix $V$ is stored in
• ${\mathbf{v}}\left[\left(j-1\right)×{\mathbf{pdv}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{v}}\left[\left(i-1\right)×{\mathbf{pdv}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the ${m}_{v}$ by ${n}_{v}$ matrix $V$; this should remain unchanged from the array b returned by a previous call to nag_dtpqrt (f08bbc).
10:  $\mathbf{pdv}$IntegerInput
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)$.
11:  $\mathbf{t}\left[\mathit{dim}\right]$const doubleInput
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: this must remain unchanged from a previous call to nag_dtpqrt (f08bbc) (see t in nag_dtpqrt (f08bbc)).
12:  $\mathbf{pdt}$IntegerInput
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)$.
13:  $\mathbf{c1}\left[\mathit{dim}\right]$doubleInput/Output
Note: the dimension, dim, of the array c1 must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdc1}}×{\mathbf{n}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}×{\mathbf{pdc1}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and ${\mathbf{order}}=\mathrm{Nag_RowMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdc1}}×{\mathbf{k}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$ and ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pdc1}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$ and ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: ${C}_{1}$, the first part of the composite matrix $C$:
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$
then c1 contains the first $k$ rows of $C$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$
then c1 contains the first $k$ columns of $C$.
On exit: c1 is overwritten by the corresponding block of $QC$ or ${Q}^{\mathrm{T}}C$ or $CQ$ or $C{Q}^{\mathrm{T}}$.
14:  $\mathbf{pdc1}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array c1.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
15:  $\mathbf{c2}\left[\mathit{dim}\right]$doubleInput/Output
Note: the dimension, dim, of the array c2 must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdc2}}×{\mathbf{n}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pdc2}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: ${C}_{2}$, the second part of the composite matrix $C$.
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$
then c2 contains the remaining ${m}_{v}$ rows of $C$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$
then c2 contains the remaining ${m}_{v}$ columns of $C$;
On exit: c2 is overwritten by the corresponding block of $QC$ or ${Q}^{\mathrm{T}}C$ or $CQ$ or $C{Q}^{\mathrm{T}}$.
16:  $\mathbf{pdc2}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array c2.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdc2}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdc2}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
17:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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{k}}=〈\mathit{\text{value}}〉$, ${\mathbf{m}}=〈\mathit{\text{value}}〉$ and ${\mathbf{pdc1}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
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)$.
On entry, ${\mathbf{side}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdc1}}=〈\mathit{\text{value}}〉$, ${\mathbf{n}}=〈\mathit{\text{value}}〉$ and ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdc1}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
NE_INT
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\ge 0$.
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{l}}=〈\mathit{\text{value}}〉$ and ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: $0\le {\mathbf{l}}\le {\mathbf{k}}$.
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$ and ${\mathbf{pdc2}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdc2}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
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{pdc2}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdc2}}\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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

The computed result differs from the exact result by a matrix $E$ such that
 $E2 = Oε C2 ,$
where $\epsilon$ is the machine precision.

## 8Parallelism and Performance

nag_dtpmqrt (f08bcc) 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 $2nk\left(2m-k\right)$ if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ and $2mk\left(2n-k\right)$ if ${\mathbf{side}}=\mathrm{Nag_RightSide}$.