From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-12-01T14:41:40+09:00 Subject: Re: Numerical Ruby In article <20021201001712.48f6cb67.Olivier.Saut@gmm.insa-tlse.fr>, Olivier Saut wrote: >Hi all, > >I am now using Ruby to test my numerical schemes. Using Ruby for this >task was a real pleasure (I usually code in F90). The computations run >just fine but I would like to have a result a little faster. > >My code uses lots of loops as in the following example. > >def faraday >for y in 1..(maxY-1) > for z in 1..(maxZ-1) > @Bx[y,z]+=-(dt/dy)*(@Ez[y+1,z]-@Ez[y,z])+(dt/dz)*(@Ey[y,z+1]-@Ey[y,z]) > @By[y,z]+= - (dt/dz)*(@Ex[y,z+1]-@Ex[y,z]) > @Bz[y,z]+=(dt/dy)*(@Ex[y+1,z]-@Ex[y,z]) > end > end >end > >I am using NArray from Masahiro Tanaka >(http://www.ir.isas.ac.jp/~masa/ruby/index-e.html) to represent the >electromagnetic field. > >Is there any way to speed up this type of computations? (I am not sure >how a C extension could help in this case.) > >BTW, is there any trend to develop the use of Ruby in the field of >scientific computations (as it seems to be the case with Python)? There should be. Actually, there are a few folks out there that seems to be using Ruby in scientific computation. Phil -- "Or perhaps the truth is less interesting than the facts?" Amy Weiss (accusing theregister.co.uk of engaging in 'tabloid journalism') Senior VP, Communications Recording Industry Association of America