autoppl
v0.8
A C++ template library for probabilistic programming
|
Go to the documentation of this file.
6 #include <fastad_bits/reverse/core/var_view.hpp>
15 ,
class TParamViewType
32 template <
class Derived>
35 template <
class ValueType
44 static constexpr
bool has_param =
true;
48 size_t cols=1) noexcept
54 template <
class VarExprType
55 ,
class = std::enable_if_t<
56 util::is_valid_op_param_v<VarExprType>
58 auto operator=(
const VarExprType& expr)
const
61 expr_t wrap_expr = expr;
63 static_cast<const derived_t&
>(*
this), wrap_expr);
71 template <
class UCValPtrType
78 CValPtrType>& pack)
const {
79 return ad::VarView<value_t, shape_t>(pack.tp_val + i_pack_->off_pack.tp_offset,
80 pack.tp_adj + i_pack_->off_pack.tp_offset,
85 i_pack_->off_pack = pack;
91 template <
class PtrPackType>
92 void bind(
const PtrPackType& pack)
94 static_cast<void>(pack);
95 if constexpr (std::is_convertible_v<typename PtrPackType::tp_val_ptr_t, value_t*>) {
97 util::bind(var_, tcp + i_pack_->off_pack.tp_offset,
110 using view_t = ad::util::shape_to_raw_view_t<value_t, shape_t>;
116 template <
class ValueType
124 using base_t::operator=;
128 size_t cols=1) noexcept
133 template <
class ValueType>
140 using base_t::operator=;
145 size_t rel_offset = 0) noexcept
147 , rel_offset_(rel_offset)
150 template <
class UCValPtrType
157 CValPtrType>& pack)
const {
164 template <
class PtrPackType>
165 void bind(
const PtrPackType& pack)
176 template <
class ValueType>
183 using base_t::operator=;
187 size_t cols=1) noexcept
197 template <
class ValueType
201 template <
class ValueType>
207 using base_t::operator=;
217 template <
class ValueType>
223 using typename base_t::value_t;
224 using base_t::operator=;
234 template <
class ValueType>
240 using base_t::operator=;
constexpr size_t size() const
Definition: tparam.hpp:104
auto ad(const util::PtrPack< UCValPtrType, UCAdjPtrType, value_t *, value_t *, CValPtrType > &pack) const
Definition: tparam.hpp:74
TParamViewBase(details::TParamInfoPack *i_pack, size_t rows=1, size_t cols=1) noexcept
Definition: tparam.hpp:46
void bind(const PtrPackType &pack)
Definition: tparam.hpp:92
util::var_t< value_t, shape_t > var_t
Definition: tparam.hpp:42
auto & get(T &&x)
Definition: value.hpp:52
void activate_refcnt() const
Definition: tparam.hpp:89
constexpr size_t cols() const
Definition: tparam.hpp:106
constexpr size_t rows() const
Definition: tparam.hpp:105
TParamView(details::TParamInfoPack *i_pack, size_t rows=1, size_t cols=1, size_t rel_offset=0) noexcept
Definition: tparam.hpp:142
ad::util::shape_to_raw_view_t< value_t, shape_t > view_t
Definition: tparam.hpp:110
ValueType value_t
Definition: tparam.hpp:39
const void * id_t
Definition: tparam.hpp:43
ad::vec vec
Definition: shape_traits.hpp:17
var_t & get()
Definition: tparam.hpp:102
TParamView(details::TParamInfoPack *i_pack, size_t rows, size_t cols=1) noexcept
Definition: tparam.hpp:185
util::OffsetPack off_pack
Definition: tparam.hpp:27
void bind(T &x, ValPtrType begin, size_t rows=1, size_t cols=1)
Definition: value.hpp:61
ShapeType shape_t
Definition: tparam.hpp:40
auto operator[](size_t i) const
Definition: tparam.hpp:191
constexpr size_t cols(const T &x)
Definition: value.hpp:42
ad::scl scl
Definition: shape_traits.hpp:16
Definition: tparam.hpp:122
void traverse(Func &&) const
Definition: tparam.hpp:67
constexpr size_t size(const T &x)
Definition: value.hpp:22
details::TParamInfoPack *const i_pack_
Definition: tparam.hpp:111
const var_t & eval()
Definition: tparam.hpp:69
void bind(const PtrPackType &pack)
Definition: tparam.hpp:165
TParam(size_t rows, size_t cols)
Definition: tparam.hpp:242
Definition: tparam.hpp:199
typename details::var< V, T >::type var_t
Definition: shape_traits.hpp:132
const var_t & get() const
Definition: tparam.hpp:103
auto ad(const util::PtrPack< UCValPtrType, UCAdjPtrType, typename base_t::value_t *, typename base_t::value_t *, CValPtrType > &pack) const
Definition: tparam.hpp:153
index_t tp_offset
Definition: offset_pack.hpp:14
void activate(util::OffsetPack &pack) const
Definition: tparam.hpp:84
id_t id() const
Definition: tparam.hpp:107
view_t var_
Definition: tparam.hpp:112
TParam(size_t n)
Definition: tparam.hpp:226
Definition: bounded.hpp:11
const id_t id_
Definition: tparam.hpp:113
Definition: var_expr_traits.hpp:20
ad::mat mat
Definition: shape_traits.hpp:18
Definition: tparam.hpp:33
typename details::convert_to_param< T >::type convert_to_param_t
Definition: traits.hpp:148
Definition: var_traits.hpp:20
Definition: tparam.hpp:26
TParam() noexcept
Definition: tparam.hpp:209
constexpr size_t rows(const T &x)
Definition: value.hpp:32
Definition: offset_pack.hpp:9
Definition: ptr_pack.hpp:14
TParamView(details::TParamInfoPack *i_pack, size_t rows=1, size_t cols=1) noexcept
Definition: tparam.hpp:126
constexpr auto make_val(size_t rows=1, size_t cols=1)
Definition: value.hpp:9