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)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


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


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


nag_matop_real_gen_trans_inplace (f01cr) 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:
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


Compulsory Input Parameters

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

Optional Input Parameters

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

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
On entry,mnm×n.
On entry,lmove0.
A serious error has occurred. Check all function calls and array sizes. Seek expert help.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


Exact results are produced.

Further Comments

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


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

fprintf('f01cr example results\n\n');

a = [ 1    2    3    4    5    6    7;
      8    9   10   11   12   13   14;
     15   16   17   18   19   20   21];
[m,n] = size(a);

[atrans, ifail] = f01cr(a, int64(m), int64(n));

atrans = reshape(atrans,[n,m]);
disp('Transpose of A');

f01cr example results

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

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–2015