Hi, everyone.
I am trying to do some element-wise multiplication between two 3D arrays/matrices and then calculate the sum of all the elements returned. Something like this:
res = 0 do k = kstart,kend do j = jstart, jend do i = istart, iend res = res + A(i, j, k) * B(i, j ,k) end do end do end do
However, such multiplication is not applied to all the elements in A or B but the elements that were involved between the iteration variables. To make the calculation faster, I tried the ddot function in MKL like this:
n = (kend - kstart + 1) * (jend - jstart + 1) * (iend - istart + 1) res = ddot(n, A(istart:iend, jstart:jend, kstart:kend), 1, B(istart:iend, jstart:jend, kstart:kend), 1)
But in this way I couldn't get the same result as I did by using three do-loops.
Anyone who might tell me where the problem is?
Thanks :)