Stan Math Library  2.20.0
reverse mode automatic differentiation
scalar_seq_view.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_SCALAR_SEQ_VIEW_HPP
2 #define STAN_MATH_PRIM_SCAL_META_SCALAR_SEQ_VIEW_HPP
3 
5 
6 namespace stan {
14 template <typename C, typename T = typename scalar_type<C>::type>
16  public:
17  explicit scalar_seq_view(const C& c) : c_(c) {}
18 
24  const T& operator[](int i) const { return c_[i]; }
25 
26  int size() const { return c_.size(); }
27 
28  private:
29  const C& c_;
30 };
31 
37 template <typename T>
38 class scalar_seq_view<T, T> {
39  public:
40  explicit scalar_seq_view(const T& t) : t_(t) {}
41 
42  const T& operator[](int /* i */) const { return t_; }
43 
44  int size() const { return 1; }
45 
46  private:
47  const T& t_;
48 };
49 } // namespace stan
50 #endif
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
const T & operator[](int i) const
Segfaults if out of bounds.
const T & operator[](int) const

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