ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 Jun 2011 12:23:13 +0200Generation of optimized Fortran code?https://ask.sagemath.org/question/8134/generation-of-optimized-fortran-code/Hey All,
Is it possible to use Sage to generate Fortran code from its expressions which is optimized?
I'm looking for an OSS alternative to the CodeGeneration package of Maple.
I came across a discussion about it from 2008 where it was said that it is a planned feature but I didn't manage to find anything newer about that.
Many thanks,
OmriWed, 08 Jun 2011 10:07:25 +0200https://ask.sagemath.org/question/8134/generation-of-optimized-fortran-code/Answer by kcrisman for <p>Hey All,</p>
<p>Is it possible to use Sage to generate Fortran code from its expressions which is optimized?
I'm looking for an OSS alternative to the CodeGeneration package of Maple. </p>
<p>I came across a discussion about it from 2008 where it was said that it is a planned feature but I didn't manage to find anything newer about that.</p>
<p>Many thanks,
Omri</p>
https://ask.sagemath.org/question/8134/generation-of-optimized-fortran-code/?answer=12424#post-id-12424I don't think so.
However, [Cython](http://cython.org/) might be just as good for you. It will generate C code based on your Sage code, compile it on the fly, and then you have a C program to use.
Some links:
- [Marshall Hampton's intro to Cython in Sage](http://openwetware.org/wiki/Open_writing_projects/Sage_and_cython_a_brief_introduction#Cython)
- [A more technical developer guide to using Cython in Sage files](http://www.sagemath.org/doc/developer/coding_in_cython.html)Wed, 08 Jun 2011 10:58:07 +0200https://ask.sagemath.org/question/8134/generation-of-optimized-fortran-code/?answer=12424#post-id-12424Comment by Omri for <p>I don't think so.</p>
<p>However, <a href="http://cython.org/">Cython</a> might be just as good for you. It will generate C code based on your Sage code, compile it on the fly, and then you have a C program to use. </p>
<p>Some links:</p>
<ul>
<li><a href="http://openwetware.org/wiki/Open_writing_projects/Sage_and_cython_a_brief_introduction#Cython">Marshall Hampton's intro to Cython in Sage</a></li>
<li><a href="http://www.sagemath.org/doc/developer/coding_in_cython.html">A more technical developer guide to using Cython in Sage files</a></li>
</ul>
https://ask.sagemath.org/question/8134/generation-of-optimized-fortran-code/?comment=21606#post-id-21606Thanks for the quick reply! The reason why I need it is to include it into an already bigger program written in Fortran (I wouldn't have chosen it myself) and I need an optimized code (i.e - many declared variables which contain steps of the calculation, exactly like Maple can produce).Wed, 08 Jun 2011 12:23:13 +0200https://ask.sagemath.org/question/8134/generation-of-optimized-fortran-code/?comment=21606#post-id-21606