Manuel Metz wrote:
> Chris Withers wrote:
>> Hi All,
>>
>> 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?
>>
>> My only solution so far is this:
>>
>> sum = arrays[0]
>> for a in arrays[1:]:
>>sum +=
use the "axis" argument in sum.
L.
On Tue, Mar 18, 2008 at 4:27 PM, Chris Withers <[EMAIL PROTECTED]>
wrote:
> Keith Goodman wrote:
> >>> sum(x)
> >
> > matrix([[ 1.15063313],
> > [ 0.8841396 ],
> > [ 1.7370669 ]])
>
> When these are arrays, I just get a single number sum back...
Chris Withers wrote:
> Hi All,
>
> 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?
>
> My only solution so far is this:
>
> sum = arrays[0]
> for a in arrays[1:]:
>sum += a
>
> ...which is ugly :-S
Keith Goodman wrote:
>>> sum(x)
>
> matrix([[ 1.15063313],
> [ 0.8841396 ],
> [ 1.7370669 ]])
When these are arrays, I just get a single number sum back...
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
_
On Tue, Mar 18, 2008 at 9:12 AM, Chris Withers <[EMAIL PROTECTED]>
wrote:
> Hi All,
>
> 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?
>
> My only solution so far is this:
>
> sum = arrays[0]
> for a in arr
On Tue, Mar 18, 2008 at 8:12 AM, Chris Withers <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> 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?
>
> My only solution so far is this:
>
> sum = arrays[0]
> for a i
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.
Hi All,
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?
My only solution so far is this:
sum = arrays[0]
for a in arrays[1:]:
sum += a
...which is ugly :-S
cheers,
Chris
--
Simplistix - Content Manageme