On 10/19/2011 01:21 AM, Panagiotis Papasotiriou wrote:
> Anyway, both solutions suggested (the trick with mode declarations in lists,
> and the use of arrays instead of lists) seem to work. I had quite some
> progress by converting everything in array forms as well. However, I
> realized that I will need to replace all list operations with loops, which
> is something I honestly don't want to do. It reminds me implementing
> numerical methods in languages not appropriate for Mathematics, like C/C++,
> where the lack of decent matrix algebra support forces the user to use loops
> and nested loops for the simplest thing on Earth.
Yes, I understand your frustration here. It would be nice to be able to
simply say a+b with a and b both arrays and get back a new array
perhaps. One problem would be that lisp in general does not focus on
in-place modification of data structures. So if such a thing existed,
doing a+b would normally allocate a new array c that contained the
results of a and b just as it does with lists. It is trivially easy to
write a function "a+" which would do this
"a+"(a,b) := block([c:make_array(...)],...)
but this is not ideal either.
Simply having an adaptive stepsize improves speed significantly. I have
used the rk4 code to do some solutions of simple equations that required
tiny stepsizes and run times in the tens of minutes. It is written in
lisp I believe, and therefore compiled to machine code, so it is
actually doing a LOT of calculations. As you mentioned earlier, the
small step size is only needed usually for a small portion of the domain
so you have already doing a great service by creating an adaptive
stepsize algorithm. Please don't get discouraged because it is not
easily translated to ultra-fast code.