# NAG Library Routine Document

## 1Purpose

f01zbf copies a complex triangular matrix stored in a packed one-dimensional array into an unpacked two-dimensional array, or vice versa.

## 2Specification

Fortran Interface
 Subroutine f01zbf ( job, uplo, diag, n, a, lda, b,
 Integer, Intent (In) :: n, lda Integer, Intent (Inout) :: ifail Complex (Kind=nag_wp), Intent (Inout) :: a(lda,n), b((n*(n+1))/2) Character (1), Intent (In) :: job, uplo, diag
#include nagmk26.h
 void f01zbf_ (const char *job, const char *uplo, const char *diag, const Integer *n, Complex a[], const Integer *lda, Complex b[], Integer *ifail, const Charlen length_job, const Charlen length_uplo, const Charlen length_diag)

## 3Description

f01zbf unpacks a triangular matrix stored in a vector into a two-dimensional array, or packs a triangular matrix stored in a two-dimensional array into a vector. The matrix is packed by column. This routine is intended for possible use in conjunction with routines from Chapters F06, F07 and F08, where some routines that use triangular matrices store them in the packed form described below.

None.

## 5Arguments

1:     $\mathbf{job}$ – Character(1)Input
On entry: specifies whether the triangular matrix is to be packed or unpacked.
${\mathbf{job}}=\text{'P'}$ (Pack)
The matrix is to be packed into array b.
${\mathbf{job}}=\text{'U'}$ (Unpack)
The matrix is to be unpacked into array a.
Constraint: ${\mathbf{job}}=\text{'P'}$ or $\text{'U'}$.
2:     $\mathbf{uplo}$ – Character(1)Input
On entry: specifies the type of the matrix to be copied
${\mathbf{uplo}}=\text{'L'}$ (Lower)
The matrix is lower triangular. In this case the packed vector holds, or will hold on exit, the matrix elements in the following order: $\left(1,1\right),\left(2,1\right),\dots ,\left({\mathbf{n}},1\right),\left(2,2\right),\left(3,2\right),\dots ,\left({\mathbf{n}},2\right)$, etc..
${\mathbf{uplo}}=\text{'U'}$ (Upper)
The matrix is upper triangular. In this case the packed vector holds, or will hold on exit, the matrix elements in the following order: $\left(1,1\right)$, $\left(1,2\right)$, $\left(2,2\right)$, $\left(1,3\right)$, $\left(2,3\right)$, $\left(3,3\right)$, $\left(1,4\right)$, etc..
Constraint: ${\mathbf{uplo}}=\text{'L'}$ or $\text{'U'}$.
3:     $\mathbf{diag}$ – Character(1)Input
On entry: must specify whether the diagonal elements of the matrix are to be copied.
${\mathbf{diag}}=\text{'B'}$ (Blank)
The diagonal elements of the matrix are not referenced and not copied.
${\mathbf{diag}}=\text{'U'}$ (Unit diagonal)
The diagonal elements of the matrix are not referenced, but are assumed all to be unity, and are copied as such.
${\mathbf{diag}}=\text{'N'}$ (Non-unit diagonal)
The diagonal elements of the matrix are referenced and copied.
Constraint: ${\mathbf{diag}}=\text{'B'}$, $\text{'U'}$ or $\text{'N'}$.
4:     $\mathbf{n}$ – IntegerInput
On entry: n must specify the number of rows and columns of the triangular matrix.
Constraint: ${\mathbf{n}}>0$.
5:     $\mathbf{a}\left({\mathbf{lda}},{\mathbf{n}}\right)$ – Complex (Kind=nag_wp) arrayInput/Output
On entry: if ${\mathbf{job}}=\text{'P'}$, the leading n by n part of a must contain the matrix to be copied, stored in unpacked form, in the upper or lower triangle depending on argument uplo. The opposite triangle of a is not referenced and need not be assigned.
On exit: if ${\mathbf{job}}=\text{'U'}$, the leading n by n part of array a contains the copied matrix, stored in unpacked form, in the upper or lower triangle depending on argument uplo. The opposite triangle of a is not referenced.
6:     $\mathbf{lda}$ – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f01zbf is called.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}$.
7:     $\mathbf{b}\left(\left({\mathbf{n}}×\left({\mathbf{n}}+1\right)\right)/2\right)$ – Complex (Kind=nag_wp) arrayInput/Output
On entry: if ${\mathbf{job}}=\text{'U'}$, b must contain the triangular matrix packed by column.
On exit: if ${\mathbf{job}}=\text{'P'}$, b contains the triangular matrix packed by column.
Note that b must have space for the diagonal elements of the matrix, even if these are not stored.
8:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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{job}}\ne \text{'P'}$ or $\text{'U'}$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{uplo}}\ne \text{'L'}$ or $\text{'U'}$.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{diag}}\ne \text{'N'}$, $\text{'U'}$ or $\text{'B'}$.
${\mathbf{ifail}}=4$
 On entry, ${\mathbf{n}}<1$.
${\mathbf{ifail}}=5$
 On entry, ${\mathbf{lda}}<{\mathbf{n}}$.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8Parallelism and Performance

f01zbf is not threaded in any implementation.

None.

## 10Example

This example reads in a triangular matrix $A$, and copies it to the packed matrix $B$.

### 10.1Program Text

Program Text (f01zbfe.f90)

### 10.2Program Data

Program Data (f01zbfe.d)

### 10.3Program Results

Program Results (f01zbfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017