[Numpy-discussion] Writing new ufuncs

Anne Archibald peridot.faceted@gmail....
Sun May 11 21:50:29 CDT 2008


2008/5/11 Robert Kern <robert.kern@gmail.com>:

> Basically, you need 3 arrays: functions implementing the type-specific
> inner loops, void* extra data to pass to these functions, and an array
> of arrays containing the type signatures of the ufunc. In numpy, we
> already have generic implementations of the loop functions for common
> combinations of types. In your case, for a binary function taking two
> doubles and returning a double, we have PyUFunc_dd_d(). As its extra
> void* data, it takes a function pointer that actually implements the
> element-wise operation. So lets start making the arrays:

Great! Thanks!

Is it possible to provide a specialized implementation of reduce()?
(Since reduce() can be implemented more efficiently than doing it
pairwise.)

>            PyUFunc_None,  // The identity element for reduction.
>                           // No good one to use for this function,
>                           // unfortunately.

Is it safe to use minus infinity, or is this going to give people all
kinds of warnings if they have seterr() set?

Anne


More information about the Numpy-discussion mailing list