Fri 12 Nov 2010 08:11:41 AM UTC, original submission:
With the BDF method, dlsode.f is able to approximate only a diagonal or banded Jacobian (Method flag: 23, 25) and to use only a banded part of a user supplied Jacobian (Method flag: 24). This is useful for efficiency. But as yet lsode offers no interface to this. The attached patch changes this.
1. In liboctave/LSODE-opts.in, options "jacobian type" (values: "full" (default), "banded", "diagonal"), "lower jacobian subdiagonals", and "upper jacobian subdiagonals" (for use with a "jacobian type" of "banded") are introduced.
2. In liboctave/LSODE.cc, the corresponding values of method_flag are set and iwork(0) and iwork(1) are set to "lower jacobian subdiagonals" and "upper jacobian subdiagonals", respectively. Since except for method_flag == 24 the user-supplied Jacobian must (according to dlsode.f) ignore the arguments "lower jacobian subdiagonals" (ML) and "upper jacobian subdiagonals" (MU), a new file-scope variable tells lsode_j when to ignore them. With method_flag == 24, lsode_j fills only the required subdiagonals of the user-supplied Jacobian into the allocated memory as specified by dlsode.f.
I think the actual user-programmed Jacobian function need not be passed ML and MU (this would necessitate much more changes), since the user knows which "lower jacobian subdiagonals" and "upper jacobian subdiagonals" he sets for lsode and can provide these to his Jacobian-function himself, if desired.
For testing the new features and seeing the time-savings, a function 'odetest' returning a structure with two test-problems and a script 'odetest_script' which uses this function are also attached.
Note: It may be necessary to fix bug #31623 before testing (I had to do it for me), for 'lsode' to be able to see settings changed with 'lsode_options'. I'm not sure whether bug #31623 affects every system.
|