[Numpy-discussion] Questions on GUFUNCS

Jaime Fernández del Río jaime.frio@gmail....
Mon Aug 5 00:49:20 CDT 2013


I have spent the last couple of weeks playing around with GUFUNCS, and am
literally blown away by the power that a C compiler and NumPy put at the
tip of my fingers! I still have many questions, but the following ones are
the most pressing in my current state of amazed ignorance:

1. **The data argument to the GUFUNC loop function** Where in the source
code can I find example of it's use? I remember reading that many UFUNCS
are just the same looping, with a pointer to a different function passed in
this argument. I think I understand the idea, but would like to see it

2. **Is there a place for initializations?** I have a GUFNC in mind that
will need, in each iteration, a small dynamically allocated array, which
can be reused by other iterations. Rather than malloc-ing it for every
loop, I am thinking of wrapping the GUFUNC in a Python interface that
creates a numpy array for this, and passes it down as another parameter. Is
there an easy way to keep this all bundled in the C code, e.g. by defining
some initialization code to be run before doing any looping?

3. **What happens with missing types?** Say I only register a function that
takes unsigned ints. What happens if I try to call it with ints? I figure
it will complain, but not if it is the other way around and the type can be
safely casted. Is that really so? Can this behavior be in any way
configured? Is it documented anywhere?

4. **.src files** The prime example of GUFUNC implementation I have found
is "umath_linalg.c.src" Correct me if I am wrong, but this is simply C code
plus the special syntax to generate multiple versions of the same functions
changing only a few types and names, using the @tag@ syntax. While the way
it works seems clear, I had never seen this done like this before. Is this
standard or just a numpy thing? How do you parse and expand this code to
its full glory before compiling?



( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130804/ed3ec110/attachment.html 

More information about the NumPy-Discussion mailing list