I need to write to arbitrary portions of an array.  If I know they are
both one-dimensional, then I can do something like:

cdef void func(self, double *x, double *out, Py_ssize_t i=0):
   out[i] = x[i] + 1
   out[i+1] = x[i+1] + 2

What I'd really like to do is pointer arithmetic,

cdef void func(self, double *x, double *out):
   *out = *x + 1
   *(out+1) = *(x+1) + 2

Here, "out" could also be a two-dimensional array and func() is
writing only to a particular row of the matrix.  Ideally, I'd like to
have one function that can handle when "x" and "out" point to data of
arbitrary dimensions as func() doesn't care about the dimension.  How
can I accomplish this?  Do I have to write this in C and then do a
"cdef extern from ..." or can it be done in Cython?
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to