On Sun, Feb 2, 2014 at 2:58 PM, Mads Ipsen <mads.ip...@gmail.com> wrote:

> Since atoms [1,2,3,7,8] have been
> deleted, the remaining atoms with indices larger than the deleted atoms
> must be decremented.
>

Let

>>> x
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])

and

>>> i = [1, 0, 2]

Create a shape of x matrix with 1's at (k, i[k]) and zeros elsewhere
>>> b = zeros_like(x)
>>> b.put(i + arange(3)*4 + 1, 1)  # there must be a simpler way

>>> x - b.cumsum(1)
array([[ 0,  1,  1,  2],
       [ 4,  4,  5,  6],
       [ 8,  9, 10, 10]])

seems to be the result you want.
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to