Automatic Differentiation
 
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 {
9
21template <typename T, typename = void>
23
35template <typename T>
37 public:
38 explicit vector_seq_view(const T& m) : m_(m) {}
39 static constexpr auto size() { return 1; }
40 inline const auto& operator[](size_t /* i */) const noexcept { return m_; }
41
42 template <typename C = T, require_st_arithmetic<C>* = nullptr>
43 inline const auto& val(size_t /* i */) const noexcept {
44 return m_;
45 }
46
47 template <typename C = T, require_st_autodiff<C>* = nullptr>
48 inline auto val(size_t /* i */) const noexcept {
49 return m_.val();
50 }
51
52 private:
54};
55
56namespace internal {
57template <typename T>
60}
61
73template <typename T>
75 T, require_std_vector_vt<internal::is_matrix_or_std_vector, T>> {
76 public:
77 explicit vector_seq_view(const T& v) noexcept : v_(v) {}
78 inline auto size() const noexcept { return v_.size(); }
79
80 inline decltype(auto) operator[](size_t i) const { return v_[i]; }
81
82 template <typename C = T, require_st_arithmetic<C>* = nullptr>
83 inline decltype(auto) val(size_t i) const {
84 return v_[i];
85 }
86
87 template <typename C = T, require_st_autodiff<C>* = nullptr>
88 inline auto val(size_t i) const {
89 return value_of(v_[i]);
90 }
91
92 private:
93 const T& v_;
94};
95
96} // namespace stan
97
98#endif
const auto & operator[](size_t) const noexcept
This class provides a low-cost wrapper for situations where you either need an Eigen Vector or RowVec...
require_t< is_matrix< std::decay_t< T > > > require_matrix_t
Require type satisfies is_matrix.
Definition is_matrix.hpp:28
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
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base implementation for checking if type is std vector.
Definition is_vector.hpp:19
Extends std::false_type when instantiated with zero or more template parameters, all of which extend ...