On 10/11/11 9:14 PM, Akshay Srinivasan wrote:
> Thank you for all the replies and suggestions. I guess I have to be
> necessarily vague, since I haven't really done anything on this front
> yet.
>
> I intend to have the callback function for ODEPACK - for the vector
> field - residing in lisp. Using CFFI to do this seemed to work well. I
> wouldn't want to have code in C/Fortran if I can help it.
>
> I tried using tranlate_file to convert something like this:
> --
> L(t, q, q1) := block([theta_1, theta_2, thetadot_1, thetadot_2, L],
> theta_1: q[1][1],
> theta_2: q[2][1],
> thetadot_1: q1[1][1],
> thetadot_2: q1[2][1],
> L: thetadot_2^2/2. + thetadot_1^2 + thetadot_1 * thetadot_2 *
> cos(theta_1 - t\
> heta_2) - 2 * sin(theta_1) -sin(theta_2),
> return(L))$
> --
> The translated code seems to have a lot of fluff; not something I'd
> use for numerical stuff - I could of course be doing it wrong. I
> didn't of course, use mode_declare while doing this. I'd be very
> skittish when passing something like this through - unedited- to any
> numerical code, especially so because the ODEs I need to solve are
> inturn passed on to an optimisation routine; so efficient numerics is
> something that is very much desired.
Of course the translated code is pretty weird because it has to handle
symbolic as well as numeric results. mode_declare will help, but I
don't think it would be quite the same as if you wrote an equivalent
lisp routine by hand. And passing such a function to ODEPACK via CFFI
can produce some really interesting results (corrupted memory, crashes,
etc.) if the function decides to return a symbolic value instead of a
numeric value for some corner case you forgot about.
And if the recent thread about colnew is any indication, the maxima
function basically limits how fast you can go anyway. If efficiency is
really that important, then translating the maxima function to C/Fortran
is the way to go. If you can deal with moderate efficiency, then maxima
might be ok.
Ray
who has occasionally thought about creating a maxima interface to the
f2cl version of odepack