[SciPy-User] polylogarithm?

Pauli Virtanen pav@iki...
Mon Sep 19 08:55:24 CDT 2011


Mon, 19 Sep 2011 15:42:52 +0200, Johann Cohen-Tanugi wrote:
[clip]
> where the first one is the mpmath code without the mpmath ctx objects
> invoked, the second is the cython version, and the third is the mpmath
> native version (0.17). Before I dive into cython management of arrays in
> order for polylog to accept input arrays, I would appreciate feedback on
> where to look for potential further improvements using cython, if any,
> on a simplistic script as this one.

In short:

- Check the annotated HTML output from "cython -a".
  The name of the game is to make things less yellow.

- Add cdef type for all variables (removes PyObject boxing).
  This will be the main source of speed gains.

- Sprinkle in @cython.cdivision(True)

- Use "from libc.math cimport abs"

- Take a look at lambertw.pyx in scipy.special.
  It shows you how to make the function an ufunc.

-- 
Pauli Virtanen



More information about the SciPy-User mailing list