Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
vector_seq_view.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_VECTOR_SEQ_VIEW_HPP
2#define STAN_MATH_PRIM_FUN_VECTOR_SEQ_VIEW_HPP
3
6#include <vector>
7
8namespace stan {
9namespace internal {
10template <typename T>
13
14template <typename T>
18} // namespace internal
19
31template <typename T, typename = void>
33
45template <typename T>
46class vector_seq_view<T, require_t<internal::is_scalar_container<T>>> {
47 public:
48 explicit vector_seq_view(const T& m) : m_(m) {}
49 static constexpr auto size() { return 1; }
50 inline const auto& operator[](size_t /* i */) const noexcept { return m_; }
51
52 template <typename C = T, require_st_arithmetic<C>* = nullptr>
53 inline const auto& val(size_t /* i */) const noexcept {
54 return m_;
55 }
56
57 template <typename C = T, require_st_autodiff<C>* = nullptr>
58 inline auto val(size_t /* i */) const noexcept {
59 return value_of(m_);
60 }
61
62 private:
64};
65
77template <typename T>
79 T, require_std_vector_vt<internal::is_matrix_or_std_vector, T>> {
80 public:
81 explicit vector_seq_view(const T& v) noexcept : v_(v) {}
82 inline auto size() const noexcept { return v_.size(); }
83
84 inline decltype(auto) operator[](size_t i) const { return v_[i]; }
85
86 template <typename C = T, require_st_arithmetic<C>* = nullptr>
87 inline decltype(auto) val(size_t i) const {
88 return v_[i];
89 }
90
91 template <typename C = T, require_st_autodiff<C>* = nullptr>
92 inline auto val(size_t i) const {
93 return value_of(v_[i]);
94 }
95
96 private:
97 const T& v_;
98};
99
100} // namespace stan
101
102#endif
This class provides a low-cost wrapper for situations where you either need an Eigen Vector or RowVec...
require_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check... > > require_std_vector_vt
Require type satisfies is_std_vector.
typename ref_type_if< true, T >::type ref_type_t
Definition ref_type.hpp:55
std::enable_if_t< Check::value > require_t
If condition is true, template is enabled.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Check if a type is derived from Eigen::EigenBase or is a var_value whose value_type is derived from E...
Definition is_matrix.hpp:18
Checks if decayed type is a var, fvar, or arithmetic.
Base implementation for checking if type is std vector.
Definition is_vector.hpp:19
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...
Extends std::false_type when instantiated with zero or more template parameters, all of which extend ...