Stan Math Library  2.11.0
reverse mode automatic differentiation
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 
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
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
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
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:35
(Expert) Numerical traits for algorithmic differentiation variables.
boost::add_const< typename scalar_type< T >::type >::type scalar_t
Definition: VectorView.hpp:30
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.