Description Usage Arguments Details Value Examples
Generate C code for a function and compile it
1 2 3 4 5 |
f |
Named character vector containing the right-hand sides of the ODE. You may use the key word
|
forcings |
Character vector with the names of the forcings |
outputs |
Named character vector for additional output variables,
see arguments |
jacobian |
Character, either "none" (no jacobian is computed), "full" (full jacobian is computed and written as a function into the C file) or "inz.lsodes" (only the non-zero elements of the jacobian are determined, see lsodes) |
rootfunc |
Named character vector. The root function (see lsoda). Besides the
variable names ( |
boundary |
data.frame with columns name, yini, yend specifying the boundary condition set-up. NULL if not a boundary value problem |
compile |
Logical. If FALSE, only the C file is written |
fcontrol |
Character, either |
nGridpoints |
Integer, defining the number of grid points between tmin and tmax where the ODE
is computed in any case. Indicates also the number of spline nodes if |
precision |
Numeric. Only used when |
modelname |
Character. The C file is generated in the working directory and is named <modelname>.c.
If |
verbose |
Print compiler output to R command line. |
The function replaces variables by arrays y[i]
, etc. and replaces "^" by pow()
in order to have the correct C syntax. The file name of the C-File is derived from f
.
I.e. funC(abc, ...
will generate a file abc.c in the current directory.
Currently, only explicit ODE specification is supported, i.e. you need to have the right-hand sides of the ODE.
the name of the generated shared object file together with a number of attributes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## Not run:
# Exponential decay plus constant supply
f <- c(x = "-k*x + supply")
func <- funC(f, forcings = "supply")
# Example 2: root function
f <- c(A = "-k1*A + k2*B", B = "k1*A - k2*B")
rootfunc <- c(steadyState = "-k1*A + k2*B - tol")
func <- funC(f, rootfunc = rootfunc, modelname = "test")
yini <- c(A = 1, B = 2)
parms <- c(k1 = 1, k2 = 5, tol = 0.1)
times <- seq(0, 10, len = 100)
odeC(yini, times, func, parms)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.