On Mon, 19 Nov 2001, Martin Kahlert wrote: > Background: I did some timing and found > a.collect! {|x| x+1} > to be twice as fast as > for i in 0 ... a.length > a[i] += 1 > end There's this class called NArray specialized in numeric computations. I did some timing and found that NArray#collect! is 30% slower than Array#collect!. However NArray#add!(1), which is equivalent, is 140 times faster. > I want to do something like that: > a = Array.new(1000000, 1) > b = Array.new(1000000, 2) > c = Array.new(1000000) > for i in 0 ... a.length > c[i] = a[i] + b[i] > end a=NArray.int(1000000).fill!(1) b=NArray.int(1000000).fill!(2) c=a+b (computes in half a second here.) ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju