Hi,

> I've now got a bit more time.
>
> I don't know how things are going at Sage days; but if you're still up
> for it, and e.g. Robert has an hour for you later on, I could spend some
> time posting an outline for how I'd go about the (2) project and then
> perhaps Robert could mentor a bit from there.
>
> I.e. the goal would be to allow for instance
>
> cdef np.ndarray[int, ndim=3] arr1 = ..., arr2
> for idx in cython.iterate(arr1, arr2):
>     arr1[idx] = arr1[idx] + arr2[idx]
>
> where idx is some "psuedo-tuple" of ndim length, and have it compile to
> a native loop.

I have been swamped the past week trying to get a research project
back on track, so unfortunately I haven't been able to take advantage
of sage days here :-(.  Bummer.  However, I still want to help out
with this and take up your mentoring offer and work on this.  To be honest,
I probably won't have a significant chunk of time, though, until after June 5.

I'm wondering, though, if it would be better to do this in two stages.
 It seems like having a type, say index_tuple, which the user can
define and then manipulate.  It seems we would be doing this anyway,
and explicitly exposing it to the user could have use cases.  In the C
code, it seems like it'd just be an int array.

e.g.

cdef size_t i
cdef index_tuple[2] idx
cdef ndarray[double, ndim=2] A

idx[0] = 0

for 0 <= i < A.shape[1]:
    idx[1] = i
    A[idx] = 1


Obviously this is a simple example, but there might easily be other
use cases, such as passing indices to a function, etc..

What do you think?

--Hoyt

++++++++++++++++++++++++++++++++++++++++++++++++
+ Hoyt Koepke
+ University of Washington Department of Statistics
+ http://www.stat.washington.edu/~hoytak/
+ [email protected]
++++++++++++++++++++++++++++++++++++++++++
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to