Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 2011-02-08 12:45:31 -0500

DSM gravatar image

If I understand you, then you're looking for the equivalent of maple's CodeGeneration package, which nicely turns Maple functions into fortran or C code which you can then include in your own code (done this many times myself). Unfortunately I couldn't find what you're looking for.

(1) I tried looking at the existing expression conversions (for sympy, maxima, etc.) but none of them seemed to need to do this.

(2) Apparently there are tricks to do it from maxima (using the "subst" command), but I couldn't get any of them to work, at least not via the Sage-Maxima interface. My Maxima-foo is pretty weak, though. Unfortunately Fortran has the "**" operator, so using maxima.fortran wouldn't help!

(3) I don't think Cython will be that useful here, because the C code that it generates is pretty messy, and parsing it to recover something that you could insert in a non-Cython C code -- though doable -- would be much harder and more error-prone than simply turning (a)^(b) into pow((a), (b)) in the first place!

This would be a very useful feature, though; doing algebra in a CAS and then moving it to code used to be one of the main things I used Maple for!

If I understand you, then you're looking for the equivalent of maple's CodeGeneration package, which nicely turns Maple functions into fortran or C code which you can then include in your own code (done this many times myself). Unfortunately I couldn't find what you're looking for.

(1) I tried looking at the existing expression conversions (for sympy, maxima, etc.) but none of them seemed to need to do this.

(2) Apparently there are tricks to do it from maxima (using the "subst" command), but I couldn't get any of them to work, at least not via the Sage-Maxima interface. My Maxima-foo is pretty weak, though. Unfortunately Fortran has the "**" operator, so using maxima.fortran wouldn't help!

(3) I don't think Cython will be that useful here, because the C code that it generates is pretty messy, and parsing it to recover something that you could insert in a non-Cython C code -- though doable -- would be much harder and more error-prone than simply turning (a)^(b) into pow((a), (b)) in the first place!

This would be a very useful feature, though; doing algebra in a CAS and then moving it to code used to be one of the main things I used Maple for!

for.

If I understand you, then you're looking for the equivalent of maple's CodeGeneration package, which nicely turns Maple functions into fortran or C code which you can then include in your own code (done this many times myself). Unfortunately I couldn't find what you're looking for.

(1) I tried looking at the existing expression conversions (for sympy, maxima, etc.) but none of them seemed to need to do this.

(2) Apparently there are tricks to do it from maxima (using the "subst" command), but I couldn't get any of them to work, at least not via the Sage-Maxima interface. My Maxima-foo Maxima-fu is pretty weak, though. Unfortunately Fortran has the "**" operator, so using maxima.fortran wouldn't help!

(3) I don't think Cython will be that useful here, because the C code that it generates is pretty messy, and parsing it to recover something that you could insert in a non-Cython C code -- though doable -- would be much harder and more error-prone than simply turning (a)^(b) into pow((a), (b)) in the first place!

This would be a very useful feature, though; doing algebra in a CAS and then moving it to code used to be one of the main things I used Maple for.