On 25 Nov 2013 08:14, "Daniele Nicolodi" <dan...@grinta.net> wrote:
>
> On 25/11/2013 17:03, Nathaniel Smith wrote:
> > On Mon, Nov 25, 2013 at 7:02 AM, Sebastien Bratieres
> > <sebastien...@gmail.com> wrote:
> >> Hi,
> >> I tried a performance comparison on a log-sum-exp function. I was
> >> disconcerted with bad performance in my Weave and Cython implementations.
> >> My IPython notebook is here:
> >> http://nbviewer.ipython.org/285184b4a808dfea7070 (sorry for the long Numba
> >> debug output which I don't know how to suppress). Cf the bottom for a recap.
> >> How can I speed up my Cython (and Weaver, in case you would know) versions ?
> >
> > BTW, this is also available as a function built-in to numpy --
> > np.logaddexp.reduce
>
> I'm not sure this is equivalent.
>
> Given that np.logaddexp() computes np.exp(np.log(x1) + np.log(x2)) I
I think you have the log and exp reversed, but yes, .reduce may not be as fast as special purpose functions. It does compute the same value, though (modulo rounding errors).
-n
function and the timings I obtain are radically different than yours,
with the Cython version being the fastest.