Stan Math Library  2.15.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 {
25  return c_[i];
26  }
27 
28  int size() const {
29  return c_.size();
30  }
31 
32  private:
33  const C& c_;
34  };
35 
41  template <typename T>
42  class scalar_seq_view<T, T> {
43  public:
44  explicit scalar_seq_view(const T& t) : t_(t) {}
45 
46  const T& operator[](int /* i */) const {
47  return t_;
48  }
49 
50  int size() const {
51  return 1;
52  }
53 
54  private:
55  const T& t_;
56  };
57 }
58 #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–2016, Stan Development Team.