
I fixed my code by turning the one dimensional arrays into 3 dimensional ones. This is much faster and totally sliced. But there still must be a way thats even faster. Rob. Rob wrote:
I've been working on this for so long I may be missing the obvious. Here is a snippet of code that I would like to at least get rid of one more indexing operation. The problem is the presence of the one dimensional array constants which are functions of x,y, or z depending on their location: (you may recognize this as some FDTD code) Any ideas?
Thanks, Rob.
####################################/ # Update the interior of the mesh: # all vector H vector components #
## for az in range(0,nz): for ay in range(0,ny): for ax in range(0,nx):
dstore[ax,ay,0:nz]=Bx[ax,ay,0:nz]
Bx[ax,ay,0:nz] = Bx[ax,ay,0:nz] * C1[0:nz] + ( ( (Ey[ax,ay,1:(nz+1)]-Ey[ax,ay,0:nz] ) / dz - (Ez[ax,ay+1,0:nz]-Ez[ax,ay,0:nz]) / dy ) * C2[0:nz] )
Hx[ax,ay,0:nz]= Hx[ax,ay,0:nz] * C3[ay] + ( ( Bx[ax,ay,0:nz] * C5[ax] - dstore[ax,ay,0:nz] * C6[ax] ) * C4h[ay] )
dstore[ax,ay,0:nz]=By[ax,ay,0:nz]
By[ax,ay,0:nz] = By[ax,ay,0:nz] * C1[ax] + ( ( (Ez[ax+1,ay,0:nz]-Ez[ax,ay,0:nz]) / dx - (Ex[ax,ay,1:(nz+1)]-Ex[ax,ay,0:nz]) / dz ) * C2[ax] )
Hy[ax,ay,0:nz]= Hy[ax,ay,0:nz] * C3[0:nz] + ( ( By[ax,ay,0:nz] * C5[ay] - dstore[ax,ay,0:nz] * C6[ay] ) * C4h[0:nz] )
dstore[ax,ay,0:nz]=Bz[ax,ay,0:nz]
Bz[ax,ay,0:nz] = Bz[ax,ay,0:nz] * C1[ay] + ( ( (Ex[ax,ay+1,0:nz]-Ex[ax,ay,0:nz] ) / dy - (Ey[ax+1,ay,0:nz]-Ey[ax,ay,0:nz] ) / dx ) * C2[ay] )
Hz[ax,ay,0:nz]= Hz[ax,ay,0:nz] * C3[ax] + ( ( Bz[ax,ay,0:nz] * C5[0:nz] - dstore[ax,ay,0:nz] * C6[0:nz] ) * C4h[ax] )
-- The Numeric Python EM Project
www.members.home.net/europax
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- The Numeric Python EM Project www.members.home.net/europax