| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

VectorView.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_ARR_SCAL_META_VECTORVIEW_HPP
2 #define STAN_MATH_ARR_SCAL_META_VECTORVIEW_HPP
3
4 #include <stan/math/prim/scal/meta/VectorView.hpp>
5 #include <vector>
6
7 namespace stan {
8
9 template <typename T>
10 class VectorView<std::vector<T>, true, false> {
11 public:
12 typedef typename scalar_type<T>::type scalar_t;
13
14 template <typename X>
15 explicit VectorView(X& x) : x_(&x[0]) { }
16
17 scalar_t& operator[](int i) {
18 return x_[i];
19 }
20
21 private:
22 scalar_t* x_;
23 };
24
25 template <typename T>
26 class VectorView<const std::vector<T>, true, false> {
27 public:
28 typedef typename boost::add_const<typename scalar_type<T>::type>::type
29 scalar_t;
30
31 template <typename X>
32 explicit VectorView(X& x) : x_(&x[0]) { }
33
34 scalar_t& operator[](int i) const {
35 return x_[i];
36 }
37 private:
38 scalar_t* x_;
39 };
40
41 }
42 #endif
stan::VectorView< std::vector< T >, true, false >::operator[]
scalar_t & operator[](int i)
Definition: VectorView.hpp:17
stan
Definition: log_sum_exp.hpp:8
std
Definition: std_numeric_limits.hpp:7
stan::VectorView::scalar_t
boost::conditional< boost::is_const< T >::value, typename boost::add_const< typename scalar_type< T >::type >::type, typename scalar_type< T >::type >::type scalar_t
Definition: VectorView.hpp:54
stan::scalar_type::type
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:34
VectorView.hpp
stan::VectorView< const std::vector< T >, true, false >::VectorView
VectorView(X &x)
Definition: VectorView.hpp:32
stan::VectorView< const std::vector< T >, true, false >::operator[]
scalar_t & operator[](int i) const
Definition: VectorView.hpp:34
stan::VectorView< std::vector< T >, true, false >::VectorView
VectorView(X &x)
Definition: VectorView.hpp:15
stan::VectorView< const std::vector< T >, true, false >::scalar_t
boost::add_const< typename scalar_type< T >::type >::type scalar_t
Definition: VectorView.hpp:29
stan::VectorView< std::vector< T >, true, false >::scalar_t
scalar_type< T >::type scalar_t
Definition: VectorView.hpp:12
stan::VectorView
VectorView is a template expression that is constructed with a container or scalar, which it then allows to be used as an array using operator[].
Definition: VectorView.hpp:48

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