TMB Documentation  v1.9.11
Functions
convenience.hpp File Reference

Templates to get convenient R-like syntax. More...

Go to the source code of this file.

Functions

template<class Type >
vector< Type > diff (vector< Type > x)
 
template<class Type >
Type invlogit (Type x)
 
template<class Type >
Type logit (Type x)
 
template<class Type >
Type logspace_add (Type logx, Type logy)
 Addition in log-space. More...
 
template<class Type >
Type logspace_sub (Type logx, Type logy)
 Subtraction in log-space. More...
 
template<class Type >
Type matern (Type u, Type phi, Type kappa)
 
template<class Type >
Type max (const vector< Type > &x)
 
template<class Type >
Type min (const vector< Type > &x)
 
template<class Type >
vector< Type > operator* (matrix< Type > A, vector< Type > x)
 
template<class Type >
vector< Type > operator* (Eigen::SparseMatrix< Type > A, vector< Type > x)
 
template<class Type >
Type pnorm_approx (Type x)
 Approximate normal cumulative distribution function, similar to R's pnorm (one-argument case only). More...
 
template<class Type >
Type qnorm_approx (Type x)
 Approximate inverse normal cumulative distribution function, similar to R's qnorm (one-argument case only). More...
 
template<class Type >
vector< vector< Type > > split (vector< Type > x, vector< int > fac)
 Similar to R's split function: split(x,fac) devides x into groups defined by fac . More...
 
template<class Type >
Type squeeze (Type u)
 
template<template< class > class Vector, class Type >
Type sum (Vector< Type > x)
 

Detailed Description

Templates to get convenient R-like syntax.

Definition in file convenience.hpp.

Function Documentation

§ diff()

template<class Type >
vector<Type> diff ( vector< Type >  x)

Diff of vector

Difference of vector elements just like diff in R, but only for vectors.

Definition at line 92 of file convenience.hpp.

§ invlogit()

template<class Type >
Type invlogit ( Type  x)

Inverse Logit

Calculates the inverse of the logit transformation; the same as plogis in base or inv.logit in the boot package in R.

Examples:
adaptive_integration.cpp, register_atomic.cpp, and register_atomic_parallel.cpp.

Definition at line 114 of file convenience.hpp.

§ logit()

template<class Type >
Type logit ( Type  x)

Logit

Calculates the logit transformation; the same as qlogis in base or logit in the boot package in R.

Definition at line 104 of file convenience.hpp.

§ max()

template<class Type >
Type max ( const vector< Type > &  x)

Taped maximum of vector

Definition at line 145 of file convenience.hpp.

Referenced by TMBad::autopar::max_tree_depth().

§ min()

template<class Type >
Type min ( const vector< Type > &  x)

Taped minimum of vector

Examples:
matrix_arrays.cpp.

Definition at line 156 of file convenience.hpp.

Referenced by sparse_matrix_exponential::expm_series< T >::operator()().

§ operator*() [1/2]

template<class Type >
vector<Type> operator* ( matrix< Type >  A,
vector< Type >  x 
)

Matrix * vector

Simplifies syntax in that .matrix() can be avoided. Recall: TMB type vector is of Eigen type Array.

Definition at line 42 of file convenience.hpp.

Referenced by TMBad::ReverseArgs< Type >::dy_segment(), and TMBad::forceContiguous().

§ operator*() [2/2]

template<class Type >
vector<Type> operator* ( Eigen::SparseMatrix< Type >  A,
vector< Type >  x 
)

SparseMatrix * vector

Definition at line 48 of file convenience.hpp.

§ pnorm_approx()

template<class Type >
Type pnorm_approx ( Type  x)

Approximate normal cumulative distribution function, similar to R's pnorm (one-argument case only).

Has been replaced by more accurate version based on Rmath library.

Definition at line 58 of file convenience.hpp.

§ qnorm_approx()

template<class Type >
Type qnorm_approx ( Type  x)

Approximate inverse normal cumulative distribution function, similar to R's qnorm (one-argument case only).

Has been replaced by more accurate version based on Rmath library.

Definition at line 72 of file convenience.hpp.

§ split()

template<class Type >
vector<vector<Type> > split ( vector< Type >  x,
vector< int >  fac 
)

Similar to R's split function: split(x,fac) devides x into groups defined by fac .

Returns a "vector of vectors".

Examples:
matrix_arrays.cpp, and nmix.cpp.

Definition at line 13 of file convenience.hpp.

§ squeeze()

template<class Type >
Type squeeze ( Type  u)

'squeeze' transform : [0,1] -> (0,1) to machine tolerance

Examples:
adaptive_integration.cpp, register_atomic.cpp, and register_atomic_parallel.cpp.

Definition at line 137 of file convenience.hpp.

§ sum()

template<template< class > class Vector, class Type >
Type sum ( Vector< Type >  x)
License: GPL v2