Stan  2.10.0
probability, sampling & optimization
rvalue_return.hpp
Go to the documentation of this file.
1 #ifndef STAN_MODEL_INDEXING_RVALUE_RETURN_HPP
2 #define STAN_MODEL_INDEXING_RVALUE_RETURN_HPP
3 
4 #include <Eigen/Dense>
7 #include <vector>
8 
9 namespace stan {
10 
11  namespace model {
12 
25  template <typename C, typename L>
26  struct rvalue_return {
27  };
28 
36  template <typename C>
41  typedef C type;
42  };
43 
44  // SINGLE INDEX
45 
56  template <typename T, typename I, int R, int C>
57  struct rvalue_return<Eigen::Matrix<T, R, C>,
58  cons_index_list<I, nil_index_list> > {
62  typedef Eigen::Matrix<T, R, C> type;
63  };
64 
71  template <typename T>
72  struct rvalue_return<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>,
73  cons_index_list<index_uni, nil_index_list> > {
77  typedef Eigen::Matrix<T, 1, Eigen::Dynamic> type;
78  };
79 
86  template <typename T>
87  struct rvalue_return<Eigen::Matrix<T, Eigen::Dynamic, 1>,
88  cons_index_list<index_uni, nil_index_list> > {
92  typedef T type;
93  };
94 
101  template <typename T>
102  struct rvalue_return<Eigen::Matrix<T, 1, Eigen::Dynamic>,
103  cons_index_list<index_uni, nil_index_list> > {
107  typedef T type;
108  };
109 
118  template <typename T, typename I1, typename I2>
119  struct rvalue_return<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>,
120  cons_index_list<I1,
121  cons_index_list<I2,
122  nil_index_list> > > {
126  typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> type;
127  };
128 
136  template <typename T, typename I>
137  struct rvalue_return<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>,
138  cons_index_list<I,
139  cons_index_list<index_uni,
140  nil_index_list> > > {
144  typedef Eigen::Matrix<T, Eigen::Dynamic, 1> type;
145  };
146 
154  template <typename T, typename I>
155  struct rvalue_return<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>,
156  cons_index_list<index_uni,
157  cons_index_list<I,
158  nil_index_list> > > {
162  typedef Eigen::Matrix<T, 1, Eigen::Dynamic> type;
163  };
164 
171  template <typename T>
172  struct rvalue_return<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>,
173  cons_index_list<index_uni,
174  cons_index_list<index_uni,
175  nil_index_list> > > {
179  typedef T type;
180  };
181 
191  template <typename C, typename I, typename L>
192  struct rvalue_return<std::vector<C>, cons_index_list<I, L> > {
198  typedef std::vector<typename rvalue_return<C, L>::type> type;
199  };
200 
201 
210  template <typename C, typename L>
211  struct rvalue_return<std::vector<C>, cons_index_list<index_uni, L> > {
216  typedef typename rvalue_return<C, L>::type type;
217  };
218 
219  }
220 }
221 #endif
Primary template class for metaprogram to calculate return value for model::rvalue() for the containe...
C type
Return type is the container or scalar type.
Probability, optimization and sampling library.
Template specification of functions in std for Stan.
Eigen::Matrix< T, Eigen::Dynamic, 1 > type
Return type is vector with same scalar type as matrix container.
rvalue_return< C, L >::type type
Return type is calculated recursively as the rvalue return for the element type C and following index...
Template structure for an index list consisting of a head and tail index.
Definition: index_list.hpp:23
std::vector< typename rvalue_return< C, L >::type > type
Return type is calculated recursively as a standard vector of the rvalue return for the element type ...
Structure for an empty (size zero) index list.
Definition: index_list.hpp:11
Eigen::Matrix< T, R, C > type
Return type is the matrix container type.
Eigen::Matrix< T, 1, Eigen::Dynamic > type
Return type is row vector with same scalar type as matrix container.

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