TMB Documentation
v1.9.11
|
C++ macros used to enable interchange of data structures between R and C++. More...
Macros | |
#define | ADREPORT(name) TMB_OBJECTIVE_PTR -> reportvector.push(name, #name); |
Report an expression (scalar, vector, matrix or array valued) back to R with derivative information. More... | |
#define | DATA_ARRAY(name) |
Get data array from R and declare it as array<Type> More... | |
#define | DATA_ARRAY_INDICATOR(name, obs) |
Declare an indicator array 'name' of same shape as 'obs'. By default, the indicator array is filled with ones indicating that all observations are enabled. More... | |
#define | DATA_FACTOR(name) |
Get data vector of type "factor" from R and declare it as a zero-based integer vector. More... | |
#define | DATA_IARRAY(name) |
Get data array from R and declare it as array<int> | |
#define | DATA_IMATRIX(name) |
Get data matrix from R and declare it as matrix<int> | |
#define | DATA_INTEGER(name) |
Get data scalar from R and declare it as int. | |
#define | DATA_IVECTOR(name) |
Get data vector of type "integer" from R and declare it vector<int>. (DATA_INTEGER() is for a scalar integer) | |
#define | DATA_MATRIX(name) |
Get data matrix from R and declare it as matrix<Type> | |
#define | DATA_SCALAR(name) |
Get data scalar from R and declare it as Type. | |
#define | DATA_SPARSE_MATRIX(name) |
Get sparse matrix from R and declare it as Eigen::SparseMatrix<Type> | |
#define | DATA_STRING(name) |
Get string from R and declare it as std::string. More... | |
#define | DATA_STRUCT(name, struct) struct<Type> name(getListElement(TMB_OBJECTIVE_PTR -> data, #name)); |
Get data list object from R and make it available in C++. More... | |
#define | DATA_UPDATE(name) |
Update a data object without re-taping. More... | |
#define | DATA_VECTOR(name) |
Get data vector from R and declare it as vector<Type> More... | |
#define | DATA_VECTOR_INDICATOR(name, obs) |
Declare an indicator vector 'name' of same shape as 'obs'. By default, the indicator vector is filled with ones indicating that all observations are enabled. More... | |
#define | NLEVELS(name) |
Get the number of levels of a data factor from R. | |
#define | PARAMETER(name) |
Get parameter scalar from R and declare it as Type. | |
#define | PARAMETER_ARRAY(name) |
Get parameter array from R and declare it as array<Type> | |
#define | PARAMETER_MATRIX(name) |
Get parameter matrix from R and declare it as matrix<Type> | |
#define | PARAMETER_VECTOR(name) |
Get parameter vector from R and declare it as vector<Type> | |
#define | REPORT(name) |
Report scalar, vector or array back to R without derivative information. More... | |
#define | SIMULATE if(isDouble<Type>::value && TMB_OBJECTIVE_PTR -> do_simulate) |
Mark code that is only executed during simulation. More... | |
#define | TMB_ATOMIC_VECTOR_FUNCTION( ATOMIC_NAME, OUTPUT_DIM, ATOMIC_DOUBLE, ATOMIC_REVERSE) |
Construct atomic vector function based on known derivatives. More... | |
#define | TMB_OBJECTIVE_PTR this |
Pointer to objective function used by DATA and PARAMETER macros. More... | |
C++ macros used to enable interchange of data structures between R and C++.
#define ADREPORT | ( | name | ) | TMB_OBJECTIVE_PTR -> reportvector.push(name, #name); |
Report an expression (scalar, vector, matrix or array valued) back to R with derivative information.
Typical use: obtain point estimate and standard deviation of the expression via the R function sdreport()
(see details in R documentation). In the summary, the dimensions of the original expression is lost, and must be retrieved manually.
ADREPORT(name)
must not be used before name
has been assigned a value. Definition at line 342 of file tmb_core.hpp.
#define DATA_ARRAY | ( | name | ) |
Get data array from R and declare it as array<Type>
Definition at line 352 of file tmb_core.hpp.
#define DATA_ARRAY_INDICATOR | ( | name, | |
obs | |||
) |
Declare an indicator array 'name' of same shape as 'obs'. By default, the indicator array is filled with ones indicating that all observations are enabled.
This is used in conjunction with one-step-ahead residuals - see ?oneStepPredict
Definition at line 518 of file tmb_core.hpp.
#define DATA_FACTOR | ( | name | ) |
Get data vector of type "factor" from R and declare it as a zero-based integer vector.
The following example (R code) shows what you have on the R side and what is being received by the C++ template:
> x=factor(letters[4:10]) > x [1] d e f g h i j Levels: d e f g h i j # The zero-based integer vector that the C++ template sees > unclass(x) - 1 [1] 0 1 2 3 4 5 6
Definition at line 281 of file tmb_core.hpp.
#define DATA_STRING | ( | name | ) |
Get string from R and declare it as std::string.
Example (incomplete) of use:
Definition at line 394 of file tmb_core.hpp.
#define DATA_STRUCT | ( | name, | |
struct | |||
) | struct<Type> name(getListElement(TMB_OBJECTIVE_PTR -> data, #name)); |
Get data list object from R and make it available in C++.
Example (incomplete) of use:
In R:
In C++:
Definition at line 433 of file tmb_core.hpp.
#define DATA_UPDATE | ( | name | ) |
Update a data object without re-taping.
Placing DATA_UPDATE(x) after e.g. DATA_VECTOR(x) will allow to change x on the R-side (through obj$env$data$x) without re-taping. Updatable data items behave like parameters. In particular, if-else branching on such data should be avoided.
Definition at line 221 of file dynamic_data.hpp.
#define DATA_VECTOR | ( | name | ) |
Get data vector from R and declare it as vector<Type>
Definition at line 236 of file tmb_core.hpp.
#define DATA_VECTOR_INDICATOR | ( | name, | |
obs | |||
) |
Declare an indicator vector 'name' of same shape as 'obs'. By default, the indicator vector is filled with ones indicating that all observations are enabled.
This is used in conjunction with one-step-ahead residuals - see ?oneStepPredict
Definition at line 534 of file tmb_core.hpp.
#define REPORT | ( | name | ) |
Report scalar, vector or array back to R without derivative information.
REPORT(name)
must not be used before name
has been assigned a value. Definition at line 313 of file tmb_core.hpp.
#define SIMULATE if(isDouble<Type>::value && TMB_OBJECTIVE_PTR -> do_simulate) |
Mark code that is only executed during simulation.
Definition at line 329 of file tmb_core.hpp.
#define TMB_ATOMIC_VECTOR_FUNCTION | ( | ATOMIC_NAME, | |
OUTPUT_DIM, | |||
ATOMIC_DOUBLE, | |||
ATOMIC_REVERSE | |||
) |
Construct atomic vector function based on known derivatives.
This macro is used internally to define most atomic functions, see for example atomic::matmul
. It works portably for both CppAD and TMBad.
The macro is actually composed of two other lower-level macros. One declares and another defines the atomic function. If two atomic functions depend on one another, the lower-level macros may be useful - see e.g the atomic::fft
.
Definition at line 217 of file tmbad_atomic_macro.hpp.
#define TMB_OBJECTIVE_PTR this |
Pointer to objective function used by DATA and PARAMETER macros.
PARAMETER and DATA objects can be accessed from other classes and functions by redefining this macro.
Example (incomplete) of use:
Definition at line 208 of file tmb_core.hpp.