can this be made faster?
Charles R Harris
charlesr.harris at gmail.com
Mon Oct 9 15:14:52 CDT 2006
On 10/9/06, A. M. Archibald <peridot.faceted at gmail.com> wrote:
>
> > > > > c contains arbitray floats.
> > > > > essentially it is to compute class totals
> > > > > as in total[class[i]] += value[i]
>
> > > This seems like a rather common operation - I know I've needed it on
> > > at least two occasions - is it worth creating some sort of C
> > > implementation? What is the appropriate generalization?
> >
> > Some sort of indirect addressing infrastructure. But it looks like this
> > could be tricky to make safe, it would need to do bounds checking at the
> > least and would probably work best with a contiguous array as the
> target. I
> > could see some sort of low-level function called argassign(target,
> indirect
> > index, source) that could be used to build more complicated things in
> > python.
>
> If it were only assignment that was needed, fancy indexing could
> already handle it. The problem is that this is something that can't
> *quite* be done with the current fancy indexing infrastructure - every
> time an index comes up we want to add the value to what's there,
> rather than replacing it. I suppose histogram covers one major
> application; in fact if histogram allowed weightings ("count this
> point as -0.6") it would solve the OP's problem.
Sure, just add functions arg_addassign, etc., which means dest[ind[i]] +=
src[i], just as arg_assign would mean dest[ind[i]] = src[i]. If you covered
all the assign variants I think you could do most everything. Upper level
python routines could deal with shaping and such while the lower level
routines dealt with flat, contiguous arrays.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061009/dad25f07/attachment-0001.html
-------------- next part --------------
-------------------------------------------------------------------------
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
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list