[R] precompiled ode with spline input
thpe at simecol.de
Tue Apr 5 07:35:03 CEST 2011
thanks for your positive response about using compiled ODE functions.
Did you use package deSolve?
Regarding the use of splines (as forcing functions ?) we don't have an
out of the box method yet, but you may consider to approximate the
splines by linear segments or contribute your own spline code to the
The example Forcing_lv.R / Forcing_lv.c shows how to use (linearly)
interpolated forcing data within compiled code, and the interpolation
code itself (Initdeforc, updateforc) is found in forcings.c. Depending
on your particular problem there may be other possibilities too.
I don't want to go more into the details here on r-help, but you may
consider to post additional questions to the mailing list of the
respective special interest group
This is also a good idea in general for such questions for getting more
On 3/15/2011 1:00 PM, Daniel Kaschek wrote:
> I tried to use lsode with precompiled C code instead of an R function
> defining the derivatives. No problem so far.
> However, now I need to implement an ODE that contains spline functions,
> i.e. the derivatives at given time points depend on the value of a
> spline function at this time point. What is an efficient way to
> implement this in precompiled C code?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help