autoppl  v0.8
A C++ template library for probabilistic programming
dist_expr_traits.hpp
Go to the documentation of this file.
1 #pragma once
2 #if __cplusplus <= 201703L
4 #endif
7 #include <cstdint>
8 #include <cstddef>
9 
10 namespace ppl {
11 namespace util {
12 
13 using dist_value_t = double;
14 using cont_param_t = double;
15 using disc_param_t = int32_t;
16 
22 template <class T>
24 {
25  using BaseCRTP<T>::self;
27 };
28 
29 template <class T>
30 inline constexpr bool dist_expr_is_base_of_v =
31  std::is_base_of_v<DistExprBase<T>, T>;
32 
38 template <class DistExprType>
40 {
41  using value_t = typename DistExprType::value_t;
43  static constexpr bool is_cont_v = util::is_cont_v<value_t>;
44  static constexpr bool is_disc_v = util::is_disc_v<value_t>;
45 
46  static_assert(is_cont_v == !is_disc_v,
48 };
49 
50 #if __cplusplus <= 201703L
51 
55 template <class T>
56 inline constexpr bool is_dist_expr_v =
57  dist_expr_is_base_of_v<T> &&
58  has_type_value_t_v<T> &&
59  has_type_dist_value_t_v<T>
60  ;
61 
62 #else
63 
64 template <class T>
65 concept dist_expr_c =
66  dist_expr_is_base_of_v<T> &&
67  requires () {
71  }
72  ;
73 
74 template <class T>
75 concept is_dist_expr_v = dist_expr_c<T>;
76 
77 #endif
78 
79 } // namespace util
80 } // namespace ppl
var_traits.hpp
PPL_CONT_XOR_DISC
#define PPL_CONT_XOR_DISC
Definition: type_traits.hpp:42
type_traits.hpp
ppl::util::is_dist_expr_v
constexpr bool is_dist_expr_v
Definition: dist_expr_traits.hpp:56
ppl::util::DistExprBase
Definition: dist_expr_traits.hpp:24
ppl::util::dist_expr_traits
Definition: dist_expr_traits.hpp:40
ppl::util::dist_expr_traits::is_cont_v
static constexpr bool is_cont_v
Definition: dist_expr_traits.hpp:43
ppl::util::BaseCRTP
Definition: type_traits.hpp:65
ppl::util::disc_param_t
int32_t disc_param_t
Definition: dist_expr_traits.hpp:15
ppl::util::dist_expr_is_base_of_v
constexpr bool dist_expr_is_base_of_v
Definition: dist_expr_traits.hpp:30
ppl::util::dist_expr_traits::value_t
typename DistExprType::value_t value_t
Definition: dist_expr_traits.hpp:41
ppl::util::dist_expr_traits::dist_value_t
typename DistExprType::dist_value_t dist_value_t
Definition: dist_expr_traits.hpp:42
ppl::util::DistExprBase< Cauchy< LocType, ScaleType > >::dist_value_t
util::dist_value_t dist_value_t
Definition: dist_expr_traits.hpp:26
ppl::util::cont_param_t
double cont_param_t
Definition: dist_expr_traits.hpp:14
ppl::util::dist_expr_traits::is_disc_v
static constexpr bool is_disc_v
Definition: dist_expr_traits.hpp:44
ppl::util::dist_value_t
double dist_value_t
Definition: dist_expr_traits.hpp:13
ppl
Definition: bounded.hpp:11
concept.hpp