nimbleFunction {nimble} | R Documentation |
create a nimbleFunction
Description
create a nimbleFunction from a setup function, run function, possibly other methods, and possibly inheritance via contains
Usage
nimbleFunction(
setup = NULL,
run = function() {
},
methods = list(),
globalSetup = NULL,
contains = NULL,
buildDerivs = list(),
name = NA,
check = getNimbleOption("checkNimbleFunction"),
where = getNimbleFunctionEnvironment()
)
Arguments
setup |
An optional R function definition for setup processing. |
run |
An optional NIMBLE function definition that executes the primary job of the nimbleFunction |
methods |
An optional named list of NIMBLE function definitions for other class methods. |
globalSetup |
For internal use only |
contains |
An optional object returned from |
buildDerivs |
A list of names of function methods for which to build derivatives capabilities. |
name |
An optional name used internally, for example in generated C++ code. Usually this is left blank and NIMBLE provides a name. |
check |
Boolean indicating whether to check the run code for function calls that NIMBLE cannot compile. Checking can be turned off for all calls to |
where |
An optional |
Details
This is the main function for defining nimbleFunctions. A lot of information is provided in the NIMBLE User Manual, so only a brief summary will be given here.
If a setup
function is provided, then nimbleFunction
returns a generator: a function that when called with arguments for the setup function will execute that function and return a specialized nimbleFunction. The run
and other methods can be called using $
like in other R classes, e.g. nf$run()
. The methods can use objects that were created in or passed to the setup
function.
If no setup
function is provided, then nimbleFunction
returns a function that executes the run
function. It is not a generator in this case, and no other methods
can be provided.
If one wants a generator but does not need any setup arguments or code, setup = TRUE
can be used.
See the NIMBLE User Manual for examples.
For more information about the contains
argument, see the section on nimbleFunctionLists.
Author(s)
NIMBLE development team