[SciPy-User] polylogarithm?

Johann Cohen-Tanugi johann.cohentanugi@gmail....
Mon Sep 19 08:42:52 CDT 2011

hi Ralph and Fredrik, thanks for the feedback.
I can certainly try to teach myself a bit of cython, and to write these 
special functions for scipy (I would probably have to start with Riemann 
zeta function), but it will take some time :)
For now find attached a first cython version of a snipet of the mpmath 
code, completely trimmed to be used in only one case (polylog_series). 
The timing results are :

In [4]: %timeit polylog.polylog(2,0.5)
10000 loops, best of 3: 29.2 us per loop

In [5]: %timeit polylog_cy.polylog(2,0.5)
100000 loops, best of 3: 14.3 us per loop

In [7]: %timeit mpmath.fp.polylog(2,0.5)
10000 loops, best of 3: 36.5 us per loop

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.


On 09/16/2011 07:11 PM, Ralf Gommers wrote:
> On Thu, Sep 15, 2011 at 8:09 AM, Johann Cohen-Tanugi 
> <johann.cohentanugi@gmail.com <mailto:johann.cohentanugi@gmail.com>> 
> wrote:
>     hi there, any chance for a polylog implementation in scipy.special? I
>     know it is there in mpmath, but I thought I would ask anyway.
> If someone (you?) contributes a patch, that would be a great addition 
> to scipy.special imho. mpmath is nice, but it doesn't understand 
> ndarrays and is way too slow when you want to use the polylog for 
> something like fitting Bose-Einstein or Fermi-Dirac distributions.
> It looks like the implementation in mpmath is quite clean and could 
> provide a starting point for a Cython/C version.
> Ralf
> -- 
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20110919/3055ba5f/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: polylog_cy.pyx
Url: http://mail.scipy.org/pipermail/scipy-user/attachments/20110919/3055ba5f/attachment.pl 

More information about the SciPy-User mailing list