NAG Library Routine Document

f01crf (real_gen_trans_inplace)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

f01crf transposes a rectangular matrix in-situ.

2
Specification

Fortran Interface
Subroutine f01crf ( a, m, n, mn, move, lmove, ifail)
Integer, Intent (In):: m, n, mn, lmove
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: move(lmove)
Real (Kind=nag_wp), Intent (Inout):: a(mn)
C Header Interface
#include nagmk26.h
void  f01crf_ (double a[], const Integer *m, const Integer *n, const Integer *mn, Integer move[], const Integer *lmove, Integer *ifail)

3
Description

f01crf requires that the elements of an m by n matrix A are stored consecutively by columns in a one-dimensional array. It reorders the elements so that on exit the array holds the transpose of A stored in the same way. For example, if m=4 and n=3, on entry the array must hold:
a11a21a31a41a12a22a32a42a13a23a33a43  
and on exit it holds
a11 a12 a13 a21 a22 a23 a31 a32 a33 a41 a42 a43.  

4
References

Cate E G and Twigg D W (1977) Algorithm 513: Analysis of in-situ transposition ACM Trans. Math. Software 3 104–110

5
Arguments

1:     amn – Real (Kind=nag_wp) arrayInput/Output
On entry: the elements of the m by n matrix A, stored by columns.
On exit: the elements of the transpose matrix, also stored by columns.
2:     m – IntegerInput
On entry: m, the number of rows of the matrix A.
3:     n – IntegerInput
On entry: n, the number of columns of the matrix A.
4:     mn – IntegerInput
On entry: n, the value m×n.
5:     movelmove – Integer arrayWorkspace
6:     lmove – IntegerInput
On entry: the dimension of the array move as declared in the (sub)program from which f01crf is called.
Suggested value: lmove=m+n/2.
Constraint: lmove1.
7:     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,mnm×n.
ifail=2
On entry,lmove0.
ifail<0
A serious error has occurred. Check all subroutine calls and array sizes. Seek expert help.
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

Exact results are produced.

8
Parallelism and Performance

f01crf is not threaded in any implementation.

9
Further Comments

The time taken by f01crf is approximately proportional to mn.

10
Example

This example transposes a 7 by 3 matrix and prints out, for convenience, its transpose.

10.1
Program Text

Program Text (f01crfe.f90)

10.2
Program Data

Program Data (f01crfe.d)

10.3
Program Results

Program Results (f01crfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017