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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_matop_dtrttp (f01va)

## Purpose

nag_matop_dtrttp (f01va) copies a real triangular matrix stored in full format in a two-dimensional array to a standard packed format in a one-dimensional array. Packed storage format is described in Section [Packed storage] in the F07 Chapter Introduction.

## Syntax

[ap, info] = f01va(uplo, a, 'n', n)
[ap, info] = nag_matop_dtrttp(uplo, a, 'n', n)

## Description

nag_matop_dtrttp (f01va) packs a real n$n$ by n$n$ triangular matrix A$A$, stored conventionally in a two-dimensional array, into a one-dimensional array of length n(n + 1) / 2$n\left(n+1\right)/2$. The matrix is packed by columns. This function is intended for possible use in conjunction with functions from Chapters F07 and F08 where some functions use triangular matrices stored in the packed form.

None.

## Parameters

### Compulsory Input Parameters

1:     uplo – string (length ≥ 1)
Specifies whether A$A$ is upper or lower triangular.
uplo = 'U'${\mathbf{uplo}}=\text{'U'}$
A$A$ is upper triangular.
uplo = 'L'${\mathbf{uplo}}=\text{'L'}$
A$A$ is lower triangular.
Constraint: uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or 'L'$\text{'L'}$.
2:     a(lda, : $:$) – double array
The first dimension of the array a must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least n${\mathbf{n}}$
The triangular matrix A$A$.
• If uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, a$a$ is upper triangular and the elements of the array below the diagonal are not referenced.
• If uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, a$a$ is lower triangular and the elements of the array above the diagonal are not referenced.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
n$n$, the order of the matrix A$A$.
Constraint: n1${\mathbf{n}}\ge 1$.

lda

### Output Parameters

1:     ap(n × (n + 1) / 2${\mathbf{n}}×\left({\mathbf{n}}+1\right)/2$) – double array
The n$n$ by n$n$ triangular matrix A$A$, packed by columns.
More precisely,
• if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, the upper triangle of A$A$ is stored with element Aij${A}_{ij}$ in ap(i + j(j1) / 2)${\mathbf{ap}}\left(i+j\left(j-1\right)/2\right)$ for ij$i\le j$;
• if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, the lower triangle of A$A$ is stored with element Aij${A}_{ij}$ in ap(i + (2nj)(j1) / 2)${\mathbf{ap}}\left(i+\left(2n-j\right)\left(j-1\right)/2\right)$ for ij$i\ge j$.
2:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: uplo, 2: n, 3: a, 4: lda, 5: ap, 6: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.

Not applicable.

None.

## Example

```function nag_matop_dtrttp_example
uplo = 'u';
a = [1.1, 1.2, 1.3, 1.4;
0.0, 2.2, 2.3, 2.4;
0.0, 0.0, 3.3, 3.4;
0.0, 0.0, 0.0, 4.4];
% Print the unpacked matrix
fprintf('\n');
[ifail] = nag_file_print_matrix_real_gen_comp(uplo, 'n', a, 'f5.2', 'Unpacked matrix a:', 'i', ...
{''}, 'i', {''}, int64(80), int64(0));,
% Convert to packed vector form
[ap, info] = nag_matop_dtrttp(uplo, a);
% Print the packed vector
fprintf('\n');
[ifail] = nag_file_print_matrix_real_gen_comp('g', 'x', ap, 'f5.2', 'Packed matrix ap:', 'i', ...
{''}, 'n', {''}, int64(80), int64(0));,
```
```

Unpacked matrix a:
1    2    3    4
1  1.10 1.20 1.30 1.40
2       2.20 2.30 2.40
3            3.30 3.40
4                 4.40

Packed matrix ap:
1  1.10
2  1.20
3  2.20
4  1.30
5  2.30
6  3.30
7  1.40
8  2.40
9  3.40
10  4.40

```
```function f01va_example
uplo = 'u';
a = [1.1, 1.2, 1.3, 1.4;
0.0, 2.2, 2.3, 2.4;
0.0, 0.0, 3.3, 3.4;
0.0, 0.0, 0.0, 4.4];
% Print the unpacked matrix
fprintf('\n');
[ifail] = x04cb(uplo, 'n', a, 'f5.2', 'Unpacked matrix a:', 'i', ...
{''}, 'i', {''}, int64(80), int64(0));,
% Convert to packed vector form
[ap, info] = f01va(uplo, a);
% Print the packed vector
fprintf('\n');
[ifail] = x04cb('g', 'x', ap, 'f5.2', 'Packed matrix ap:', 'i', ...
{''}, 'n', {''}, int64(80), int64(0));,
```
```

Unpacked matrix a:
1    2    3    4
1  1.10 1.20 1.30 1.40
2       2.20 2.30 2.40
3            3.30 3.40
4                 4.40

Packed matrix ap:
1  1.10
2  1.20
3  2.20
4  1.30
5  2.30
6  3.30
7  1.40
8  2.40
9  3.40
10  4.40

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013