[R-sig-dyn-mod] Jacobian and lsodes()

Daniel Kaschek daniel.kaschek at physik.uni-freiburg.de
Wed Mar 11 22:53:00 CET 2015


Hi everybody,

I use lsodes() with compiled code and set sparsetype = "sparseusr" in
combination with "inz". (I had a case where the ODE solution based on
the automatic computation of the jacobian structure was just wrong). The
issue is indeed solved by supplying the correct matrix "inz".

However, there might by a minor bug in deSolve v1.11. The code complains
that "inz" should be orderd by the row number (first column, according
to the help page). Instead, "inz" should be ordered by the second
column, i.e. by column number. Furthermore, the length of the real work
array "lrw" is generally estimated too small by the code. The following
formula, taken from the documentation of the FORTRAN code of lsodes
works for me:

20 + (2 + 1./lenrat)*nnz + (11 + 9./lenrat)*neq

with lanrat = 1, nnz = number of non-zero elements = dim(inz)[1] and neq
= number of equations.

Cheers,
Daniel



More information about the R-sig-dynamic-models mailing list