# NAG FL Interfacef01zaf (real_​tri_​pack)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine f01zaf ( job, uplo, diag, n, a, lda, b,
 Integer, Intent (In) :: n, lda Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (Inout) :: a(lda,n), b((n*(n+1))/2) Character (1), Intent (In) :: job, uplo, diag
#include <nag.h>
 void f01zaf_ (const char *job, const char *uplo, const char *diag, const Integer *n, double a[], const Integer *lda, double b[], Integer *ifail, const Charlen length_job, const Charlen length_uplo, const Charlen length_diag)
The routine may be called by the names f01zaf or nagf_matop_real_tri_pack.

## 3Description

f01zaf 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}$Integer Input
On entry: $n$, the number of rows and columns of the triangular matrix.
Constraint: ${\mathbf{n}}>0$.
5: $\mathbf{a}\left({\mathbf{lda}},{\mathbf{n}}\right)$Real (Kind=nag_wp) array Input/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}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f01zaf is called.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}$.
7: $\mathbf{b}\left(\left({\mathbf{n}}×\left({\mathbf{n}}+1\right)\right)/2\right)$Real (Kind=nag_wp) array Input/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}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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{job}}=⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{uplo}}\ne \text{'U'}$ or $\text{'L'}$: ${\mathbf{uplo}}=⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{diag}}\ne \text{'N'}$, $\text{'U'}$ or $\text{'B'}$: ${\mathbf{diag}}=⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=5$
On entry, ${\mathbf{lda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

f01zaf 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 (f01zafe.f90)

### 10.2Program Data

Program Data (f01zafe.d)

### 10.3Program Results

Program Results (f01zafe.r)