Stan Math Library  2.10.0
reverse mode automatic differentiation
container_view.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_CONTAINER_VIEW_HPP
2 #define STAN_MATH_PRIM_SCAL_META_CONTAINER_VIEW_HPP
3 
5 #include <stdexcept>
6 
7 namespace stan {
8 
9  namespace math {
10 
11 
21  template <typename T1, typename T2>
23  public:
30  container_view(const T1& x, T2* y) : y_(y) { }
31 
40  T2& operator[](int i) {
41  return y_[0];
42  }
43  private:
44  T2* y_;
45  };
46 
53  struct dummy { };
54 
62  template <typename T2>
63  class container_view<dummy, T2> {
64  public:
66  template <typename T1>
67 
74  container_view(const T1& x, scalar_t* y) { }
75 
82  scalar_t operator[](int n) const {
83  throw std::out_of_range("can't access dummy elements.");
84  }
85  };
86  }
87 }
88 
89 #endif
container_view(const T1 &x, T2 *y)
Constructor.
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:35
Empty struct for use in boost::condtional::value, T1, dummy>::type as false co...
stan::scalar_type< T2 >::type scalar_t
T2 & operator[](int i)
operator[](int i) returns reference to view, indexed by i Specialization handle appropriate broadcast...
scalar_t operator[](int n) const
operator[](int i) throws exception
container_view(const T1 &x, scalar_t *y)
Nothing initialized.
void out_of_range(const char *function, const int max, const int index, const char *msg1="", const char *msg2="")
Throw an out_of_range exception with a consistently formatted message.
Primary template class for container view of array y with same structure as T1 and size as x...

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