| 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_MAT_SCAL_META_VECTORVIEW_HPP
2 #define STAN_MATH_MAT_SCAL_META_VECTORVIEW_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/meta/scalar_type.hpp>
6 #include <stan/math/prim/scal/meta/VectorView.hpp>
7 #include <boost/type_traits.hpp>
8
9 namespace stan {
10
11 template <typename T, int R, int C>
12 class VectorView<Eigen::Matrix<T, R, C>, true, false> {
13 public:
14 typedef typename scalar_type<T>::type scalar_t;
15
16 template <typename X>
17 explicit VectorView(X& x) : x_(x.data()) { }
18
19 scalar_t& operator[](int i) {
20 return x_[i];
21 }
22 private:
23 scalar_t* x_;
24 };
25
26 template <typename T, int R, int C>
27 class VectorView<const Eigen::Matrix<T, R, C>, true, false> {
28 public:
29 typedef typename boost::add_const<typename scalar_type<T>::type>::type
30 scalar_t;
31
32 template <typename X>
33 explicit VectorView(X& x) : x_(x.data()) { }
34
35 scalar_t& operator[](int i) const {
36 return x_[i];
37 }
38 private:
39 scalar_t* x_;
40 };
41
42 }
43 #endif
scalar_type.hpp
stan
Definition: log_sum_exp.hpp:8
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::VectorView< const Eigen::Matrix< T, R, C >, true, false >::VectorView
VectorView(X &x)
Definition: VectorView.hpp:33
stan::scalar_type::type
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:34
Eigen
(Expert) Numerical traits for algorithmic differentiation variables.
Definition: Eigen_NumTraits.hpp:9
stan::VectorView< Eigen::Matrix< T, R, C >, true, false >::scalar_t
scalar_type< T >::type scalar_t
Definition: VectorView.hpp:14
stan::VectorView< const Eigen::Matrix< T, R, C >, true, false >::scalar_t
boost::add_const< typename scalar_type< T >::type >::type scalar_t
Definition: VectorView.hpp:30
VectorView.hpp
Eigen.hpp
stan::VectorView< Eigen::Matrix< T, R, C >, true, false >::VectorView
VectorView(X &x)
Definition: VectorView.hpp:17
stan::VectorView< const Eigen::Matrix< T, R, C >, true, false >::operator[]
scalar_t & operator[](int i) const
Definition: VectorView.hpp:35
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::VectorView< Eigen::Matrix< T, R, C >, true, false >::operator[]
scalar_t & operator[](int i)
Definition: VectorView.hpp:19

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