Stan  2.10.0
probability, sampling & optimization
Classes | Functions
stan::model Namespace Reference

For compiling models. More...

Classes

struct  cons_index_list
 Template structure for an index list consisting of a head and tail index. More...
 
struct  index_max
 Structure for an indexing from the start of a container to a specified maximum index (inclusive). More...
 
struct  index_min
 Structure for an indexing from a minimum index (inclusive) to the end of a container. More...
 
struct  index_min_max
 Structure for an indexing from a minimum index (inclusive) to a maximum index (inclusive). More...
 
struct  index_multi
 Structure for an indexing consisting of multiple indexes. More...
 
struct  index_omni
 Structure for an indexing that consists of all indexes for a container. More...
 
struct  index_uni
 Structure for an indexing consisting of a single index. More...
 
struct  model_functional
 
struct  nil_index_list
 Structure for an empty (size zero) index list. More...
 
class  prob_grad
 The prob_grad class represents the basic parameter holders for a model. More...
 
struct  rvalue_return
 Primary template class for metaprogram to calculate return value for model::rvalue() for the container or scalar type and index list type specified in the template parameters. More...
 
struct  rvalue_return< C, nil_index_list >
 Template class specialization for nil indexes, which provide the container type as the return type. More...
 
struct  rvalue_return< Eigen::Matrix< T, 1, Eigen::Dynamic >, cons_index_list< index_uni, nil_index_list > >
 Template class specialization for an Eigen row vector and one single index. More...
 
struct  rvalue_return< Eigen::Matrix< T, Eigen::Dynamic, 1 >, cons_index_list< index_uni, nil_index_list > >
 Template class specialization for an Eigen vector and one single index. More...
 
struct  rvalue_return< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >, cons_index_list< I, cons_index_list< index_uni, nil_index_list > > >
 Template specialization for an Eigen matrix with one multiple index followed by one single index. More...
 
struct  rvalue_return< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >, cons_index_list< I1, cons_index_list< I2, nil_index_list > > >
 Template specialization for an Eigen matrix and two multiple indexes. More...
 
struct  rvalue_return< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >, cons_index_list< index_uni, cons_index_list< I, nil_index_list > > >
 Template specialization for an Eigen matrix with one single index followed by one multiple index. More...
 
struct  rvalue_return< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >, cons_index_list< index_uni, cons_index_list< index_uni, nil_index_list > > >
 Template specialization for an Eigen matrix with two single indexes. More...
 
struct  rvalue_return< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >, cons_index_list< index_uni, nil_index_list > >
 Template class specialization for an Eigen matrix and one single index. More...
 
struct  rvalue_return< Eigen::Matrix< T, R, C >, cons_index_list< I, nil_index_list > >
 Template class specialization for an Eigen matrix, vector or rwo vector and one multiple index. More...
 
struct  rvalue_return< std::vector< C >, cons_index_list< I, L > >
 Template specialization for a standard vector whose index list starts with a multiple index. More...
 
struct  rvalue_return< std::vector< C >, cons_index_list< index_uni, L > >
 Template specialization for a standard vector whose index list starts with a single index. More...
 

Functions

template<typename T >
const T & deep_copy (const T &x)
 Return the specified argument as a constant reference. More...
 
template<typename T , int R, int C>
Eigen::Matrix< T, R, C > deep_copy (const Eigen::Matrix< T, R, C > &a)
 Return a copy of the specified matrix, vector, or row vector. More...
 
template<typename T >
std::vector< T > deep_copy (const std::vector< T > &v)
 Return a deep copy of the specified standard vector. More...
 
template<typename I , typename T >
cons_index_list< I, T > cons_list (const I &idx1, const T &t)
 
nil_index_list index_list ()
 
template<typename I >
cons_index_list< I, nil_index_listindex_list (const I &idx)
 
template<typename I1 , typename I2 >
cons_index_list< I1, cons_index_list< I2, nil_index_list > > index_list (const I1 &idx1, const I2 &idx2)
 
template<typename I1 , typename I2 , typename I3 >
cons_index_list< I1, cons_index_list< I2, cons_index_list< I3, nil_index_list > > > index_list (const I1 &idx1, const I2 &idx2, const I3 &idx3)
 
template<typename T , typename U >
void assign (T &x, const nil_index_list &, const U &y, const char *name="ANON", int depth=0)
 Assign the specified scalar reference under the specified indexing to the specified scalar value. More...
 
template<typename T , typename U , int R, int C>
void assign (Eigen::Matrix< T, R, C > &x, const nil_index_list &, const Eigen::Matrix< U, R, C > &y, const char *name="ANON", int depth=0)
 
template<typename T , typename U >
void assign (std::vector< T > &x, const nil_index_list &, const std::vector< U > &y, const char *name="ANON", int depth=0)
 
template<typename T , typename U >
void assign (Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, const cons_index_list< index_uni, nil_index_list > &idxs, const U &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen vector at the specified single index to the specified value. More...
 
template<typename T , typename U >
void assign (Eigen::Matrix< T, 1, Eigen::Dynamic > &x, const cons_index_list< index_uni, nil_index_list > &idxs, const U &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen vector at the specified single index to the specified value. More...
 
template<typename T , typename I , typename U >
boost::disable_if< boost::is_same< I, index_uni >, void >::type assign (Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, const cons_index_list< I, nil_index_list > &idxs, const Eigen::Matrix< U, Eigen::Dynamic, 1 > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen vector at the specified multiple index to the specified value. More...
 
template<typename T , typename I , typename U >
boost::disable_if< boost::is_same< I, index_uni >, void >::type assign (Eigen::Matrix< T, 1, Eigen::Dynamic > &x, const cons_index_list< I, nil_index_list > &idxs, const Eigen::Matrix< U, 1, Eigen::Dynamic > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen row vector at the specified multiple index to the specified value. More...
 
template<typename T , typename U >
void assign (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, const cons_index_list< index_uni, nil_index_list > &idxs, const Eigen::Matrix< U, 1, Eigen::Dynamic > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen matrix at the specified single index to the specified row vector value. More...
 
template<typename T , typename I , typename U >
boost::disable_if< boost::is_same< I, index_uni >, void >::type assign (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, const cons_index_list< I, nil_index_list > &idxs, const Eigen::Matrix< U, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen matrix at the specified multiple index to the specified matrix value. More...
 
template<typename T , typename U >
void assign (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, const cons_index_list< index_uni, cons_index_list< index_uni, nil_index_list > > &idxs, const U &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen matrix at the specified pair of single indexes to the specified scalar value. More...
 
template<typename T , typename I , typename U >
boost::disable_if< boost::is_same< I, index_uni >, void >::type assign (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, const cons_index_list< index_uni, cons_index_list< I, nil_index_list > > &idxs, const Eigen::Matrix< U, 1, Eigen::Dynamic > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen matrix at the specified single and multiple index to the specified row vector. More...
 
template<typename T , typename I , typename U >
boost::disable_if< boost::is_same< I, index_uni >, void >::type assign (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, const cons_index_list< I, cons_index_list< index_uni, nil_index_list > > &idxs, const Eigen::Matrix< U, Eigen::Dynamic, 1 > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen matrix at the specified multiple and single index to the specified vector. More...
 
template<typename T , typename I1 , typename I2 , typename U >
boost::disable_if_c< boost::is_same< I1, index_uni >::value||boost::is_same< I2, index_uni >::value, void >::type assign (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, const cons_index_list< I1, cons_index_list< I2, nil_index_list > > &idxs, const Eigen::Matrix< U, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name="ANON", int depth=0)
 Assign the specified Eigen matrix at the specified pair of multiple indexes to the specified matrix. More...
 
template<typename T , typename L , typename U >
void assign (std::vector< T > &x, const cons_index_list< index_uni, L > &idxs, const U &y, const char *name="ANON", int depth=0)
 Assign the specified array (standard vector) at the specified index list beginning with a single index to the specified value. More...
 
template<typename T , typename I , typename L , typename U >
boost::disable_if< boost::is_same< I, index_uni >, void >::type assign (std::vector< T > &x, const cons_index_list< I, L > &idxs, const std::vector< U > &y, const char *name="ANON", int depth=0)
 Assign the specified array (standard vector) at the specified index list beginning with a multiple index to the specified value. More...
 
template<typename T >
rvalue (const T &c, const nil_index_list &, const char *="", int=0)
 Return the result of indexing a specified value with a nil index list, which just returns the value. More...
 
template<typename T >
rvalue (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, const cons_index_list< index_uni, nil_index_list > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen vector with a sequence containing one single index, returning a scalar. More...
 
template<typename T >
rvalue (const Eigen::Matrix< T, 1, Eigen::Dynamic > &rv, const cons_index_list< index_uni, nil_index_list > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen row vector with a sequence containing one single index, returning a scalar. More...
 
template<typename T , typename I >
boost::disable_if< boost::is_same< I, index_uni >, Eigen::Matrix< T, Eigen::Dynamic, 1 > >::type rvalue (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, const cons_index_list< I, nil_index_list > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen vector with a sequence containing one multiple index, returning a vector. More...
 
template<typename T , typename I >
boost::disable_if< boost::is_same< I, index_uni >, Eigen::Matrix< T, 1, Eigen::Dynamic > >::type rvalue (const Eigen::Matrix< T, 1, Eigen::Dynamic > &rv, const cons_index_list< I, nil_index_list > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen row vector with a sequence containing one multiple index, returning a row vector. More...
 
template<typename T >
Eigen::Matrix< T, 1, Eigen::Dynamic > rvalue (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a, const cons_index_list< index_uni, nil_index_list > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen matrix with a sequence consisting of one single index, returning a row vector. More...
 
template<typename T , typename I >
boost::disable_if< boost::is_same< I, index_uni >, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > >::type rvalue (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a, const cons_index_list< I, nil_index_list > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen matrix with a sequence consisting of a one multiple index, returning a matrix. More...
 
template<typename T >
rvalue (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a, const cons_index_list< index_uni, cons_index_list< index_uni, nil_index_list > > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen matrix with a sequence consisting of two single indexes, returning a scalar. More...
 
template<typename T , typename I >
boost::disable_if< boost::is_same< I, index_uni >, Eigen::Matrix< T, 1, Eigen::Dynamic > >::type rvalue (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a, const cons_index_list< index_uni, cons_index_list< I, nil_index_list > > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen matrix with a sequence consisting of a single index and multiple index, returning a row vector. More...
 
template<typename T , typename I >
boost::disable_if< boost::is_same< I, index_uni >, Eigen::Matrix< T, Eigen::Dynamic, 1 > >::type rvalue (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a, const cons_index_list< I, cons_index_list< index_uni, nil_index_list > > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen matrix with a sequence consisting of a multiple index and a single index, returning a vector. More...
 
template<typename T , typename I1 , typename I2 >
boost::disable_if_c< boost::is_same< I1, index_uni >::value||boost::is_same< I2, index_uni >::value, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > >::type rvalue (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a, const cons_index_list< I1, cons_index_list< I2, nil_index_list > > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified Eigen matrix with a sequence consisting of a pair o multiple indexes, returning a a matrix. More...
 
template<typename T , typename L >
rvalue_return< std::vector< T >, cons_index_list< index_uni, L > >::type rvalue (const std::vector< T > &c, const cons_index_list< index_uni, L > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified array with a list of indexes beginning with a single index; the result is determined recursively. More...
 
template<typename T , typename I , typename L >
rvalue_return< std::vector< T >, cons_index_list< I, L > >::type rvalue (const std::vector< T > &c, const cons_index_list< I, L > &idx, const char *name="ANON", int depth=0)
 Return the result of indexing the specified array with a list of indexes beginning with a multiple index; the result is determined recursively. More...
 
int rvalue_at (int n, const index_multi &idx)
 Return the index in the underlying array corresponding to the specified position in the specified multi-index. More...
 
int rvalue_at (int n, const index_omni &idx)
 Return the index in the underlying array corresponding to the specified position in the specified omni-index. More...
 
int rvalue_at (int n, const index_min &idx)
 Return the index in the underlying array corresponding to the specified position in the specified min-index. More...
 
int rvalue_at (int n, const index_max &idx)
 Return the index in the underlying array corresponding to the specified position in the specified max-index. More...
 
int rvalue_at (int n, const index_min_max &idx)
 Return the index in the underlying array corresponding to the specified position in the specified min-max-index. More...
 
int rvalue_index_size (const index_multi &idx, int size)
 Return size of specified multi-index. More...
 
int rvalue_index_size (const index_omni &idx, int size)
 Return size of specified omni-index for specified size of input. More...
 
int rvalue_index_size (const index_min &idx, int size)
 Return size of specified min index for specified size of input. More...
 
int rvalue_index_size (const index_max &idx, int size)
 Return size of specified max index. More...
 
int rvalue_index_size (const index_min_max &idx, int size)
 Return size of specified min-max index. More...
 
template<bool jacobian_adjust_transform, class M >
double log_prob_propto (const M &model, std::vector< double > &params_r, std::vector< int > &params_i, std::ostream *msgs=0)
 Helper function to calculate log probability for double scalars up to a proportion. More...
 
template<bool propto, bool jacobian_adjust_transform, class M >
double log_prob_grad (const M &model, std::vector< double > &params_r, std::vector< int > &params_i, std::vector< double > &gradient, std::ostream *msgs=0)
 Compute the gradient using reverse-mode automatic differentiation, writing the result into the specified gradient, using the specified perturbation. More...
 
template<bool jacobian_adjust_transform, class M >
double log_prob_propto (const M &model, Eigen::VectorXd &params_r, std::ostream *msgs=0)
 Helper function to calculate log probability for double scalars up to a proportion. More...
 
template<bool propto, bool jacobian_adjust_transform, class M >
double log_prob_grad (const M &model, Eigen::VectorXd &params_r, Eigen::VectorXd &gradient, std::ostream *msgs=0)
 Compute the gradient using reverse-mode automatic differentiation, writing the result into the specified gradient, using the specified perturbation. More...
 
template<bool propto, bool jacobian_adjust_transform, class M >
void finite_diff_grad (const M &model, std::vector< double > &params_r, std::vector< int > &params_i, std::vector< double > &grad, double epsilon=1e-6, std::ostream *msgs=0)
 Compute the gradient using finite differences for the specified parameters, writing the result into the specified gradient, using the specified perturbation. More...
 
template<bool propto, bool jacobian_adjust_transform, class M >
int test_gradients (const M &model, std::vector< double > &params_r, std::vector< int > &params_i, double epsilon, double error, stan::interface_callbacks::writer::base_writer &writer)
 Test the log_prob_grad() function's ability to produce accurate gradients using finite differences. More...
 
template<bool propto, bool jacobian_adjust_transform, class M >
double grad_hess_log_prob (const M &model, std::vector< double > &params_r, std::vector< int > &params_i, std::vector< double > &gradient, std::vector< double > &hessian, std::ostream *msgs=0)
 Evaluate the log-probability, its gradient, and its Hessian at params_r. More...
 
template<class M >
void gradient (const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, double &f, Eigen::Matrix< double, Eigen::Dynamic, 1 > &grad_f, std::ostream *msgs=0)
 
template<class M >
void gradient (const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, double &f, Eigen::Matrix< double, Eigen::Dynamic, 1 > &grad_f, stan::interface_callbacks::writer::base_writer &writer)
 
template<class M >
void hessian (const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, double &f, Eigen::Matrix< double, Eigen::Dynamic, 1 > &grad_f, Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &hess_f, std::ostream *msgs=0)
 
template<class M >
void gradient_dot_vector (const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &v, double &f, double &grad_f_dot_v, std::ostream *msgs=0)
 
template<class M >
void hessian_times_vector (const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &v, double &f, Eigen::Matrix< double, Eigen::Dynamic, 1 > &hess_f_dot_v, std::ostream *msgs=0)
 
template<class M >
void grad_tr_mat_times_hessian (const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &X, Eigen::Matrix< double, Eigen::Dynamic, 1 > &grad_tr_X_hess_f, std::ostream *msgs=0)
 

Detailed Description

For compiling models.

Function Documentation

template<typename T , typename U >
void stan::model::assign ( T &  x,
const nil_index_list ,
const U &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified scalar reference under the specified indexing to the specified scalar value.

Types: x[] <- y

Template Parameters
TAssigned variable type.
UValue type (must be assignable to T).
Parameters
[in]xVariable to be assigned.
[in]yValue.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).

Definition at line 33 of file lvalue.hpp.

template<typename T , typename U , int R, int C>
void stan::model::assign ( Eigen::Matrix< T, R, C > &  x,
const nil_index_list ,
const Eigen::Matrix< U, R, C > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Definition at line 39 of file lvalue.hpp.

template<typename T , typename U >
void stan::model::assign ( std::vector< T > &  x,
const nil_index_list ,
const std::vector< U > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Definition at line 51 of file lvalue.hpp.

template<typename T , typename U >
void stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, 1 > &  x,
const cons_index_list< index_uni, nil_index_list > &  idxs,
const U &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen vector at the specified single index to the specified value.

Types: vec[uni] <- scalar

Template Parameters
TType of assigned vector scalar.
UType of value (must be assignable to T).
Parameters
[in]xVector variable to be assigned.
[in]idxsSequence of one single index (from 1).
[in]yValue scalar.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf the index is out of bounds.

Definition at line 76 of file lvalue.hpp.

template<typename T , typename U >
void stan::model::assign ( Eigen::Matrix< T, 1, Eigen::Dynamic > &  x,
const cons_index_list< index_uni, nil_index_list > &  idxs,
const U &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen vector at the specified single index to the specified value.

Types: row_vec[uni] <- scalar

Template Parameters
TType of assigned row vector scalar.
UType of value (must be assignable to T).
Parameters
[in]xRow vector variable to be assigned.
[in]idxsSequence of one single index (from 1).
[in]yValue scalar.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIndex is out of bounds.

Definition at line 101 of file lvalue.hpp.

template<typename T , typename I , typename U >
boost::disable_if<boost::is_same<I, index_uni>, void>::type stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, 1 > &  x,
const cons_index_list< I, nil_index_list > &  idxs,
const Eigen::Matrix< U, Eigen::Dynamic, 1 > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen vector at the specified multiple index to the specified value.

Types: vec[multi] <- vec

Template Parameters
TType of assigned vector scalar.
IType of multiple index.
UType of vector value scalar (must be assignable to T).
Parameters
[in]xRow vector variable to be assigned.
[in]idxsSequence of one single index (from 1).
[in]yValue vector.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the value size isn't the same as the indexed size.

Definition at line 130 of file lvalue.hpp.

template<typename T , typename I , typename U >
boost::disable_if<boost::is_same<I, index_uni>, void>::type stan::model::assign ( Eigen::Matrix< T, 1, Eigen::Dynamic > &  x,
const cons_index_list< I, nil_index_list > &  idxs,
const Eigen::Matrix< U, 1, Eigen::Dynamic > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen row vector at the specified multiple index to the specified value.

Types: row_vec[multi] <- row_vec

Template Parameters
TScalar type for assigned row vector.
IType of multiple index.
UType of value row vector scalar (must be assignable to T).
Parameters
[in]xRow vector variable to be assigned.
[in]idxsSequence of one multiple index (from 1).
[in]yValue vector.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the value size isn't the same as the indexed size.

Definition at line 164 of file lvalue.hpp.

template<typename T , typename U >
void stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  x,
const cons_index_list< index_uni, nil_index_list > &  idxs,
const Eigen::Matrix< U, 1, Eigen::Dynamic > &  y,
const char *  name = "ANON",
int  depth = 0 
)

Assign the specified Eigen matrix at the specified single index to the specified row vector value.

Types: mat[uni] = rowvec

Template Parameters
TAssigned matrix scalar type.
UType of value scalar for row vector (must be assignable to T).
Parameters
[in]xMatrix variable to be assigned.
[in]idxsSequence of one single index (from 1).
[in]yValue row vector.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the number of columns in the row vector and matrix do not match.

Definition at line 197 of file lvalue.hpp.

template<typename T , typename I , typename U >
boost::disable_if<boost::is_same<I, index_uni>, void>::type stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  x,
const cons_index_list< I, nil_index_list > &  idxs,
const Eigen::Matrix< U, Eigen::Dynamic, Eigen::Dynamic > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen matrix at the specified multiple index to the specified matrix value.

Types: mat[multi] = mat

Template Parameters
TAssigned matrix scalar type.
IMultiple index type.
UValue matrix scalar type (must be assignable to T).
Parameters
[in]xMatrix variable to be assigned.
[in]idxsSequence of one multiple index (from 1).
[in]yValue matrix.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the dimensions of the indexed matrix and right-hand side matrix do not match.

Definition at line 228 of file lvalue.hpp.

template<typename T , typename U >
void stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  x,
const cons_index_list< index_uni, cons_index_list< index_uni, nil_index_list > > &  idxs,
const U &  y,
const char *  name = "ANON",
int  depth = 0 
)

Assign the specified Eigen matrix at the specified pair of single indexes to the specified scalar value.

Types: mat[single, single] = scalar

Template Parameters
TMatrix scalar type.
UScalar type.
Parameters
[in]xMatrix variable to be assigned.
[in]idxsSequence of two single indexes (from 1).
[in]yValue scalar.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf either of the indices are out of bounds.

Definition at line 262 of file lvalue.hpp.

template<typename T , typename I , typename U >
boost::disable_if<boost::is_same<I, index_uni>, void>::type stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  x,
const cons_index_list< index_uni, cons_index_list< I, nil_index_list > > &  idxs,
const Eigen::Matrix< U, 1, Eigen::Dynamic > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen matrix at the specified single and multiple index to the specified row vector.

Types: mat[uni, multi] = rowvec

Template Parameters
TAssigned matrix scalar type.
IMulti-index type.
UValue row vector scalar type (must be assignable to T).
Parameters
[in]xMatrix variable to be assigned.
[in]idxsSequence of single and multiple index (from 1).
[in]yValue row vector.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the dimensions of the indexed matrix and right-hand side row vector do not match.

Definition at line 296 of file lvalue.hpp.

template<typename T , typename I , typename U >
boost::disable_if<boost::is_same<I, index_uni>, void>::type stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  x,
const cons_index_list< I, cons_index_list< index_uni, nil_index_list > > &  idxs,
const Eigen::Matrix< U, Eigen::Dynamic, 1 > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen matrix at the specified multiple and single index to the specified vector.

Types: mat[multi, uni] = vec

Template Parameters
TAssigned matrix scalar type.
IMulti-index type.
UValue vector scalar type (must be assignable to T).
Parameters
[in]xMatrix variable to be assigned.
[in]idxsSequence of multiple and single index (from 1).
[in]yValue vector.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the dimensions of the indexed matrix and right-hand side vector do not match.

Definition at line 333 of file lvalue.hpp.

template<typename T , typename I1 , typename I2 , typename U >
boost::disable_if_c<boost::is_same<I1, index_uni>::value || boost::is_same<I2, index_uni>::value, void>::type stan::model::assign ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  x,
const cons_index_list< I1, cons_index_list< I2, nil_index_list > > &  idxs,
const Eigen::Matrix< U, Eigen::Dynamic, Eigen::Dynamic > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified Eigen matrix at the specified pair of multiple indexes to the specified matrix.

Types: mat[multi, multi] = mat

Template Parameters
TAssigned matrix scalar type.
I1First multiple index type.
I2Second multiple index type.
UValue matrix scalar type (must be assignable to T).
Parameters
[in]xMatrix variable to be assigned.
[in]idxsPair of multiple indexes (from 1).
[in]yValue matrix.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the dimensions of the indexed matrix and value matrix do not match.

Definition at line 374 of file lvalue.hpp.

template<typename T , typename L , typename U >
void stan::model::assign ( std::vector< T > &  x,
const cons_index_list< index_uni, L > &  idxs,
const U &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified array (standard vector) at the specified index list beginning with a single index to the specified value.

This function operates recursively to carry out the tail indexing.

Types: x[uni | L] = y

Template Parameters
TAssigned vector member type.
LType of tail of index list.
UValue scalar type (must be assignable to indexed variable).
Parameters
[in]xArray variable to be assigned.
[in]idxsList of indexes beginning with single index (from 1).
[in]yValue.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the dimensions do not match in the tail assignment.

Definition at line 422 of file lvalue.hpp.

template<typename T , typename I , typename L , typename U >
boost::disable_if<boost::is_same<I, index_uni>, void>::type stan::model::assign ( std::vector< T > &  x,
const cons_index_list< I, L > &  idxs,
const std::vector< U > &  y,
const char *  name = "ANON",
int  depth = 0 
)
inline

Assign the specified array (standard vector) at the specified index list beginning with a multiple index to the specified value.

This function operates recursively to carry out the tail indexing.

Types: x[multi | L] = y

Template Parameters
TAssigned vector member type.
IType of multiple index heading index list.
LType of tail of index list.
UValue scalar type (must be assignable to indexed variable).
Parameters
[in]xArray variable to be assigned.
[in]idxsList of indexes beginning with multiple index (from 1).
[in]yValue.
[in]nameName of variable (default "ANON").
[in]depthIndexing depth (default 0).
Exceptions
std::out_of_rangeIf any of the indices are out of bounds.
std::domain_errorIf the size of the multiple indexing and size of first dimension of value do not match, or any of the recursive tail assignment dimensions do not match.

Definition at line 457 of file lvalue.hpp.

template<typename I , typename T >
cons_index_list<I, T> stan::model::cons_list ( const I &  idx1,
const T &  t 
)
inline

Definition at line 43 of file index_list.hpp.

template<typename T >
const T& stan::model::deep_copy ( const T &  x)
inline

Return the specified argument as a constant reference.

Warning: because of the usage pattern of this class, this function only needs to return value references, not actual copies. The functions that call this overload recursively will be doing the actual copies with assignment.

Template Parameters
TType of scalar.
Parameters
xInput value.
Returns
Constant reference to input.

Definition at line 24 of file deep_copy.hpp.

template<typename T , int R, int C>
Eigen::Matrix<T, R, C> stan::model::deep_copy ( const Eigen::Matrix< T, R, C > &  a)
inline

Return a copy of the specified matrix, vector, or row vector.

The return value is a copy in the sense that modifying its contents will not affect the original matrix.

Warning: This function assumes that the elements of the matrix deep copy under assignment.

Template Parameters
TScalar type.
RRow type specificiation.
CColumn type specificiation.
Parameters
aInput matrix, vector, or row vector.
Returns
Deep copy of input.

Definition at line 43 of file deep_copy.hpp.

template<typename T >
std::vector<T> stan::model::deep_copy ( const std::vector< T > &  v)
inline

Return a deep copy of the specified standard vector.

The return value is a copy in the sense that modifying its contents will not affect the original vector.

Warning: This function assumes that the elements of the vector deep copy under assignment.

Template Parameters
TScalar type.
Parameters
vInput vector.
Returns
Deep copy of input.

Definition at line 61 of file deep_copy.hpp.

template<bool propto, bool jacobian_adjust_transform, class M >
void stan::model::finite_diff_grad ( const M &  model,
std::vector< double > &  params_r,
std::vector< int > &  params_i,
std::vector< double > &  grad,
double  epsilon = 1e-6,
std::ostream *  msgs = 0 
)

Compute the gradient using finite differences for the specified parameters, writing the result into the specified gradient, using the specified perturbation.

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
modelModel.
params_rReal-valued parameters.
params_iInteger-valued parameters.
[out]gradVector into which gradient is written.
epsilon
[in,out]msgs

Definition at line 228 of file util.hpp.

template<bool propto, bool jacobian_adjust_transform, class M >
double stan::model::grad_hess_log_prob ( const M &  model,
std::vector< double > &  params_r,
std::vector< int > &  params_i,
std::vector< double > &  gradient,
std::vector< double > &  hessian,
std::ostream *  msgs = 0 
)

Evaluate the log-probability, its gradient, and its Hessian at params_r.

This default version computes the Hessian numerically by finite-differencing the gradient, at a cost of O(params_r.size()^2).

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
modelModel.
params_rReal-valued parameter vector.
params_iInteger-valued parameter vector.
gradientVector to write gradient to.
hessianVector to write gradient to. hessian[i*D + j] gives the element at the ith row and jth column of the Hessian (where D=params_r.size()).
msgsStream to which print statements in Stan programs are written, default is 0

Definition at line 361 of file util.hpp.

template<class M >
void stan::model::grad_tr_mat_times_hessian ( const M &  model,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  x,
const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &  X,
Eigen::Matrix< double, Eigen::Dynamic, 1 > &  grad_tr_X_hess_f,
std::ostream *  msgs = 0 
)

Definition at line 481 of file util.hpp.

template<class M >
void stan::model::gradient ( const M &  model,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  x,
double &  f,
Eigen::Matrix< double, Eigen::Dynamic, 1 > &  grad_f,
std::ostream *  msgs = 0 
)

Definition at line 422 of file util.hpp.

template<class M >
void stan::model::gradient ( const M &  model,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  x,
double &  f,
Eigen::Matrix< double, Eigen::Dynamic, 1 > &  grad_f,
stan::interface_callbacks::writer::base_writer writer 
)

Definition at line 431 of file util.hpp.

template<class M >
void stan::model::gradient_dot_vector ( const M &  model,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  x,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  v,
double &  f,
double &  grad_f_dot_v,
std::ostream *  msgs = 0 
)

Definition at line 458 of file util.hpp.

template<class M >
void stan::model::hessian ( const M &  model,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  x,
double &  f,
Eigen::Matrix< double, Eigen::Dynamic, 1 > &  grad_f,
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &  hess_f,
std::ostream *  msgs = 0 
)

Definition at line 447 of file util.hpp.

template<class M >
void stan::model::hessian_times_vector ( const M &  model,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  x,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  v,
double &  f,
Eigen::Matrix< double, Eigen::Dynamic, 1 > &  hess_f_dot_v,
std::ostream *  msgs = 0 
)

Definition at line 469 of file util.hpp.

nil_index_list stan::model::index_list ( )
inline

Definition at line 48 of file index_list.hpp.

template<typename I >
cons_index_list<I, nil_index_list> stan::model::index_list ( const I &  idx)
inline

Definition at line 54 of file index_list.hpp.

template<typename I1 , typename I2 >
cons_index_list<I1, cons_index_list<I2, nil_index_list> > stan::model::index_list ( const I1 &  idx1,
const I2 &  idx2 
)
inline

Definition at line 60 of file index_list.hpp.

template<typename I1 , typename I2 , typename I3 >
cons_index_list<I1, cons_index_list<I2, cons_index_list<I3, nil_index_list> > > stan::model::index_list ( const I1 &  idx1,
const I2 &  idx2,
const I3 &  idx3 
)
inline

Definition at line 70 of file index_list.hpp.

template<bool propto, bool jacobian_adjust_transform, class M >
double stan::model::log_prob_grad ( const M &  model,
std::vector< double > &  params_r,
std::vector< int > &  params_i,
std::vector< double > &  gradient,
std::ostream *  msgs = 0 
)

Compute the gradient using reverse-mode automatic differentiation, writing the result into the specified gradient, using the specified perturbation.

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
[in]modelModel.
[in]params_rReal-valued parameters.
[in]params_iInteger-valued parameters.
[out]gradientVector into which gradient is written.
[in,out]msgs

Definition at line 92 of file util.hpp.

template<bool propto, bool jacobian_adjust_transform, class M >
double stan::model::log_prob_grad ( const M &  model,
Eigen::VectorXd &  params_r,
Eigen::VectorXd &  gradient,
std::ostream *  msgs = 0 
)

Compute the gradient using reverse-mode automatic differentiation, writing the result into the specified gradient, using the specified perturbation.

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
[in]modelModel.
[in]params_rReal-valued parameters.
[out]gradientVector into which gradient is written.
[in,out]msgs

Definition at line 183 of file util.hpp.

template<bool jacobian_adjust_transform, class M >
double stan::model::log_prob_propto ( const M &  model,
std::vector< double > &  params_r,
std::vector< int > &  params_i,
std::ostream *  msgs = 0 
)

Helper function to calculate log probability for double scalars up to a proportion.

This implementation wraps the double values in stan::math::var and calls the model's log_prob() function with propto=true and the specified parameter for applying the Jacobian adjustment for transformed parameters.

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
[in]modelModel.
[in]params_rReal-valued parameters.
[in]params_iInteger-valued parameters.
[in,out]msgs

Definition at line 53 of file util.hpp.

template<bool jacobian_adjust_transform, class M >
double stan::model::log_prob_propto ( const M &  model,
Eigen::VectorXd &  params_r,
std::ostream *  msgs = 0 
)

Helper function to calculate log probability for double scalars up to a proportion.

This implementation wraps the double values in stan::math::var and calls the model's log_prob() function with propto=true and the specified parameter for applying the Jacobian adjustment for transformed parameters.

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
[in]modelModel.
[in]params_rReal-valued parameters.
[in,out]msgs

Definition at line 140 of file util.hpp.

template<typename T >
T stan::model::rvalue ( const T &  c,
const nil_index_list ,
const char *  = "",
int  = 0 
)
inline

Return the result of indexing a specified value with a nil index list, which just returns the value.

Types: T[] : T

Template Parameters
TScalar type.
Parameters
[in]cValue to index.
Returns
Input value.

Definition at line 32 of file rvalue.hpp.

template<typename T >
T stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, 1 > &  v,
const cons_index_list< index_uni, nil_index_list > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen vector with a sequence containing one single index, returning a scalar.

Types: vec[single] : scal

Template Parameters
TScalar type.
Parameters
[in]vVector being indexed.
[in]idxOne single index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing vector.

Definition at line 51 of file rvalue.hpp.

template<typename T >
T stan::model::rvalue ( const Eigen::Matrix< T, 1, Eigen::Dynamic > &  rv,
const cons_index_list< index_uni, nil_index_list > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen row vector with a sequence containing one single index, returning a scalar.

Types: rowvec[single] : scal

Template Parameters
TScalar type.
Parameters
[in]rvRow vector being indexed.
[in]idxOne single index in list.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing row vector.

Definition at line 74 of file rvalue.hpp.

template<typename T , typename I >
boost::disable_if<boost::is_same<I, index_uni>, Eigen::Matrix<T, Eigen::Dynamic, 1> >::type stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, 1 > &  v,
const cons_index_list< I, nil_index_list > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen vector with a sequence containing one multiple index, returning a vector.

Types: vec[multiple] : vec

Template Parameters
TScalar type.
IMulti-index type.
Parameters
[in]vEigen vector.
[in]idxIndex consisting of one multi-index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing vector.

Definition at line 101 of file rvalue.hpp.

template<typename T , typename I >
boost::disable_if<boost::is_same<I, index_uni>, Eigen::Matrix<T, 1, Eigen::Dynamic> >::type stan::model::rvalue ( const Eigen::Matrix< T, 1, Eigen::Dynamic > &  rv,
const cons_index_list< I, nil_index_list > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen row vector with a sequence containing one multiple index, returning a row vector.

Types: row_vec[multiple] : rowvec

Template Parameters
TScalar type.
IMulti-index type.
Parameters
[in]rvEigen row vector.
[in]idxIndex consisting of one multi-index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing vector.

Definition at line 133 of file rvalue.hpp.

template<typename T >
Eigen::Matrix<T, 1, Eigen::Dynamic> stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a,
const cons_index_list< index_uni, nil_index_list > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen matrix with a sequence consisting of one single index, returning a row vector.

Types: mat[single] : rowvec

Template Parameters
TScalar type.
Parameters
[in]aEigen matrix.
[in]idxIndex consisting of one uni-index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing matrix.

Definition at line 161 of file rvalue.hpp.

template<typename T , typename I >
boost::disable_if<boost::is_same<I, index_uni>, Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >::type stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a,
const cons_index_list< I, nil_index_list > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen matrix with a sequence consisting of a one multiple index, returning a matrix.

Types: mat[multiple] : mat

Template Parameters
TScalar type.
IType of multiple index.
Parameters
[in]aMatrix to index.
[in]idxIndex consisting of single multiple index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing matrix.

Definition at line 187 of file rvalue.hpp.

template<typename T >
T stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a,
const cons_index_list< index_uni, cons_index_list< index_uni, nil_index_list > > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen matrix with a sequence consisting of two single indexes, returning a scalar.

Types: mat[single,single] : scalar

Template Parameters
TScalar type.
Parameters
[in]aMatrix to index.
[in]idxPair of single indexes.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing matrix.

Definition at line 215 of file rvalue.hpp.

template<typename T , typename I >
boost::disable_if<boost::is_same<I, index_uni>, Eigen::Matrix<T, 1, Eigen::Dynamic> >::type stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a,
const cons_index_list< index_uni, cons_index_list< I, nil_index_list > > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen matrix with a sequence consisting of a single index and multiple index, returning a row vector.

Types: mat[single,multiple] : row vector

Template Parameters
TScalar type.
IType of multiple index.
Parameters
[in]aMatrix to index.
[in]idxPair of single index and multiple index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing matrix.

Definition at line 246 of file rvalue.hpp.

template<typename T , typename I >
boost::disable_if<boost::is_same<I, index_uni>, Eigen::Matrix<T, Eigen::Dynamic, 1> >::type stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a,
const cons_index_list< I, cons_index_list< index_uni, nil_index_list > > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen matrix with a sequence consisting of a multiple index and a single index, returning a vector.

Types: mat[multiple,single] : vector

Template Parameters
TScalar type.
IType of multiple index.
Parameters
[in]aMatrix to index.
[in]idxPair multiple index and single index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing matrix.

Definition at line 275 of file rvalue.hpp.

template<typename T , typename I1 , typename I2 >
boost::disable_if_c<boost::is_same<I1, index_uni>::value || boost::is_same<I2, index_uni>::value, Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >::type stan::model::rvalue ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a,
const cons_index_list< I1, cons_index_list< I2, nil_index_list > > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified Eigen matrix with a sequence consisting of a pair o multiple indexes, returning a a matrix.

Types: mat[multiple,multiple] : mat

Template Parameters
TScalar type.
IType of multiple index.
Parameters
[in]aMatrix to index.
[in]idxPair of multiple indexes.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing matrix.

Definition at line 312 of file rvalue.hpp.

template<typename T , typename L >
rvalue_return<std::vector<T>, cons_index_list<index_uni, L> >::type stan::model::rvalue ( const std::vector< T > &  c,
const cons_index_list< index_uni, L > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified array with a list of indexes beginning with a single index; the result is determined recursively.

Note that arrays are represented as standard library vectors.

Types: std::vector<T>[single | L] : T[L]

Template Parameters
TType of list elements.
LIndex list type for indexes after first index.
Parameters
[in]cContainer of list elements.
[in]idxIndex list beginning with single index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing array.

Definition at line 352 of file rvalue.hpp.

template<typename T , typename I , typename L >
rvalue_return<std::vector<T>, cons_index_list<I, L> >::type stan::model::rvalue ( const std::vector< T > &  c,
const cons_index_list< I, L > &  idx,
const char *  name = "ANON",
int  depth = 0 
)
inline

Return the result of indexing the specified array with a list of indexes beginning with a multiple index; the result is determined recursively.

Note that arrays are represented as standard library vectors.

Types: std::vector<T>[multiple | L] : std::vector<T[L]>

Template Parameters
TType of list elements.
LIndex list type for indexes after first index.
Parameters
[in]cContainer of list elements.
[in]idxIndex list beginning with multiple index.
[in]nameString form of expression being evaluated.
[in]depthDepth of indexing dimension.
Returns
Result of indexing array.

Definition at line 377 of file rvalue.hpp.

int stan::model::rvalue_at ( int  n,
const index_multi idx 
)
inline

Return the index in the underlying array corresponding to the specified position in the specified multi-index.

Parameters
[in]nRelative index position (from 0).
[in]idxIndex (from 1).
Returns
Underlying index position (from 1).

Definition at line 21 of file rvalue_at.hpp.

int stan::model::rvalue_at ( int  n,
const index_omni idx 
)
inline

Return the index in the underlying array corresponding to the specified position in the specified omni-index.

Parameters
[in]nRelative index position (from 0).
[in]idxIndex (from 1).
Returns
Underlying index position (from 1).

Definition at line 33 of file rvalue_at.hpp.

int stan::model::rvalue_at ( int  n,
const index_min idx 
)
inline

Return the index in the underlying array corresponding to the specified position in the specified min-index.

All indexing begins from 1.

Parameters
[in]nRelative index position (from 0).
[in]idxIndex (from 1)
Returns
Underlying index position (from 1).

Definition at line 47 of file rvalue_at.hpp.

int stan::model::rvalue_at ( int  n,
const index_max idx 
)
inline

Return the index in the underlying array corresponding to the specified position in the specified max-index.

All indexing begins from 1.

Parameters
[in]nRelative index position (from 0).
[in]idxIndex (from 1).
Returns
Underlying index position (from 1).

Definition at line 61 of file rvalue_at.hpp.

int stan::model::rvalue_at ( int  n,
const index_min_max idx 
)
inline

Return the index in the underlying array corresponding to the specified position in the specified min-max-index.

All indexing begins from 1.

Parameters
[in]nRelative index position (from 0).
[in]idxIndex (from 1).
Returns
Underlying index position (from 1).

Definition at line 75 of file rvalue_at.hpp.

int stan::model::rvalue_index_size ( const index_multi idx,
int  size 
)
inline

Return size of specified multi-index.

Parameters
[in]idxInput index (from 1).
[in]sizeSize of container (ignored here).
Returns
Size of result.

Definition at line 19 of file rvalue_index_size.hpp.

int stan::model::rvalue_index_size ( const index_omni idx,
int  size 
)
inline

Return size of specified omni-index for specified size of input.

Parameters
[in]idxInput index (from 1).
[in]sizeSize of container.
Returns
Size of result.

Definition at line 31 of file rvalue_index_size.hpp.

int stan::model::rvalue_index_size ( const index_min idx,
int  size 
)
inline

Return size of specified min index for specified size of input.

Parameters
[in]idxInput index (from 1).
[in]sizeSize of container.
Returns
Size of result.

Definition at line 43 of file rvalue_index_size.hpp.

int stan::model::rvalue_index_size ( const index_max idx,
int  size 
)
inline

Return size of specified max index.

Parameters
[in]idxInput index (from 1).
[in]sizeSize of container (ignored).
Returns
Size of result.

Definition at line 54 of file rvalue_index_size.hpp.

int stan::model::rvalue_index_size ( const index_min_max idx,
int  size 
)
inline

Return size of specified min-max index.

Parameters
[in]idxInput index (from 1).
[in]sizeSize of container (ignored).
Returns
Size of result.

Definition at line 65 of file rvalue_index_size.hpp.

template<bool propto, bool jacobian_adjust_transform, class M >
int stan::model::test_gradients ( const M &  model,
std::vector< double > &  params_r,
std::vector< int > &  params_i,
double  epsilon,
double  error,
stan::interface_callbacks::writer::base_writer writer 
)

Test the log_prob_grad() function's ability to produce accurate gradients using finite differences.

This shouldn't be necessary when using autodiff, but is useful for finding bugs in hand-written code (or var).

Template Parameters
proptoTrue if calculation is up to proportion (double-only terms dropped).
jacobian_adjust_transformTrue if the log absolute Jacobian determinant of inverse parameter transforms is added to the log probability.
MClass of model.
Parameters
modelModel.
params_rReal-valued parameter vector.
params_iInteger-valued parameter vector.
epsilonReal-valued scalar saying how much to perturb. Reasonable value is 1e-6.
errorReal-valued scalar saying how much error to allow. Reasonable value is 1e-6.
writerWriter for messages
Returns
number of failed gradient comparisons versus allowed error, so 0 if all gradients pass

Definition at line 278 of file util.hpp.


     [ Stan Home Page ] © 2011–2016, Stan Development Team.