On Jun 16, 2009, at 7:21 AM, Ethan Van Andel wrote:

> I'm transferring some code to Cython to speed things up.
> In my SAGE/python code, I have a function which takes as one of its
> arguments, a function G.
> I then declare a series of intermediate functions like this:
>
>     Gprime = derivative(G)
>     Hconj(t) = 1/(2*pi*i)*(Gprime(t)/abs(Gprime(t))/(a-G 
> (t))).conjugate
> ()
>     A(t,s) = 1/(2*pi*i)*(Gprime(s)/abs(Gprime(s))/(G(s)-G(t))-(Gprime
> (t)/abs(Gprime(t))/(G(s)-G(t))).conjugate())
>     K(t,s) = sqrt(abs(Gprime(s))) * A(t,s) * sqrt(abs(Gprime(t)))
>     g(t) = sqrt(abs(Gprime(t)))*Hconj(t)
>
> After GPrime, I have no idea how to transfer this code into Cython.
> The f(x) syntax doesn't work, and neither does lambda x:  How can I
> solve this?

Just transferring code like this to Cython is not going to speed  
things up. The first thing to ask yourself is whether or not your  
time is being eaten up in your code, or in code that you're calling.  
In this case, the code you're calling is the slow(er) part, so you're  
not going to see a benefit calling it from Cython over calling it  
from Python.

Cython can do wonders if, e.g., you have some loop where you're  
manipulating lots of small things (e.g. bits, ints, floats, etc.),  
need raw access to c types (e.g. mpz_t) and many other cases.

I'm not sure exactly what you're trying to do with this function, but  
if you want to do everything symbolically you it may just be slow.  
You could try approximating things with power series or looking into  
fast_callable.

- 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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to