| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/meta/scalar_type.hpp>
5 #include <stdexcept>
6
7 namespace stan {
8
9 namespace math {
10
11
21 template <typename T1, typename T2>
22 class container_view {
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:
65 typedef typename stan::scalar_type<T2>::type scalar_t;
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
stan::math::container_view::container_view
container_view(const T1 &x, T2 *y)
Constructor.
Definition: container_view.hpp:30
stan
Definition: log_sum_exp.hpp:8
stan::scalar_type::type
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:35
stan::math::dummy
Empty struct for use in boost::condtional::value, T1, dummy>::type as false co...
Definition: container_view.hpp:53
stan::math::container_view< dummy, T2 >::scalar_t
stan::scalar_type< T2 >::type scalar_t
Definition: container_view.hpp:65
stan::math::container_view::operator[]
T2 & operator[](int i)
operator[](int i) returns reference to view, indexed by i Specialization handle appropriate broadcast...
Definition: container_view.hpp:40
stan::math::container_view< dummy, T2 >::operator[]
scalar_t operator[](int n) const
operator[](int i) throws exception
Definition: container_view.hpp:82
stan::math::container_view< dummy, T2 >::container_view
container_view(const T1 &x, scalar_t *y)
Nothing initialized.
Definition: container_view.hpp:74
stan::math::out_of_range
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.
Definition: out_of_range.hpp:30
scalar_type.hpp
stan::math::container_view
Primary template class for container view of array y with same structure as T1 and size as x...
Definition: container_view.hpp:22

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