Before I begin, I'd like to thank you in advance for any help I get with this question. I'm currently working with some heavy computation and decided to cython-ize my code. Because of what I'm doing in my math research, I will need to make MILLIONS of calls to pretty high level complex functions such as gamma, eta, and the list goes on. I've gotten stuck with a curiosity concerning the MPComplexNumber and the ComplexNumber types in sage.
I would like to make a function, f, which takes sage ComplexNumber types and does something with it. In the end, I'd like to return a sage ComplexNumber type. Should I use MPComplexNumber so that within the function in order to use the GNU mpc library or would it be better to use the mpfr library that is given to me by ComplexNumber and use Sage directly? In other words, would it be better for me to use mpc to square a complex number or would it be better for me to just square the number using the built-in sage code that does it with MPFR? I tend to believe that it would be best for me to use MPComplexNumbers and directly use GNU mpc. If I'm right, how do I convert MPComplexNumber into a ComplexNumber in cython? How do I initialize a variable in cython with the type MPComplexNumber? I am quite the novice in cython. The last question I have concerns weather I should just install the mpfr and mpc libraries, and use the header file directly. Would this result in faster computation? Below is a code snippet of an example of what I'm trying to do... Should I: from sage.rings.complex_number cimport ComplexNumber def Square(ComplexNumber x): return x^2 or should I use the following pseudo-code: #IMPORT GNU MPC USING mpc.h from sage.rings.complex_number cimport ComplexNumber def Square(ComplexNumber x): Square The number using mpc, by extracting the real and imaginary parts Convert back to ComplexNumber type (if so..how?) or should I: from sage.rings.complex_mpc cimport MPComplexNumber from sage.rings.complex_number cimport ComplexNumber def Square(ComplexNumber x): Initialize MPComplexNumber variable Extract the real and imaginary part of x, make them have type mpfr_t square the result using mpc's multiply function Build the ComplexNumber from the real and imaginary parts again...(again, if so...how?) Very sorry if I'm not making a lot of sense. Thank you for any help! -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.