Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_matop_real_gen_trans_inplace (f01cr)

## Purpose

nag_matop_real_gen_trans_inplace (f01cr) transposes a rectangular matrix in-situ.

## Syntax

[a, ifail] = f01cr(a, m, n, 'mn', mn)
[a, ifail] = nag_matop_real_gen_trans_inplace(a, m, n, 'mn', mn)

## Description

nag_matop_real_gen_trans_inplace (f01cr) requires that the elements of an m$m$ by n$n$ matrix A$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$A$ stored in the same way. For example, if m = 4$m=4$ and n = 3$n=3$, on entry the array must hold:
 a11 a21 a31 a41 a12 a22 a32 a42 a13 a23 a33 a43 $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. $a11 a12 a13 a21 a22 a23 a31 a32 a33 a41 a42 a43.$

## References

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

## Parameters

### Compulsory Input Parameters

1:     a(mn) – double array
The elements of the m$m$ by n$n$ matrix A$A$, stored by columns.
2:     m – int64int32nag_int scalar
m$m$, the number of rows of the matrix A$A$.
3:     n – int64int32nag_int scalar
n$n$, the number of columns of the matrix A$A$.

### Optional Input Parameters

1:     mn – int64int32nag_int scalar
Default: The dimension of the array a.
n$n$, the value m × n$m×n$.

move lmove

### Output Parameters

1:     a(mn) – double array
The elements of the transpose matrix, also stored by columns.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, mn ≠ m × n${\mathbf{mn}}\ne {\mathbf{m}}×{\mathbf{n}}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, lmove ≤ 0$\mathit{lmove}\le 0$.
ifail < 0${\mathbf{ifail}}<0$
A serious error has occurred. Check all function calls and array sizes. Seek expert help.

## Accuracy

Exact results are produced.

## Further Comments

The time taken by nag_matop_real_gen_trans_inplace (f01cr) is approximately proportional to mn$mn$.

## Example

```function nag_matop_real_gen_trans_inplace_example
a = [1;
2;
3;
4;
5;
6;
7;
8;
9;
10;
11;
12;
13;
14;
15;
16;
17;
18;
19;
20;
21];
m = int64(3);
n = int64(7);
[aOut, ifail] = nag_matop_real_gen_trans_inplace(a, m, n)
```
```

aOut =

1
4
7
10
13
16
19
2
5
8
11
14
17
20
3
6
9
12
15
18
21

ifail =

0

```
```function f01cr_example
a = [1;
2;
3;
4;
5;
6;
7;
8;
9;
10;
11;
12;
13;
14;
15;
16;
17;
18;
19;
20;
21];
m = int64(3);
n = int64(7);
[aOut, ifail] = f01cr(a, m, n)
```
```

aOut =

1
4
7
10
13
16
19
2
5
8
11
14
17
20
3
6
9
12
15
18
21

ifail =

0

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013