F01 Chapter Contents
F01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF01CRF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F01CRF transposes a rectangular matrix in-situ.

## 2  Specification

 SUBROUTINE F01CRF ( A, M, N, MN, MOVE, LMOVE, IFAIL)
 INTEGER M, N, MN, MOVE(LMOVE), LMOVE, IFAIL REAL (KIND=nag_wp) A(MN)

## 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:
 $a11 a21 a31 a41 a12 a22 a32 a42 a13 a23 a33 a43$
and on exit it holds
 $a11 a12 a13 a21 a22 a23 a31 a32 a33 a41 a42 a43.$
Cate E G and Twigg D W (1977) Algorithm 513: Analysis of in-situ transposition ACM Trans. Math. Software 3 104–110

## 5  Parameters

1:     A(MN) – 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:     MOVE(LMOVE) – 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: ${\mathbf{LMOVE}}=\left(m+n\right)/2$.
Constraint: ${\mathbf{LMOVE}}\ge 1$.
7:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ 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 parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{MN}}\ne {\mathbf{M}}×{\mathbf{N}}$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{LMOVE}}\le 0$.
${\mathbf{IFAIL}}<0$
A serious error has occurred. Check all subroutine calls and array sizes. Seek expert help.

## 7  Accuracy

Exact results are produced.

The time taken by F01CRF is approximately proportional to $mn$.

## 9  Example

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

### 9.1  Program Text

Program Text (f01crfe.f90)

### 9.2  Program Data

Program Data (f01crfe.d)

### 9.3  Program Results

Program Results (f01crfe.r)