(reply in line)
On Sat, Mar 17, 2012 at 13:39, Akshay Srinivasan <akshaysrinivasan at gmail.com
> wrote:
> Yes it will probably be much easier (not to mention far more elegant)
> to write the whole thing in Maxima. At the time I wrote the thing, I
> hardly knew any lisp (much less about the internals of Maxima), so the
> whole thing was hacked up to work.
>
You shouldn't need to know anything about either Lisp or the internals of
Maxima for the mathematical part -- you can write in the Maxima language
itself, and then simply output the expressions in C syntax. You will need
to use Lisp if you need to fiddle the "fortran" module (which may not even
be necessary, since Fortran and C syntax for mathematical expressions (as
opposed to procedural code) are almost identical).
The purpose of the project is to actually generate the C code; I need
> to get the jacobian of the vector field governing the dynamics, which
> is feasible only using AD for large systems.
>
The way I'd do this is to generate the expressions then simply *output*
them in C format. For mathematical expressions, I think Fortran and C
syntax are the same, so you can use the Fortran function. If that doesn't
work, you may need to write a small variant of the Fortran package
specifically for C. That would be generally useful, and would still be
easier than doing this via string processing.
> I have a vague idea of what I should write in Maxima (lisp module), I
> think I have to write something like fortra.lisp which generates C
> compatible expressions. I will then have to then format them into a
> file-stream which should be easy to do because the existing parser is
> in lisp anyway.
>
Exactly. The Maxima-to-C component should not be specific to Lagrange.
But you should not start from scratch. fortra.lisp is 95% of what you
need.
-s