Even better :
import numarray
m = numarray.arange(16,shape=(4,4))
numarray.sum(m)
array([24, 28, 32, 36])
numarray.sum(axis=1)
array([ 6, 22, 38, 54])
Pierre
Kent Johnson a écrit :
Kent Johnson wrote:
Liam Clarke wrote:
There's a specific package for arrays
http://www.stsci.edu/resources/software_h
Kent Johnson wrote:
Liam Clarke wrote:
There's a specific package for arrays
http://www.stsci.edu/resources/software_hardware/numarray
that implements array mathematics. I use it for pixel map manipulation
in pygame, so it's relatively fast.
Here is one way to do what you want using numarray:
Here
Liam Clarke wrote:
There's a specific package for arrays
http://www.stsci.edu/resources/software_hardware/numarray
that implements array mathematics. I use it for pixel map manipulation
in pygame, so it's relatively fast.
Here is one way to do what you want using numarray:
>>> import numarray
Cr
Gregor Lingl wrote:
Hi all of you,
I'm representing a 4x4 matrix as a 16-element list, e.g.
m=range(16)
first 4 elements first row, second four elements second row etc.
I want to sum rows and columns like
i-th row:
sum(m[4*i:4*i+4])
and ith column:
sum(m[i::4])
This seems to be slow because of the
There's a specific package for arrays
http://www.stsci.edu/resources/software_hardware/numarray
that implements array mathematics. I use it for pixel map manipulation
in pygame, so it's relatively fast.
On Mon, 31 Jan 2005 19:09:59 +0100, Gregor Lingl <[EMAIL PROTECTED]> wrote:
> Hi all of you
Hi all of you,
I'm representing a 4x4 matrix as a 16-element list, e.g.
m=range(16)
first 4 elements first row, second four elements second row etc.
I want to sum rows and columns like
i-th row:
sum(m[4*i:4*i+4])
and ith column:
sum(m[i::4])
This seems to be slow because of the formation of the sli