[Numpy-discussion] Possible to use numexpr with user made ufuncs/scipy ufuncs?
Sat Jun 26 11:51:52 CDT 2010
2010/6/26 Pauli Virtanen <email@example.com>
> la, 2010-06-26 kello 14:24 +0200, Francesc Alted kirjoitti:
> > Yeah, you need to explicitly code the support for new functions in
> > But another possibility, more doable, would be to code the scipy.special
> > functions by using numexpr as a computing back-end.
> Would it be possible to add generic support for user-supplied ufuncs
> into numexpr? This would maybe be more of a convenience feature than a
> speed improvement, although perhaps some speed could be gained by
> evaluating ufuncs per-block.
Well, I'd say that this support can be faked in numexpr easily. For
example, if one want to compute a certain ufunc called, say, sincos(x)
defined as sin(cos(x)) (okay, that's very simple, but it will suffice for
demonstration purposes), he can express that as sincos = "sin(cos(%s))", and
then use it in a more complex expression like:
"%s+1*cos(%s)" % (sincos % 'x', 'y')
that will be expanded as:
Of course, this is a bit crude, but I'd say that's more than enough for
allowing the evaluation of moderately complex expressions.
Having said this, one can always think in setting up a wrapper for doing a
similar thing more elegantly (although I'm not sure if this is worth the
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion