autoppl
v0.8
A C++ template library for probabilistic programming
|
Go to the documentation of this file.
2 #include <fastad_bits/reverse/core/constant.hpp>
5 #define PPL_CONSTANT_SHAPE_UNSUPPORTED \
6 "Unsupported shape for constants. "
12 template <
class ValueType
16 static_assert(!util::is_shape_v<ShapeType>,
20 template <
class ValueType>
26 static constexpr
bool has_param =
false;
35 constexpr
size_t size()
const {
return 1; }
37 template <
class PtrPackType>
38 auto ad(
const PtrPackType&)
const
39 {
return ad::constant(c_); }
47 template <
class ValueType>
53 static constexpr
bool has_param =
false;
56 Constant(
const Eigen::EigenBase<T>& c) : c_{c} {}
61 const auto&
eval()
const {
return c_; }
62 const auto&
get()
const {
return c_; }
63 size_t size()
const {
return c_.size(); }
64 size_t rows()
const {
return c_.rows(); }
65 constexpr
size_t cols()
const {
return 1; }
67 template <
class PtrPackType>
68 auto ad(
const PtrPackType&)
const
69 {
return ad::constant_view(c_.data(),
rows()); }
74 Eigen::Matrix<value_t, Eigen::Dynamic, 1> c_;
77 template <
class ValueType>
83 static constexpr
bool has_param =
false;
86 Constant(
const Eigen::EigenBase<T>& c) : c_{c} {}
91 const auto&
eval()
const {
return c_; }
92 const auto&
get()
const {
return c_; }
93 size_t size()
const {
return c_.size(); }
94 size_t rows()
const {
return c_.rows(); }
95 size_t cols()
const {
return c_.cols(); }
97 template <
class PtrPackType>
98 auto ad(
const PtrPackType&)
const
99 {
return ad::constant_view(c_.data(),
rows(),
cols()); }
104 Eigen::Matrix<value_t, Eigen::Dynamic, Eigen::Dynamic> c_;
111 #undef PPL_CONSTANT_VEC_UNSUPPORTED
112 #undef PPL_CONSTANT_MAT_UNSUPPORTED
void activate_refcnt() const
Definition: constant.hpp:101
ppl::mat shape_t
Definition: constant.hpp:82
void traverse(Func &&) const
Definition: constant.hpp:89
void activate_refcnt() const
Definition: constant.hpp:41
size_t rows() const
Definition: constant.hpp:64
size_t cols() const
Definition: constant.hpp:95
constexpr size_t cols() const
Definition: constant.hpp:65
size_t size() const
Definition: constant.hpp:93
auto ad(const PtrPackType &) const
Definition: constant.hpp:38
value_t eval() const
Definition: constant.hpp:33
void activate_refcnt() const
Definition: constant.hpp:71
void traverse(Func &&) const
Definition: constant.hpp:59
ad::vec vec
Definition: shape_traits.hpp:17
ValueType value_t
Definition: constant.hpp:24
ValueType value_t
Definition: constant.hpp:81
const auto & eval() const
Definition: constant.hpp:91
Constant(const Eigen::EigenBase< T > &c)
Definition: constant.hpp:86
value_t get() const
Definition: constant.hpp:34
constexpr size_t cols(const T &x)
Definition: value.hpp:42
Constant(const Eigen::EigenBase< T > &c)
Definition: constant.hpp:56
Definition: constant.hpp:15
ad::scl scl
Definition: shape_traits.hpp:16
auto ad(const PtrPackType &) const
Definition: constant.hpp:98
const auto & get() const
Definition: constant.hpp:92
Constant(value_t c)
Definition: constant.hpp:28
ppl::vec shape_t
Definition: constant.hpp:52
const auto & eval() const
Definition: constant.hpp:61
size_t rows() const
Definition: constant.hpp:94
void traverse(Func &&) const
Definition: constant.hpp:31
size_t size() const
Definition: constant.hpp:63
ValueType value_t
Definition: constant.hpp:51
#define PPL_CONSTANT_SHAPE_UNSUPPORTED
Definition: constant.hpp:5
auto ad(const PtrPackType &) const
Definition: constant.hpp:68
constexpr size_t size() const
Definition: constant.hpp:35
Definition: bounded.hpp:11
Definition: var_expr_traits.hpp:20
ad::mat mat
Definition: shape_traits.hpp:18
ppl::scl shape_t
Definition: constant.hpp:25
constexpr size_t rows(const T &x)
Definition: value.hpp:32
const auto & get() const
Definition: constant.hpp:62