On Sun, 01 Dec 2002, Masahiro TANAKA <masa / ir.isas.ac.jp> wrote:

> Hi,
> 
> 
> If you use NArray, "writing without loop" is the way to speed up.
> Your 'faraday' method can be rewritten as:
> 
>   def faraday2
>     dt,dx,dy,dz = [1.0]*4
>     @Bx[1..-2,1..-2] += -(dt/dy)*(@Ez[2..-1,1..-2] - @Ez[1..-2,1..-2]) +
>     		         (dt/dz)*(@Ey[1..-2,2..-1] - @Ey[1..-2,1..-2])
>     @By[1..-2,1..-2] += -(dt/dz)*(@Ex[1..-2,2..-1] - @Ex[1..-2,1..-2])
>     @Bz[1..-2,1..-2] +=  (dt/dy)*(@Ex[2..-1,1..-2] - @Ex[1..-2,1..-2])
>   end
> 
> For 500x500 array, the result of benchmark on my machine is:
> 
>   with loop:    8.69 sec
>   without loop: 0.31 sec

Great that was exactly what I was hoping for. 

Thanks a lot!
			- Olivier