On 08/10/06, Robert Kern <[EMAIL PROTECTED]> wrote:
> Bill Baxter wrote:
> > Yes, that'd be
> >    a[b] += c
>
> No, I'm afraid that fancy indexing does not do the loop that you are thinking 
> it
> would (and for reasons that we've discussed previously on this list, *can't* 
> do
> that loop). That statement reduces to something like the following:

So the question remains, is there a for-loop-free way to do this?

(This, specifically, is:
for i in range(len(b)):
    a[b[i]]+=c[i]
where b[i] may contain repetitions.)

I didn't find one, but came to the conclusion that for loops are not
necessarily slower than fancy indexing, so the way to do this one is
just to use a for loop.

A. M. Archibald

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to