On Oct 4, 2009, at 10:07 AM, mark mcclure wrote:

> I'm investigating the complex dynamics of Airy functions with
> Python and I wonder if I can speed up the process significantly
> with Cython.  I've successfully sped up the code by about 50%
> but I might expect much greater speed improvement.  I'm
> guessing the problem is that Cython can't deal with SciPy's
> complex valued airy function.
>   1) Am I likely correct that the airy function is the
>   culprit?

It's certainly possible, but see the comments below.

>   2) If so, is it likely that Cython will be eventually
>   expanded to include the complex valued special functions
>   of SciPy?

No, but you might want to call these functions in SciPy directly as C  
functions. (You'd have to look up the SciPy headers to see what to  
call them.)

> If you're interested in the specific code, you can view it
> as a Sage notebook here:
> http://sagenb.org/home/pub/1013/

http://sagenb.org/home/pub/1013/cells/1/ 
__home_sage_sagenb_sage_notebook_worksheets_mcmcclur_8_code_sage7_spyx.h 
tml

Lines 27, 31, 33:

You're calling abs as a Python function. Use cabs, which can be  
imported as

cdef extern from "complex.h":
     double cabs(double complex)

Line 24-25 has a huge amount of Cython code in it. complex(...) and  
float(...) create *Python* complex and float objects. Click on those  
lines to see the insane amount of Python going on. Try writing

z =(((xmax - xmin)*j)/resRe + xmin) + ((ymax - ymin)*k)/resIm + ymin)  
* 1.0j

instead. You should be getting much more than a 50% speedup.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to