compile | R Documentation |
Creates and 'compiles' a function for use with numerical methods from
package deSolve
or rootSolve
.
sources |
Name(s) of source files(s) where functions appearing in
process rates or stoichiometric factors are implemented. Can be |
fortran |
If |
target |
Name of a 'target environment'. Currently, 'deSolve' is the only supported value. |
lib |
File path to be used for the generated library (without the platform specific extension). Note that any uppercase characters will be converted to lowercase. By default, the file is created in R's temporary folder under a random name. |
reuse |
If |
invisible(NULL)
The expected language of the external code passed in sources
depends on the value of fortran
.
If fortran
is FALSE
, R code is generated and made executable
by eval
and parse
. Auxiliary code
passed via sources
is made available via source
.
The created R function is stored in the object.
If fortran
is TRUE
, the external code passed in
sources
must implement a module with the fixed name 'functions'.
This module must contain all user-defined functions referenced in process
rates or stoichiometric factors.
If fortran
is TRUE
, a shared library is created. The library
is immediately loaded with dyn.load
and it is
automatically unloaded with dyn.unload
when the
object's finalize
method is called.
The name of the library (base name without extension) as well as the name
of the function to compute the derivatives are stored in the object.
These names can be queried with the
libName
and libFunc
methods, respectively.
Unless a file path is specified via the lib
argument, the library is
created in the folder returned by tempdir
under a
unique random name.
This method internally calls generate
.
data(vars, pars, funs, pros, stoi)
model <- rodeo$new(vars, pars, funs, pros, stoi, dim=c(1))
# This would trigger compilation assuming that 'functionsCode.f95' contains
# a Fortran implementation of all functions; see vignette for full example
## Not run:
model$compile(sources="functionsCode.f95")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.