NAG Library Routine Document

f01zaf (real_tri_pack)

1
Purpose

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

2
Specification

Fortran Interface
Subroutine f01zaf ( job, uplo, diag, n, a, lda, b, ifail)
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
C Header Interface
#include <nagmk26.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)

3
Description

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.

4
References

None.

5
Arguments

1:     job – Character(1)Input
On entry: specifies whether the triangular matrix is to be packed or unpacked.
job='P' (Pack)
The matrix is to be packed into array b.
job='U' (Unpack)
The matrix is to be unpacked into array a.
Constraint: job='P' or 'U'.
2:     uplo – Character(1)Input
On entry: specifies the type of the matrix to be copied
uplo='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, etc..
uplo='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, 1,2, 2,2, 1,3, 2,3, 3,3, 1,4, etc..
Constraint: uplo='L' or 'U'.
3:     diag – Character(1)Input
On entry: must specify whether the diagonal elements of the matrix are to be copied.
diag='B' (Blank)
The diagonal elements of the matrix are not referenced and not copied.
diag='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' (Non-unit diagonal)
The diagonal elements of the matrix are referenced and copied.
Constraint: diag='B', 'U' or 'N'.
4:     n – IntegerInput
On entry: n, the number of rows and columns of the triangular matrix.
Constraint: n>0.
5:     aldan – Real (Kind=nag_wp) arrayInput/Output
On entry: if job='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 job='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:     lda – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f01zaf is called.
Constraint: ldan.
7:     bn×n+1/2 – Real (Kind=nag_wp) arrayInput/Output
On entry: if job='U', b must contain the triangular matrix packed by column.
On exit: if job='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:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 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 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 -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry 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:
ifail=1
On entry, job'P' or 'U': job=value.
ifail=2
On entry, uplo'U' or 'L': uplo=value.
ifail=3
On entry, diag'N', 'U' or 'B': diag=value.
ifail=4
On entry, n=value.
Constraint: n1.
ifail=5
On entry, lda=value and n=value.
Constraint: ldan.
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.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

f01zaf is not threaded in any implementation.

9
Further Comments

None.

10
Example

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

10.1
Program Text

Program Text (f01zafe.f90)

10.2
Program Data

Program Data (f01zafe.d)

10.3
Program Results

Program Results (f01zafe.r)