or better yet, which pow function is numpy using?
On Tue, Sep 29, 2009 at 6:21 PM, Chris Colbert <[email protected]> wrote: > No, the python ** gets translated to a pow statement by cython. > > I think the issue is that for some reason, i'm getting stuck in the > gcc slow pow function.... > > if i let e2 and e1 be 1 and replace f**2 (which would call pow) with f*f, > > my execution time drops to this: > 10000 loops, best of 3: 108 µs per loop > > over 6x improvement just by avoid a few measly pow statements... > anyone know why i'm stuck in slowpow? > > > > On Tue, Sep 29, 2009 at 6:15 PM, Sturla Molden <[email protected]> wrote: >> Sturla Molden skrev: >>> Chris Colbert skrev: >>> >>>> and within that loop it is these statements that take the bulk of the time: >>>> >>>> F = ((f1**2)**(1/e2) + (f2**2)**(1/e2))**(e2/e1) + (f3**2)**(1/e1) >>>> >>>> temperr = (C4 * (F**(e1) - 1))**2 >>>> >>>> and replacing the powers with serial multiplications don't really help >>>> any... >>>> >>>> >>> >>> Does this help? >>> >>> cdef extern from "math.h": >>> double pow(double, double) >>> >>> F = pow(pow((f1*f1),(1/e2)) + pow((f2*f2),(1/e2)),(e2/e1)) \ >>> + pow((f3*f3),(1/e1)) >>> >>> >> cdef double tmp >> >> tmp = C4 * (pow(F,e1) - 1) >> >> temperr = tmp*tmp >> >> >> >> >> _______________________________________________ >> Cython-dev mailing list >> [email protected] >> http://codespeak.net/mailman/listinfo/cython-dev >> > _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
