LF Fortran 95

TRANSPOSE Function

Description

The TRANSPOSE function transposes an array of rank two.

    

Syntax

TRANSPOSE (matrix)

Arguments

matrix is an INTENT(IN) rank two array of any type.

Result

The result is of rank two and the same type and kind as matrix. Its shape is (n, m), where (m, n) is the shape of matrix. Element (i, j) of the result has the value matrix(j, i).

    

Example

integer:: a(2,3)=reshape((/1,2,3,4,5,6/),shape(a)) write(*,'(2i3)') a ! writes 1 2 ! 3 4 ! 5 6 write(*,*) shape(a) ! writes 2 3 write(*,'(3i3)') transpose(a) ! writes 1 3 5 ! 2 4 6 write(*,*) shape(transpose(a)) ! writes 3 2