Stan Math Library  2.15.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  namespace math {
9 
18  template <typename T1, typename T2>
20  public:
27  container_view(const T1& x, T2* y) : y_(y) { }
28 
37  T2& operator[](int i) {
38  return y_[0];
39  }
40  private:
41  T2* y_;
42  };
43 
50  struct dummy { };
51 
59  template <typename T2>
60  class container_view<dummy, T2> {
61  public:
63  template <typename T1>
64 
71  container_view(const T1& x, scalar_t* y) { }
72 
79  scalar_t operator[](int n) const {
80  throw std::out_of_range("can't access dummy elements.");
81  }
82  };
83  }
84 }
85 
86 #endif
container_view(const T1 &x, T2 *y)
Constructor.
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:34
Empty struct for use in boost::condtional<is_constant_struct<T1>::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...
container_view(const T1 &x, scalar_t *y)
Nothing initialized.
scalar_t operator[](int n) const
operator[](int i)
void out_of_range(const char *function, int max, 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.