nimbleFunction: create a nimbleFunction

Description Usage Arguments Details Author(s)

Description

create a nimbleFunction from a setup function, run function, possibly other methods, and possibly inheritance via contains

Usage

1
2
nimbleFunction(setup = NULL, run = function() { }, methods = list(),
  contains = NULL, name = NA, where = globalenv())

Arguments

setup

An optional R function definition for setup processing.

run

An optional NIMBLE function definition the executes the primary job of the nimbleFunction

methods

An optional named list of NIMBLE function definitions for other class methods that can be called via nfMethod.

contains

An optional object returned from nimbleFunctionVirtual that defines arguments and returnTypes for run and/or methods, to which the current nimbleFunction must conform

name

An optional name used internally, for example in generated C++ code. Usually this is left blank and NIMBLE provides a name.

where

An optional where argument passed to setRefClass for where the reference class definition generated for this nimbleFunction will be stored. This is needed due to R package namespace issues but should never need to be provided by a user.

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 made 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. When the specialized nimbleFunction is called, the run function is executed, which can use objects that were created in or passed to the setup function. Additional member functions provided in the methods argument can be accessed using nfMethod.

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


thirdwing/nimble documentation built on May 31, 2019, 10:41 a.m.