Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_matop_complex_tri_pack (f01zb)

## Purpose

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

## Syntax

[a, b, ifail] = f01zb(job, uplo, diag, a, b, 'n', n)
[a, b, ifail] = nag_matop_complex_tri_pack(job, uplo, diag, a, b, 'n', n)

## Description

nag_matop_complex_tri_pack (f01zb) 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 function is intended for possible use in conjunction with functions from Chapters F07 and F08, where some functions that use triangular matrices store them in the packed form described below.

None.

## Parameters

### Compulsory Input Parameters

1:     job – string (length ≥ 1)
Specifies whether the triangular matrix is to be packed or unpacked.
job = 'P'${\mathbf{job}}=\text{'P'}$ (Pack)
The matrix is to be packed into array b.
job = 'U'${\mathbf{job}}=\text{'U'}$ (Unpack)
The matrix is to be unpacked into array a.
Constraint: job = 'P'${\mathbf{job}}=\text{'P'}$ or 'U'$\text{'U'}$.
2:     uplo – string (length ≥ 1)
Specifies the type of the matrix to be copied
uplo = 'L'${\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: (1,1),(2,1),,(n,1), (2,2),(3,2),,(n,2)$\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..
uplo = 'U'${\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: (1,1)$\left(1,1\right)$, (1,2)$\left(1,2\right)$, (2,2)$\left(2,2\right)$, (1,3)$\left(1,3\right)$, (2,3)$\left(2,3\right)$, (3,3)$\left(3,3\right)$, (1,4)$\left(1,4\right)$, etc..
Constraint: uplo = 'L'${\mathbf{uplo}}=\text{'L'}$ or 'U'$\text{'U'}$.
3:     diag – string (length ≥ 1)
Must specify whether the diagonal elements of the matrix are to be copied.
diag = 'B'${\mathbf{diag}}=\text{'B'}$ (Blank)
The diagonal elements of the matrix are not referenced and not copied.
diag = 'U'${\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.
diag = 'N'${\mathbf{diag}}=\text{'N'}$ (Non-unit diagonal)
The diagonal elements of the matrix are referenced and copied.
Constraint: diag = 'B'${\mathbf{diag}}=\text{'B'}$, 'U'$\text{'U'}$ or 'N'$\text{'N'}$.
4:     a(lda,n) – complex array
lda, the first dimension of the array, must satisfy the constraint ldan$\mathit{lda}\ge {\mathbf{n}}$.
If job = 'P'${\mathbf{job}}=\text{'P'}$, then 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 parameter uplo. The opposite triangle of a is not referenced and need not be assigned.
5:     b((n × (n + 1)) / 2$\left({\mathbf{n}}×\left({\mathbf{n}}+1\right)\right)/2$) – complex array
If job = 'U'${\mathbf{job}}=\text{'U'}$, then b must contain the triangular matrix packed by column.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a and the second dimension of the array a. (An error is raised if these dimensions are not equal.)
n must specify the number of rows and columns of the triangular matrix.
Constraint: n > 0${\mathbf{n}}>0$.

lda

### Output Parameters

1:     a(lda,n) – complex array
ldan$\mathit{lda}\ge {\mathbf{n}}$.
If job = 'U'${\mathbf{job}}=\text{'U'}$, then 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 parameter uplo. The opposite triangle of a is not referenced.
2:     b((n × (n + 1)) / 2$\left({\mathbf{n}}×\left({\mathbf{n}}+1\right)\right)/2$) – complex array
If job = 'P'${\mathbf{job}}=\text{'P'}$, then 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.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, job ≠ 'P'${\mathbf{job}}\ne \text{'P'}$ or 'U'$\text{'U'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, uplo ≠ 'L'${\mathbf{uplo}}\ne \text{'L'}$ or 'U'$\text{'U'}$.
ifail = 3${\mathbf{ifail}}=3$
 On entry, diag ≠ 'N'${\mathbf{diag}}\ne \text{'N'}$, 'U'$\text{'U'}$ or 'B'$\text{'B'}$.
ifail = 4${\mathbf{ifail}}=4$
 On entry, n < 1${\mathbf{n}}<1$.
ifail = 5${\mathbf{ifail}}=5$
 On entry, lda < n$\mathit{lda}<{\mathbf{n}}$.

Not applicable.

None.

## Example

```function nag_matop_complex_tri_pack_example
job = 'Pack';
uplo = 'U';
diag = 'N';
a = [ 1.1 + 1.1i,  1.2 + 1.2i,  1.3 + 1.3i,  1.4 + 1.4i;
0 + 0i,  2.2 + 2.2i,  2.3 + 2.3i,  2.4 + 2.4i;
0 + 0i,  0 + 0i,  3.3 + 3.3i,  3.4 + 3.4i;
0 + 0i,  0 + 0i,  0 + 0i,  4.4 + 4.4i];
b =  complex(zeros(10, 1));
[aOut, bOut, ifail] = nag_matop_complex_tri_pack(job, uplo, diag, a, b)
```
```

aOut =

1.1000 + 1.1000i   1.2000 + 1.2000i   1.3000 + 1.3000i   1.4000 + 1.4000i
0.0000 + 0.0000i   2.2000 + 2.2000i   2.3000 + 2.3000i   2.4000 + 2.4000i
0.0000 + 0.0000i   0.0000 + 0.0000i   3.3000 + 3.3000i   3.4000 + 3.4000i
0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   4.4000 + 4.4000i

bOut =

1.1000 + 1.1000i
1.2000 + 1.2000i
2.2000 + 2.2000i
1.3000 + 1.3000i
2.3000 + 2.3000i
3.3000 + 3.3000i
1.4000 + 1.4000i
2.4000 + 2.4000i
3.4000 + 3.4000i
4.4000 + 4.4000i

ifail =

0

```
```function f01zb_example
job = 'Pack';
uplo = 'U';
diag = 'N';
a = [ 1.1 + 1.1i,  1.2 + 1.2i,  1.3 + 1.3i,  1.4 + 1.4i;
0 + 0i,  2.2 + 2.2i,  2.3 + 2.3i,  2.4 + 2.4i;
0 + 0i,  0 + 0i,  3.3 + 3.3i,  3.4 + 3.4i;
0 + 0i,  0 + 0i,  0 + 0i,  4.4 + 4.4i];
b =  complex(zeros(10, 1));
[aOut, bOut, ifail] = f01zb(job, uplo, diag, a, b)
```
```

aOut =

1.1000 + 1.1000i   1.2000 + 1.2000i   1.3000 + 1.3000i   1.4000 + 1.4000i
0.0000 + 0.0000i   2.2000 + 2.2000i   2.3000 + 2.3000i   2.4000 + 2.4000i
0.0000 + 0.0000i   0.0000 + 0.0000i   3.3000 + 3.3000i   3.4000 + 3.4000i
0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   4.4000 + 4.4000i

bOut =

1.1000 + 1.1000i
1.2000 + 1.2000i
2.2000 + 2.2000i
1.3000 + 1.3000i
2.3000 + 2.3000i
3.3000 + 3.3000i
1.4000 + 1.4000i
2.4000 + 2.4000i
3.4000 + 3.4000i
4.4000 + 4.4000i

ifail =

0

```