# NAG CL Interfacef01duc (complex_​tri_​matmul_​inplace)

## 1Purpose

f01duc performs one of the matrix-matrix operations
 $B←αAB, B←αATB, B←αAHB, B←αBA, B←αBAT or B←αBAH,$
where $A$ and $B$ are complex triangular matrices, and $\alpha$ is a complex scalar.

## 2Specification

 #include
 void f01duc (Nag_SideType side, Nag_UploType uplo, Nag_TransType transa, Integer n, Complex alpha, const Complex a[], Integer pda, Complex b[], Integer pdb, NagError *fail)
The function may be called by the names: f01duc or nag_matop_complex_tri_matmul_inplace.

## 3Description

f01duc computes the matrix product $B=\alpha AB$ or $B=\alpha BA$ for two upper triangular or two lower triangular matrices. The storage method for matrices $A$ and $B$ must match (e.g., $A$ and $B$ must both be upper triangular or lower triangular matrices). When the transpose or the conjugate transpose of the input matrix $A$ is used during computation, the solution matrix $B$ is a general matrix. Otherwise, the solution matrix $B$ is a triangular matrix with the storage method identified by the input parameter uplo.
None.

## 5Arguments

1: $\mathbf{side}$Nag_SideType Input
On entry: specifies whether $B$ is operated on from the left or the right.
${\mathbf{side}}=\mathrm{Nag_LeftSide}$
$B$ is pre-multiplied from the left.
${\mathbf{side}}=\mathrm{Nag_RightSide}$
$B$ is post-multiplied from the right.
Constraint: ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_RightSide}$.
2: $\mathbf{uplo}$Nag_UploType Input
On entry: specifies whether $A$ and $B$ are upper or lower triangular.
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
$A$ and $B$ are upper triangular.
${\mathbf{uplo}}=\mathrm{Nag_Lower}$
$A$ and $B$ are lower triangular.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
3: $\mathbf{transa}$Nag_TransType Input
On entry: specifies whether the operation involves $A$, ${A}^{\mathrm{T}}$ or ${A}^{\mathrm{H}}$.
${\mathbf{transa}}=\mathrm{Nag_NoTrans}$
The operation involves $A$.
${\mathbf{transa}}=\mathrm{Nag_Trans}$
The operation involves ${A}^{\mathrm{T}}$.
${\mathbf{transa}}=\mathrm{Nag_ConjTrans}$
The operation involves ${A}^{\mathrm{H}}$.
Constraint: ${\mathbf{transa}}=\mathrm{Nag_NoTrans}$, $\mathrm{Nag_Trans}$ or $\mathrm{Nag_ConjTrans}$.
4: $\mathbf{n}$Integer Input
On entry: $n$, the order of the triangular matrices $A$ and $B$.
Constraint: ${\mathbf{n}}\ge 0$.
5: $\mathbf{alpha}$Complex Input
On entry: the scalar $\alpha$.
6: $\mathbf{a}\left[\mathit{dim}\right]$const Complex Input
Note: the dimension, dim, of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pda}}\right)$.
On entry: the $n$ by $n$ triangular matrix $A$.
${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the upper triangular part of $A$ must be stored and the elements of the array below the diagonal are not referenced.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the lower triangular part of $A$ must be stored and the elements of the array above the diagonal are not referenced.
7: $\mathbf{pda}$Integer Input
On entry: the stride separating row elements of the matrix $A$ in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
8: $\mathbf{b}\left[\mathit{dim}\right]$Complex Input/Output
Note: the dimension, dim, of the array b must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdb}}\right)$.
On entry: the $n$ by $n$ triangular matrix $B$.
${B}_{ij}$ is stored in ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the upper triangular part of $B$ must be stored and the elements of the array below the diagonal are not referenced.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the lower triangular part of $B$ must be stored and the elements of the array above the diagonal are not referenced.
If ${\mathbf{alpha}}=0$, b need not be set.
On exit: $B$ is overwritten.
${B}_{ij}$ is stored in ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ and ${\mathbf{transa}}=\mathrm{Nag_NoTrans}$, $B$ is upper triangular and the elements of the array below the diagonal are not set.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$ and ${\mathbf{transa}}=\mathrm{Nag_NoTrans}$, $B$ is lower triangular and the elements of the array above the diagonal are not set.
If ${\mathbf{transa}}=\mathrm{Nag_Trans}$ or ${\mathbf{transa}}=\mathrm{Nag_ConjTrans}$, $B$ is a general matrix.
9: $\mathbf{pdb}$Integer Input
On entry: the stride separating row elements of the matrix $B$ in the array b.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
10: $\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_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
NE_INT_2
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=〈\mathit{\text{value}}〉$, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdb}}\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.

Not applicable.

## 8Parallelism and Performance

f01duc 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.

None.

## 10Example

This example reads in two upper triangular matrices $A$ and $B$. It then calls f01duc to compute the triangular matrix product $B=\alpha {A}^{\mathrm{H}}B$.

### 10.1Program Text

Program Text (f01duce.c)

### 10.2Program Data

Program Data (f01duce.d)

### 10.3Program Results

Program Results (f01duce.r)