Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

TRANSPOSE

Transformational Intrinsic Function (Generic): Transposes an array of rank two.

result = TRANSPOSE (matrix)

matrix

(Input) Must be a rank-two array. It may be of any data type.

Results

The result is a rank-two array with the same type and kind parameters as matrix. Its shape is (n, m), where (m, n) is the shape of matrix. For example, if the shape of matrix is (4,6), the shape of the result is (6,4).

Element (i, j) of the result has the value matrix(j, i), where i is in the range 1 to n, and j is in the range 1 to m.

Example

B is the array

  [ 2  3  4 ]
  [ 5  6  7 ]
  [ 8  9  1 ].

TRANSPOSE (B) has the value

  [ 2  5  8 ]
  [ 3  6  9 ]
  [ 4  7  1 ].

The following shows another example:

 INTEGER array(2, 3), result(3, 2)
 array = RESHAPE((/1, 2, 3, 4, 5, 6/), (/2, 3/))
 ! array is  1  3  5
 !           2  4  6
 result = TRANSPOSE(array)
 ! result is 1  2
 !           3  4
 !           5  6
 END

See Also