[R-sig-dyn-mod] Jacobian in compiled code

Daniel Kaschek daniel.kaschek at physik.uni-freiburg.de
Thu Apr 9 11:30:12 CEST 2015


Dear John,

you can have a look at my package "cOde" on CRAN. The purpose of this 
package is to autogenerate the C code for an ODE, including a small 
wrapper function to use it together with ode() from deSolve. There is 
also the functionality to generate the jacobian function.

To my knowledge, the only case where the jacobian is really required in 
compiled code is bvptwp() in the bvpSolve package (this is why I 
implemented it). For the solvers from deSolve you can just omit the 
jacobian, i.e. you don't have to return 0 values. I have played around 
with jacobians in compiled code and the lsodes() solver. I could not 
find a single case where the specified jacobian could speed up 
calculations.

Best regards,
Daniel


Daniel Kaschek
Institute of Physics
Freiburg University

On Do, Apr 9, 2015 at 2:55 , John Harrold <john.m.harrold at gmail.com> 
wrote:
> Hello,
> 
> I'll start by saying that I'm relatively new to R. I'm trying to 
> solve ODEs
> using compiled code. I'm generating automation tools (creating the 
> same
> system in several formats including R-scrpt and the C code needed for 
> R to
> run compiled code, and right now it's not feasible for me to generate 
> the
> Jacobian right now. As I understand it, the Jacobian is used by some
> solvers but I don't believe it's required (at least not by most of 
> them).
> Is it possible to write compiled code with only the ODEs specified? 
> I've
> done this in Matlab with C and their mex functionality. If it's 
> possible,
> can someone briefly describe what I'd have to change in one of the 
> examples
> in the vignette on writing code in compiled languages:
> 
> R Package deSolve, Writing Code in Compiled Languages
> <http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCIQFjAA&url=http%3A%2F%2Fcran.r-project.org%2Fweb%2Fpackages%2FdeSolve%2Fvignettes%2FcompiledCode.pdf&ei=jcwlVfbbNoT8oAT4_4HQAw&usg=AFQjCNFvPvW2Il_E8OGhkB-AiZVFrouHmw&sig2=qlAopNEfWAq4PhQt_bmN7w&bvm=bv.90491159,d.cGU>
> 
> Specifically do I need the 'jac' function (from the C examples). Do I
> delete it? To I have it return a specific value like 0.
> 
> Thanks
> John
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

	[[alternative HTML version deleted]]



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