# NAG FL Interfacef01crf (real_​gen_​trans_​inplace)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f01crf transposes a rectangular matrix in-situ.

## 2Specification

Fortran Interface
 Subroutine f01crf ( a, m, n, mn, move,
 Integer, Intent (In) :: m, n, mn, lmove Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: move(lmove) Real (Kind=nag_wp), Intent (Inout) :: a(mn)
#include <nag.h>
 void f01crf_ (double a[], const Integer *m, const Integer *n, const Integer *mn, Integer move[], const Integer *lmove, Integer *ifail)
The routine may be called by the names f01crf or nagf_matop_real_gen_trans_inplace.

## 3Description

f01crf requires that the elements of an $m×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.$

## 4References

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

## 5Arguments

1: $\mathbf{a}\left({\mathbf{mn}}\right)$Real (Kind=nag_wp) array Input/Output
On entry: the elements of the $m×n$ matrix $A$, stored by columns.
On exit: the elements of the transpose matrix, also stored by columns.
2: $\mathbf{m}$Integer Input
On entry: $m$, the number of rows of the matrix $A$.
3: $\mathbf{n}$Integer Input
On entry: $n$, the number of columns of the matrix $A$.
4: $\mathbf{mn}$Integer Input
On entry: $\mathit{mn}$, the value $m×n$.
5: $\mathbf{move}\left({\mathbf{lmove}}\right)$Integer array Workspace
6: $\mathbf{lmove}$Integer Input
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: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{mn}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mn}}={\mathbf{m}}×{\mathbf{n}}$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{lmove}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lmove}}>0$.
${\mathbf{ifail}}<0$
A serious internal error has occurred in f01crf.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

Exact results are produced.

## 8Parallelism and Performance

f01crf is not threaded in any implementation.

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

## 10Example

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

### 10.1Program Text

Program Text (f01crfe.f90)

### 10.2Program Data

Program Data (f01crfe.d)

### 10.3Program Results

Program Results (f01crfe.r)