hide long namesshow long names
hide short namesshow short names
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 mm by nn matrix AA are stored consecutively by columns in a one-dimensional array. It reorders the elements so that on exit the array holds the transpose of AA stored in the same way. For example, if m = 4m=4 and n = 3n=3, on entry the array must hold:
a11a21a31a41a12a22a32a42a13a23a33a43
a11a21a31a41a12a22a32a42a13a23a33a43
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 mm by nn matrix AA, stored by columns.
2:     m – int64int32nag_int scalar
mm, the number of rows of the matrix AA.
3:     n – int64int32nag_int scalar
nn, the number of columns of the matrix AA.

Optional Input Parameters

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

Input Parameters Omitted from the MATLAB Interface

move lmove

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,mnm × nmnm×n.
  ifail = 2ifail=2
On entry,lmove0lmove0.
  ifail < 0ifail<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 mnmn.

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