On Tue, 18 Mar 2008, Chris Withers apparently wrote:
> Say I have an aribtary number of arrays:
> arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] 
> How can I sum these all together? 

Try N.sum(arrays,axis=0).

But must they be in a list?
An array of arrays (i.e., 2d array) is easy to sum.

> My only solution so far is this:
> sum = arrays[0] 
> for a in arrays[1:]:
>    sum += a
> ...which is ugly :-S 

And changes the first array!

Cheers,
Alan Isaac



_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to