# NAG Library Routine Document

## 1Purpose

f01zdf copies a complex band matrix stored in a packed array into an unpacked array, or vice versa.

## 2Specification

Fortran Interface
 Subroutine f01zdf ( job, m, n, kl, ku, a, lda, b, ldb,
 Integer, Intent (In) :: m, n, kl, ku, lda, ldb Integer, Intent (Inout) :: ifail Complex (Kind=nag_wp), Intent (Inout) :: a(lda,n), b(ldb,*) Character (1), Intent (In) :: job
#include nagmk26.h
 void f01zdf_ (const char *job, const Integer *m, const Integer *n, const Integer *kl, const Integer *ku, Complex a[], const Integer *lda, Complex b[], const Integer *ldb, Integer *ifail, const Charlen length_job)

## 3Description

f01zdf unpacks a band matrix that is stored in a packed array, or packs a band matrix that is stored in an unpacked array. The band matrix has $m$ rows, $n$ columns, ${k}_{l}$ nonzero subdiagonals, and ${k}_{u}$ nonzero superdiagonals. This routine is intended for possible use in conjunction with routines from Chapters F06, F07 and F08, where routines that use band matrices store them in the packed form described below.
None.

## 5Arguments

1:     $\mathbf{job}$ – Character(1)Input
On entry: specifies whether the band matrix is to be packed or unpacked.
${\mathbf{job}}=\text{'P'}$ (Pack)
The band matrix is to be packed into array b.
${\mathbf{job}}=\text{'U'}$ (Unpack)
The band matrix is to be unpacked into array a.
Constraint: ${\mathbf{job}}=\text{'P'}$ or $\text{'U'}$.
2:     $\mathbf{m}$ – IntegerInput
3:     $\mathbf{n}$ – IntegerInput
On entry: $m$ and $n$, the number of rows and columns of the band matrix, respectively.
Constraints:
• ${\mathbf{m}}>0$;
• ${\mathbf{n}}>0$.
4:     $\mathbf{kl}$ – IntegerInput
On entry: ${k}_{l}$, the number of subdiagonals of the band matrix.
Constraint: ${\mathbf{kl}}\ge 0$.
5:     $\mathbf{ku}$ – IntegerInput
On entry: ${k}_{u}$, the number of superdiagonals of the band matrix.
Constraint: ${\mathbf{ku}}\ge 0$.
6:     $\mathbf{a}\left({\mathbf{lda}},{\mathbf{n}}\right)$ – Complex (Kind=nag_wp) arrayInput/Output
On entry: if ${\mathbf{job}}=\text{'P'}$, the leading $m$ by $n$ part of a must contain the band matrix stored in unpacked form. Elements of the array that lie outside the banded part of the matrix are not referenced and need not be assigned.
On exit: if ${\mathbf{job}}=\text{'U'}$, the leading $m$ by $n$ part of a contains the band matrix stored in unpacked form. Elements of the leading $m$ by $n$ part of a that are not within the banded part of the matrix are assigned the value zero.
7:     $\mathbf{lda}$ – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f01zdf is called.
Constraint: ${\mathbf{lda}}\ge {\mathbf{m}}$.
8:     $\mathbf{b}\left({\mathbf{ldb}},*\right)$ – Complex (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array b must be at least $\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}+{\mathbf{ku}},{\mathbf{n}}\right)$.
On entry: if ${\mathbf{job}}=\text{'U'}$, b must contain the band matrix in packed form, in the leading $\left({k}_{l}+{k}_{u}+1\right)$ by $\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m+{k}_{u},n\right)$ part of the array. The matrix is packed column by column, with the leading diagonal of the matrix in row $\left({k}_{u}+1\right)$ of b, the first superdiagonal starting at position $2$ in row ${k}_{u}$, the first subdiagonal starting at position $1$ in row $\left({k}_{u}+2\right)$, and so on. Elements of b that are not needed to store the band matrix, for instance the leading ${k}_{u}$ by ${k}_{u}$ triangle, are not referenced and need not be assigned.
On exit: if ${\mathbf{job}}=\text{'P'}$, b contains the band matrix stored in packed form. Elements of b that are not needed to store the band matrix are not referenced.
9:     $\mathbf{ldb}$ – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which f01zdf is called.
Constraint: ${\mathbf{ldb}}\ge \left({\mathbf{kl}}+{\mathbf{ku}}+1\right)$.
10:   $\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{kl}}<0$.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{ku}}<0$.
${\mathbf{ifail}}=4$
 On entry, ${\mathbf{lda}}<{\mathbf{m}}$.
${\mathbf{ifail}}=5$
 On entry, ${\mathbf{ldb}}<{\mathbf{kl}}+{\mathbf{ku}}+1$.
${\mathbf{ifail}}=6$
 On entry, ${\mathbf{m}}<1$, or ${\mathbf{n}}<1$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
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

f01zdf is not threaded in any implementation.

None.

## 10Example

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

### 10.1Program Text

Program Text (f01zdfe.f90)

### 10.2Program Data

Program Data (f01zdfe.d)

### 10.3Program Results

Program Results (f01zdfe.r)

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