[R-sig-dyn-mod] deSolve with compiled code and varying size of parms

Tim Keitt tkeitt at utexas.edu
Tue Mar 28 22:37:31 CEST 2017


On Tue, Mar 28, 2017 at 3:14 PM, Daniel Kaschek <
daniel.kaschek at physik.uni-freiburg.de> wrote:

> By the way, there are some packages around working with deSolve and
> autogenerating C code or FORTRAN code, e.g., cOde and rodeo.
>

Here's an example in odeintr:

library(odeintr)
> sys = '
>   for (int i = 0; i != N; ++i)
>   {
>     dxdt[i] = 0;
>     for (int j = 0; j != N; ++j)
>       dxdt[i] += pars[j] * x[j];
>   }
> '
> n_pars = 10
> compile_sys("test", sys, n_pars, sys_dim = n_pars)
> test_set_params(rnorm(10))
> x0 = rep(1, 10)
> res = test(x0, 5)


The dimension is currently set at compile time, but that would be easy to
change.

THK

http://www.keittlab.org/

	[[alternative HTML version deleted]]



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