[Numpy-discussion] Arithmetic on arrays of pointers
Dan Goodman
dg.gmane@thesamovar....
Tue Apr 28 21:05:20 CDT 2009
Hi all,
I have a slightly strange idea for something I would like to do with
numpy which I guess probably doesn't exist, but I may be wrong. What I
want to do, essentially, is to have two arrays of equal size, say X and
Y, of pointers to doubles say. Then I want to do (in C notation) *x +=
*y for each x, y in X, Y. I'd like to write this in Python as X+=Y where
X and Y understand that they consist of arrays of pointers to doubles
and that it should do the arithmetic on the values pointed to. Now I can
do this in C easily enough, and integrate it with numpy via weave or
whatever (it only took a few lines using scipy.weave.inline), but it
would be really nice if something along these lines were already in
numpy or an extension of it already. Anyone know of anything like that
or had any experience with similar situations?
I'd also like to be able to take pointers and do pointer arithmetic too
(because I want to construct the 1D arrays X, Y above from values picked
from a variety of possible data structures, including dense and sparse
2D arrays, but in such a way that the code that uses these values
doesn't have to know where the values came from in these data
structures). Why? you might ask. Well, because I'm writing simulation
code which involves scheduling events in the future (simple events like
add a value to another value), but the library is supposed to be easily
extensible for people who don't know C so I want to make it as easy to
use as possible.
Well, that's a slightly underdefined problem, basically I just have a
vague idea that something like the above would be useful to me and I'm
looking for any ideas that might seem relevant.
Thanks in advance!
Dan
More information about the Numpy-discussion
mailing list