Stan  2.10.0
probability, sampling & optimization
Public Member Functions | Static Public Member Functions | List of all members
stan::io::var_context Class Referenceabstract

A var_reader reads array variables of integer and floating point type by name and dimension. More...

#include <var_context.hpp>

Inheritance diagram for stan::io::var_context:
stan::io::array_var_context stan::io::chained_var_context stan::io::dump stan::json::json_data

Public Member Functions

virtual ~var_context ()
 
virtual bool contains_r (const std::string &name) const =0
 Return true if the specified variable name is defined. More...
 
virtual std::vector< double > vals_r (const std::string &name) const =0
 Return the floating point values for the variable of the specified variable name in last-index-major order. More...
 
virtual std::vector< size_t > dims_r (const std::string &name) const =0
 Return the dimensions for the specified floating point variable. More...
 
virtual bool contains_i (const std::string &name) const =0
 Return true if the specified variable name has integer values. More...
 
virtual std::vector< int > vals_i (const std::string &name) const =0
 Return the integer values for the variable of the specified name in last-index-major order or the empty sequence if the variable is not defined. More...
 
virtual std::vector< size_t > dims_i (const std::string &name) const =0
 Return the dimensions of the specified floating point variable. More...
 
virtual void names_r (std::vector< std::string > &names) const =0
 Return a list of the names of the floating point variables in the context. More...
 
virtual void names_i (std::vector< std::string > &names) const =0
 Return a list of the names of the integer variables in the context. More...
 
void add_vec (std::stringstream &msg, const std::vector< size_t > &dims) const
 
void validate_dims (const std::string &stage, const std::string &name, const std::string &base_type, const std::vector< size_t > &dims_declared) const
 

Static Public Member Functions

static std::vector< size_t > to_vec ()
 
static std::vector< size_t > to_vec (size_t n1)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2, size_t n3)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2, size_t n3, size_t n4)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6, size_t n7)
 
static std::vector< size_t > to_vec (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6, size_t n7, size_t n8)
 

Detailed Description

A var_reader reads array variables of integer and floating point type by name and dimension.

An array's dimensionality is described by a sequence of (unsigned) integers. For instance, (7, 2, 3) picks out a 7 by 2 by 3 array. The empty dimensionality sequence () is used for scalars.

Multidimensional arrays are stored in column-major order, meaning the first index changes the most quickly.

If a variable has integer variables, it should return those integer values cast to floating point values when accessed through the floating-point methods.

Definition at line 29 of file var_context.hpp.

Constructor & Destructor Documentation

virtual stan::io::var_context::~var_context ( )
inlinevirtual

Definition at line 31 of file var_context.hpp.

Member Function Documentation

void stan::io::var_context::add_vec ( std::stringstream &  msg,
const std::vector< size_t > &  dims 
) const
inline

Definition at line 114 of file var_context.hpp.

virtual bool stan::io::var_context::contains_i ( const std::string &  name) const
pure virtual

Return true if the specified variable name has integer values.

Parameters
nameName of variable.
Returns
true if an integer variable of the specified name is defined.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

virtual bool stan::io::var_context::contains_r ( const std::string &  name) const
pure virtual

Return true if the specified variable name is defined.

This method should return true even if the values are all integers.

Parameters
nameName of variable.
Returns
true if the variable exists with real values.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

virtual std::vector<size_t> stan::io::var_context::dims_i ( const std::string &  name) const
pure virtual

Return the dimensions of the specified floating point variable.

If the variable doesn't exist (or if it is a scalar), the return result should be the empty vector.

Parameters
nameName of variable.
Returns
Sequence of dimensions for the variable.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

virtual std::vector<size_t> stan::io::var_context::dims_r ( const std::string &  name) const
pure virtual

Return the dimensions for the specified floating point variable.

If the variable doesn't exist or if it is a scalar, the return result should be the empty vector.

Parameters
nameName of variable.
Returns
Sequence of dimensions for the variable.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

virtual void stan::io::var_context::names_i ( std::vector< std::string > &  names) const
pure virtual

Return a list of the names of the integer variables in the context.

Parameters
namesVector to store the list of names in.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

virtual void stan::io::var_context::names_r ( std::vector< std::string > &  names) const
pure virtual

Return a list of the names of the floating point variables in the context.

Parameters
namesVector to store the list of names in.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

static std::vector<size_t> stan::io::var_context::to_vec ( )
inlinestatic

Definition at line 179 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1)
inlinestatic

Definition at line 182 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2 
)
inlinestatic

Definition at line 187 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2,
size_t  n3 
)
inlinestatic

Definition at line 193 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2,
size_t  n3,
size_t  n4 
)
inlinestatic

Definition at line 201 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2,
size_t  n3,
size_t  n4,
size_t  n5 
)
inlinestatic

Definition at line 210 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2,
size_t  n3,
size_t  n4,
size_t  n5,
size_t  n6 
)
inlinestatic

Definition at line 221 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2,
size_t  n3,
size_t  n4,
size_t  n5,
size_t  n6,
size_t  n7 
)
inlinestatic

Definition at line 233 of file var_context.hpp.

static std::vector<size_t> stan::io::var_context::to_vec ( size_t  n1,
size_t  n2,
size_t  n3,
size_t  n4,
size_t  n5,
size_t  n6,
size_t  n7,
size_t  n8 
)
inlinestatic

Definition at line 247 of file var_context.hpp.

void stan::io::var_context::validate_dims ( const std::string &  stage,
const std::string &  name,
const std::string &  base_type,
const std::vector< size_t > &  dims_declared 
) const
inline

Definition at line 124 of file var_context.hpp.

virtual std::vector<int> stan::io::var_context::vals_i ( const std::string &  name) const
pure virtual

Return the integer values for the variable of the specified name in last-index-major order or the empty sequence if the variable is not defined.

Parameters
nameName of variable.
Returns
Sequence of integer values.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.

virtual std::vector<double> stan::io::var_context::vals_r ( const std::string &  name) const
pure virtual

Return the floating point values for the variable of the specified variable name in last-index-major order.

This method should cast integers to floating point values if the values of the named variable are all integers.

If there is no variable of the specified name, the empty vector is returned.

Parameters
nameName of variable.
Returns
Sequence of values for the named variable.

Implemented in stan::io::dump, stan::io::array_var_context, stan::json::json_data, and stan::io::chained_var_context.


The documentation for this class was generated from the following file:

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