Stan  2.10.0
probability, sampling & optimization
chained_var_context.hpp
Go to the documentation of this file.
1 #ifndef STAN_IO_CHAINED_VAR_CONTEXT_HPP
2 #define STAN_IO_CHAINED_VAR_CONTEXT_HPP
3 
5 #include <string>
6 #include <vector>
7 
8 namespace stan {
9  namespace io {
10 
16  private:
17  const var_context& vc1_;
18  const var_context& vc2_;
19 
20  public:
22  vc1_(v1), vc2_(v2) {
23  }
24 
25  bool contains_i(const std::string& name) const {
26  return vc1_.contains_i(name) || vc2_.contains_i(name);
27  }
28 
29  bool contains_r(const std::string& name) const {
30  return vc1_.contains_r(name) || vc2_.contains_r(name);
31  }
32 
33  std::vector<double> vals_r(const std::string& name) const {
34  return vc1_.contains_r(name) ? vc1_.vals_r(name) : vc2_.vals_r(name);
35  }
36 
37  std::vector<int> vals_i(const std::string& name) const {
38  return vc1_.contains_i(name) ? vc1_.vals_i(name) : vc2_.vals_i(name);
39  }
40 
41  std::vector<size_t> dims_r(const std::string& name) const {
42  return vc1_.contains_r(name) ? vc1_.dims_r(name) : vc2_.dims_r(name);
43  }
44 
45  std::vector<size_t> dims_i(const std::string& name) const {
46  return vc1_.contains_r(name) ? vc1_.dims_i(name) : vc2_.dims_i(name);
47  }
48 
49  void names_r(std::vector<std::string>& names) const {
50  vc1_.names_r(names);
51  std::vector<std::string> names2;
52  vc2_.names_r(names2);
53  names.insert(names.end(), names2.begin(), names2.end());
54  }
55 
56  void names_i(std::vector<std::string>& names) const {
57  vc1_.names_i(names);
58  std::vector<std::string> names2;
59  vc2_.names_i(names2);
60  names.insert(names.end(), names2.begin(), names2.end());
61  }
62  };
63  }
64 }
65 
66 #endif
std::vector< double > vals_r(const std::string &name) const
Return the floating point values for the variable of the specified variable name in last-index-major ...
Probability, optimization and sampling library.
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 emp...
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 ...
virtual bool contains_r(const std::string &name) const =0
Return true if the specified variable name is defined.
virtual bool contains_i(const std::string &name) const =0
Return true if the specified variable name has integer values.
void names_i(std::vector< std::string > &names) const
Return a list of the names of the integer variables in the context.
std::vector< size_t > dims_i(const std::string &name) const
Return the dimensions of the specified floating point variable.
bool contains_i(const std::string &name) const
Return true if the specified variable name has integer values.
virtual void names_i(std::vector< std::string > &names) const =0
Return a list of the names of the integer variables in the context.
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.
std::vector< int > vals_i(const std::string &name) const
Return the integer values for the variable of the specified name in last-index-major order or the emp...
A var_reader reads array variables of integer and floating point type by name and dimension...
Definition: var_context.hpp:29
bool contains_r(const std::string &name) const
Return true if the specified variable name is defined.
void names_r(std::vector< std::string > &names) const
Return a list of the names of the floating point variables in the context.
std::vector< size_t > dims_r(const std::string &name) const
Return the dimensions for the specified floating point variable.
chained_var_context(const var_context &v1, const var_context &v2)
virtual std::vector< size_t > dims_r(const std::string &name) const =0
Return the dimensions for the specified floating point variable.
A chained_var_context object represents two objects of var_context as one.
virtual std::vector< size_t > dims_i(const std::string &name) const =0
Return the dimensions of the specified floating point variable.

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