In order to maximize speed I am trying to vectorize the following (to enable the compiler to vectorize as it deems good):
integer :: i,j
real :: a(4),b(4,5),c(4,5)
!... setting values to a and b...
do i=1,5
do j=1,4
c(j,i)=b(j,i)/a(i)
end do
end do
I have tried the following
c=b/a
but that doesn't work:
error #6366: The shapes of the array expressions do not conform.
My thought was that since you can do a/i, (array / scalar), I was hoping that it was possible to do (2d array / array). To begin with the dimension of b and c were (5,4) and I thought that was the problem, that it needs to conform to the variable with smaller rank on the first ranks, but this didn't seem to be the case. As of now, I am wondering if it is at all possible??? Or do I have to stick with the do loops? (of course I could be satisfied with vectorize the inner loop)
Very happy with any comments or ideas with this. (I am using ifort 16 on windows)
a(4,5)and initialize it appropriately, so thatc=b/awould be correct. Your initial code is not right by the way as you declarea(4)and loopa(i)overi,5