Hi all,
Thank you for your replies ... my question was initially unclear in
that I knew that using normal slicing would do the trick, but it was
rather a list of indices that couldn't be represented as a slice that
was bugging me. Luckily, Robert's solution solves this problem for
the gene
Steve Lianoglou wrote:
> ===
> import numpy as N
> mat = N.zeros((10,10))
> rows = [0,1,2]
> cols = [4,5,6]
>
> for row in rows:
> mat[row,cols] += 1
>
>
>
> I found something on the lists from a few years back that was in
> reference to numeric or numarray that suggested doing some g
On 1/29/07, Steve Lianoglou <[EMAIL PROTECTED]> wrote:
> For example, say I have a 10x10 array and only want to add some
> number to the elements in the submatrix that consists of the [0,1,2]
> th rows, and [4,5,6]th colums.
Here's one way to do it:
i,j = N.mgrid[0:3,4:7]
mat[i,j] += 1
__
How about
mat[0:3, 4:7] += 1
-Sebastian
On 1/29/07, Steve Lianoglou <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I was just curious what the "correct" (fast) way to select and alter
> > a submatrix.
> >
> > For example, say I have a 10x10 array and only want to add some
> > number to the elements
How about
mat[0:3, 4:7] += 1
-Sebastian
On 1/29/07, Steve Lianoglou <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was just curious what the "correct" (fast) way to select and alter
> a submatrix.
>
> For example, say I have a 10x10 array and only want to add some
> number to the elements in the submatr
Hi,
I was just curious what the "correct" (fast) way to select and alter
a submatrix.
For example, say I have a 10x10 array and only want to add some
number to the elements in the submatrix that consists of the [0,1,2]
th rows, and [4,5,6]th colums.
You can imagine that those rows/cols sele