Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nimNumeric

Creates numeric, integer or logical vectors for use in nimbleFunctions


Description

In a nimbleFunction, numeric, integer and logical are identical to nimNumeric, nimInteger and nimLogical, respectively.

Usage

nimNumeric(length = 0, value = 0, init = TRUE, fillZeros = TRUE,
  recycle = TRUE)

nimInteger(length = 0, value = 0, init = TRUE, fillZeros = TRUE,
  recycle = TRUE)

nimLogical(length = 0, value = 0, init = TRUE, fillZeros = TRUE,
  recycle = TRUE)

Arguments

length

the length of the vector (default = 0)

value

value(s) for initializing the vector (default = 0). This may be a vector, matrix or array but will be used as a vector.

init

logical, whether to initialize elements of the vector (default = TRUE)

fillZeros

logical, whether to initialize any elements not filled by (possibly recycled) value with 0 (or FALSE for nimLogical) (default = TRUE)

recycle

logical, whether value should be recycled to fill the entire length of the new vector (default = TRUE)

Details

These functions are similar to R's numeric, integer, logical functions, but they can be used in a nimbleFunction and then compiled using compileNimble. Largely for compilation purposes, finer control is provided over initialization behavior. If init = FALSE, no initialization will be done, and value, fillZeros and recycle will be ignored. If init=TRUE and recycle=TRUE, then fillZeros will be ignored, and value will be repeated (according to R's recycling rule) as much as necessary to fill a vector of length length. If init=TRUE and recycle=FALSE, then if fillZeros=TRUE, values of 0 (or FALSE for nimLogical) will be filled in after value up to length length. Compiled code will be more efficient if unnecessary initialization is not done, but this may or may not be noticeable depending on the situation.

When used in a nimbleFunction (in run or other member function), numeric, integer and logical are immediately converted to nimNumeric, nimInteger and nimLogical, respectively.

Author(s)

Daniel Turek, Chris Paciorek, Perry de Valpine

See Also


nimble

MCMC, Particle Filtering, and Programmable Hierarchical Modeling

v0.11.0
BSD_3_clause + file LICENSE | GPL (>= 2)
Authors
Perry de Valpine [aut], Christopher Paciorek [aut, cre], Daniel Turek [aut], Nick Michaud [aut], Cliff Anderson-Bergman [aut], Fritz Obermeyer [aut], Claudia Wehrhahn Cortes [aut] (Bayesian nonparametrics system), Abel Rodrìguez [aut] (Bayesian nonparametrics system), Duncan Temple Lang [aut] (packaging configuration), Sally Paganin [aut] (reversible jump MCMC), Jagadish Babu [ctb] (code for the compilation system for an early version of NIMBLE), Lauren Ponisio [ctb] (contributions to the cross-validation code), Peter Sujan [ctb] (multivariate t distribution code)
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.