Matrix transposition: Difference between revisions

Line 200:
=={{header|Fortran}}==
In ISO Fortran 90 or later, use the TRANSPOSE intrinsic function:
real, dimension(n integer,m) ::parameter a = reshape(:: (/n (i,i=1,n*m) /), (/ n3, m /)= )5
real, dimension(m,n,m) :: ba = reshape( (/ (i,i=1,n*m) /), (/ n, m /) )
real, dimension(m,n) :: b
b = transpose(a)
b = transpose(a)
do i = 1, n
print *, a(i,:)
end do
do j = 1, m
print *, b(j,:)
end do
 
In ANSI FORTRAN 77 with MIL-STD-1753 Fortranextensions or later, use nested structured DO loops:
REAL A(3,5), B(5,3)
DATA ((A(I,J),I=1,3),J=1,5) /1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15/
Anonymous user