| Stan Math Library 2.12.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 namespace math {
9
18 template <typename T1, typename T2>
19 class container_view {
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:
62 typedef typename stan::scalar_type<T2>::type scalar_t;
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
stan::math::container_view::container_view
container_view(const T1 &x, T2 *y)
Constructor.
Definition: container_view.hpp:27
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:34
stan::math::dummy
Empty struct for use in boost::condtional::value, T1, dummy>::type as false co...
Definition: container_view.hpp:50
stan::math::container_view< dummy, T2 >::scalar_t
stan::scalar_type< T2 >::type scalar_t
Definition: container_view.hpp:62
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:37
stan::math::container_view< dummy, T2 >::operator[]
scalar_t operator[](int n) const
operator[](int i)
Definition: container_view.hpp:79
stan::math::container_view< dummy, T2 >::container_view
container_view(const T1 &x, scalar_t *y)
Nothing initialized.
Definition: container_view.hpp:71
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:31
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:19

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