cjp1032
cjp1032

Reputation: 23

Fortran index ordering and array syntax

I’m aware of Fortran’s column major ordering and to ensure the inner-most loop is indexing the first dimension of the array. What I’m unsure about is which of the following would be faster:

do k=1,100
  do j=1, 12
      x(:,k) * y(j,:)
  enddo
enddo

Or:

do k=1,100
  do j=1, 12
     x(:,k) * y_transpose(:,j)
  enddo
enddo

Where x is (k x k) and y is (j x k).

I assume the second option would be faster as the first dimension of y_transpose would be contiguous in memory and faster to access?

Appreciate the help.

Upvotes: 1

Views: 164

Answers (0)

Related Questions