index_list.hpp
Go to the documentation of this file.
1 #ifndef STAN_MODEL_INDEXING_INDEX_LIST_HPP
2 #define STAN_MODEL_INDEXING_INDEX_LIST_HPP
3 
4 
5 namespace stan {
6  namespace model {
7 
8  /**
9  * Structure for an empty (size zero) index list.
10  */
11  struct nil_index_list {
12  };
13 
14 
15  /**
16  * Template structure for an index list consisting of a head and
17  * tail index.
18  *
19  * @tparam H type of index stored as the head of the list.
20  * @tparam T type of index list stored as the tail of the list.
21  */
22  template <typename H, typename T>
23  struct cons_index_list {
24  const H head_;
25  const T tail_;
26 
27  /**
28  * Construct a non-empty index list with the specified index for
29  * a head and specified index list for a tail.
30  *
31  * @param head Index for head.
32  * @param tail Index list for tail.
33  */
34  explicit cons_index_list(const H& head, const T& tail)
35  : head_(head),
36  tail_(tail) {
37  }
38  };
39 
40  // factory-like function does type inference for I and T
41  template <typename I, typename T>
43  cons_list(const I& idx1, const T& t) {
44  return cons_index_list<I, T>(idx1, t);
45  }
46 
47  inline nil_index_list
49  return nil_index_list();
50  }
51 
52  template <typename I>
54  index_list(const I& idx) {
55  return cons_list(idx, index_list());
56  }
57 
58  template <typename I1, typename I2>
60  index_list(const I1& idx1, const I2& idx2) {
61  return cons_list(idx1, index_list(idx2));
62  }
63 
64  template <typename I1, typename I2, typename I3>
65  inline
66  cons_index_list<I1,
67  cons_index_list<I2,
68  cons_index_list<I3,
69  nil_index_list> > >
70  index_list(const I1& idx1, const I2& idx2, const I3& idx3) {
71  return cons_list(idx1, index_list(idx2, idx3));
72  }
73 
74  }
75 }
76 #endif
Eigen::Matrix< T, Eigen::Dynamic, 1 > head(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, size_t n)
Definition: head.hpp:24
cons_index_list(const H &head, const T &tail)
Definition: index_list.hpp:34
nil_index_list index_list()
Definition: index_list.hpp:48
cons_index_list< I, T > cons_list(const I &idx1, const T &t)
Definition: index_list.hpp:43
def tail(path, window=20)
Definition: log_trawl.py:24
double T
Definition: Xdiff_gwt.C:5
const XML_Char XML_Content * model
Definition: expat.h:151