Learn R Programming

nimble (version 1.2.1)

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)

Author

Daniel Turek, Christopher Paciorek, Perry de Valpine

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.

See Also

nimMatrix, nimArray