autoppl
v0.8
A C++ template library for probabilistic programming
|
Go to the documentation of this file.
4 #include <fastad_bits/reverse/stat/cauchy.hpp>
10 #define PPL_CAUCHY_PARAM_SHAPE \
11 "Cauchy parameters loc and scale must be either scalar or vector. "
22 template <
class LocType
27 util::is_shape_v<LocType> &&
28 util::is_shape_v<ScaleType> &&
29 !util::is_mat_v<LocType> &&
30 !util::is_mat_v<ScaleType>;
37 template <
class VarType
43 util::is_shape_v<VarType> &&
45 (util::is_scl_v<VarType> &&
46 util::is_scl_v<LocType> &&
47 util::is_scl_v<ScaleType>) ||
48 (util::is_vec_v<VarType> &&
53 template <
class LocType
58 template <
class VarType
78 template <
class LocType
83 using loc_t = LocType;
84 using scale_t = ScaleType;
86 static_assert(util::is_var_expr_v<loc_t>);
87 static_assert(util::is_var_expr_v<scale_t>);
88 static_assert(details::cauchy_valid_param_dim_v<loc_t, scale_t>,
100 : loc_{loc}, scale_{scale}
112 template <
class XType>
115 static_assert(util::is_dist_assignable_v<XType>);
116 static_assert(details::cauchy_valid_dim_v<XType, loc_t, scale_t>,
121 template <
class XType
124 const PtrPackType& pack)
const
126 return ad::cauchy_adj_log_pdf(x.ad(pack),
131 template <
class PtrPackType>
132 void bind(
const PtrPackType& pack)
134 static_cast<void>(pack);
135 if constexpr (loc_t::has_param) {
138 if constexpr (scale_t::has_param) {
145 loc_.activate_refcnt();
146 scale_.activate_refcnt();
149 template <
class XType,
class GenType>
150 constexpr
bool prune(XType&, GenType&)
const {
return false; }
165 template <
class LocType,
class ScaleType
166 ,
class = std::enable_if_t<
167 util::is_valid_dist_param_v<LocType> &&
168 util::is_valid_dist_param_v<ScaleType>
170 inline constexpr
auto cauchy(
const LocType& loc_expr,
171 const ScaleType& scale_expr)
176 loc_t wrap_loc_expr = loc_expr;
177 scale_t wrap_scale_expr = scale_expr;
184 #undef PPL_CAUCHY_PARAM_SHAPE
static constexpr bool value
Definition: cauchy.hpp:26
auto ad_log_pdf(const XType &x, const PtrPackType &pack) const
Definition: cauchy.hpp:123
Definition: dist_expr_traits.hpp:24
Definition: cauchy.hpp:81
constexpr bool prune(XType &, GenType &) const
Definition: cauchy.hpp:150
Definition: cauchy.hpp:25
constexpr bool cauchy_valid_param_dim_v
Definition: cauchy.hpp:55
constexpr bool cauchy_valid_dim_v
Definition: cauchy.hpp:61
util::dist_value_t dist_value_t
Definition: dist_expr_traits.hpp:26
void activate_refcnt() const
Definition: cauchy.hpp:143
#define PPL_CAUCHY_PARAM_SHAPE
Definition: cauchy.hpp:10
constexpr auto cauchy(const LocType &loc_expr, const ScaleType &scale_expr)
Definition: cauchy.hpp:170
util::dist_value_t dist_value_t
Definition: dist_expr_traits.hpp:26
double cont_param_t
Definition: dist_expr_traits.hpp:14
dist_value_t cauchy_log_pdf(const XType &x, const LocType &loc, const ScaleType &scale)
Definition: density.hpp:261
Cauchy(const loc_t &loc, const scale_t &scale)
Definition: cauchy.hpp:98
Definition: bounded.hpp:11
typename details::convert_to_param< T >::type convert_to_param_t
Definition: traits.hpp:148
static constexpr bool value
Definition: cauchy.hpp:42
dist_value_t log_pdf(const XType &x)
Definition: cauchy.hpp:113
void bind(const PtrPackType &pack)
Definition: cauchy.hpp:132
util::cont_param_t value_t
Definition: cauchy.hpp:94
#define PPL_DIST_SHAPE_MISMATCH
Definition: dist_utils.hpp:2
Definition: cauchy.hpp:41