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_dtpttf (f01vj)

## Purpose

nag_matop_dtpttf (f01vj) copies a real triangular matrix, stored in a standard packed format array, to a Rectangular Full Packed (RFP) format array.

## Syntax

[ar, info] = f01vj(transr, uplo, n, ap)
[ar, info] = nag_matop_dtpttf(transr, uplo, n, ap)

## Description

nag_matop_dtpttf (f01vj) copies a real $n$ by $n$ triangular matrix, $A$, stored in packed format, to RFP format. This function is intended for possible use in conjunction with functions from Chapters F07 and F16 where some functions that use triangular matrices store them in RFP format. The RFP storage format is described in Rectangular Full Packed (RFP) Storage in the F07 Chapter Introduction and the packed storage format is described in Packed storage in the F07 Chapter Introduction.

## References

Gustavson F G, Waśniewski J, Dongarra J J and Langou J (2010) Rectangular full packed format for Cholesky's algorithm: factorization, solution, and inversion ACM Trans. Math. Software 37, 2

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{transr}$ – string (length ≥ 1)
Specifies whether the normal RFP representation of $A$ or its transpose is stored.
${\mathbf{transr}}=\text{'N'}$
The RFP representation of the matrix $A$ is stored.
${\mathbf{transr}}=\text{'T'}$
The transpose of the RFP representation of the matrix $A$ is stored.
Constraint: ${\mathbf{transr}}=\text{'N'}$ or $\text{'T'}$.
2:     $\mathrm{uplo}$ – string (length ≥ 1)
Specifies whether $A$ is upper or lower triangular.
${\mathbf{uplo}}=\text{'U'}$
$A$ is upper triangular.
${\mathbf{uplo}}=\text{'L'}$
$A$ is lower triangular.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
3:     $\mathrm{n}$int64int32nag_int scalar
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     $\mathrm{ap}\left({\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right)$ – double array
The $n$ by $n$ triangular matrix $A$, packed by columns.
More precisely,
• if ${\mathbf{uplo}}=\text{'U'}$, the upper triangle of $A$ must be stored with element ${A}_{ij}$ in ${\mathbf{ap}}\left(i+j\left(j-1\right)/2\right)$ for $i\le j$;
• if ${\mathbf{uplo}}=\text{'L'}$, the lower triangle of $A$ must be stored with element ${A}_{ij}$ in ${\mathbf{ap}}\left(i+\left(2n-j\right)\left(j-1\right)/2\right)$ for $i\ge j$.

None.

### Output Parameters

1:     $\mathrm{ar}\left({\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right)$ – double array
The upper or lower $n$ by $n$ triangular matrix $A$ (as specified by uplo) in either normal or transposed RFP format (as specified by transr). The storage format is described in Rectangular Full Packed (RFP) Storage in the F07 Chapter Introduction.
2:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

$-999<{\mathbf{info}}<0$
If ${\mathbf{info}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{info}}=-999$
Dynamic memory allocation failed.

Not applicable.

None.

## Example

This example reads in a triangular matrix in packed format and copies it to RFP format.
```function f01vj_example

fprintf('f01vj example results\n\n');

transr = 'n';
uplo   = 'u';
n      = int64(4);
ap = [1.1; 1.2; 2.2; 1.3; 2.3; 3.3; 1.4; 2.4; 3.4; 4.4];
% Print the packed array
fprintf('\n');
[ifail] = x04cb('g', 'x', ap, 'f5.2', 'Packed array ap:', 'i', ...
{''}, 'n', {''}, int64(80), int64(0));
% Convert to Rectangular Full Packed form
[ar, info] = f01vj(transr, uplo, n, ap);
% Print the Rectangular Full Packed array
fprintf('\n');
[ifail] = x04cb('g', 'x', ar, 'f5.2', 'RFP packed array ar:', 'i', ...
{''}, 'n', {''}, int64(80), int64(0));

k = int64(n/2);
q = n - k;
if transr=='N' || transr=='n'
lar1 = 2*k + 1;
lar2 = q;
else
lar1 = q;
lar2 = 2*k + 1;
end

ar = reshape(ar,lar1,lar2);

fprintf('\n');
[ifail] = x04cb('g', 'x', ar, 'f5.2', ...
'RFP Packed Array ar (graphical representation):', 'i', ...
{''}, 'i', {''}, int64(80), int64(0), 'm', lar1, 'n', lar2);

```
```f01vj example results

Packed array 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

RFP packed array ar:
1  1.30
2  2.30
3  3.30
4  1.10
5  1.20
6  1.40
7  2.40
8  3.40
9  4.40
10  2.20

RFP Packed Array ar (graphical representation):
1    2
1  1.30 1.40
2  2.30 2.40
3  3.30 3.40
4  1.10 4.40
5  1.20 2.20
```