Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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 
6 namespace stan {
7 
8  namespace math {
9 
10 
20  template <typename T1, typename T2>
22  public:
29  container_view(const T1& x, T2* y) : y_(y) { }
30 
39  T2& operator[](int i) {
40  return y_[0];
41  }
42  private:
43  T2* y_;
44  };
45 
52  struct dummy { };
53 
61  template <typename T2>
62  class container_view<dummy, T2> {
63  public:
65  template <typename T1>
66 
73  container_view(const T1& x, scalar_t* y) { }
74 
81  scalar_t operator[](int n) const {
82  throw std::out_of_range("can't access dummy elements.");
83  }
84  };
85  }
86 }
87 
88 #endif
container_view(const T1 &x, T2 *y)
Constructor.
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:38
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...
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–2015, Stan Development Team.