27 template<
typename C>
requires std::ranges::range<C>
43 inline constexpr cdf(
const C& samples) :
_cdf(samples)
59 if(&src ==
this)
return *
this;
65 inline size_t size(
void)
const {
return _cdf.size(); }
88 mask &= bbm::cast<index_mask_t<index_type>>((xi >= 0) && (xi <= 1));
97 value_type prev = bbm::lookup<value_type>(
_cdf, idx-1, mask && (idx >= 1));
103 return make_named<
"index",
"pdf",
"residual">(idx,
pdf, residual);
113 inline auto pdf(
const index_type& idx, index_mask_t<index_type> mask=
true)
const
119 value_type prev = bbm::lookup<value_type>(
_cdf, idx-1, mask && (idx >= 1));
122 return (eval - prev);
Extensions for STL iterators/ranges.
Definition: aggregatebsdf.h:29
constexpr named< anonymize_t< T >, NAMES... > make_named(T &&t)
Make a named of a gettable type (with size == #NAMES); renames if the type is a named container.
Definition: named.h:293
constexpr auto select(MASK &&mask, const A &a, const A &b)
Definition: backbone.h:255
auto end(T &&t)
Definition: iterator_util.h:43
size_t size(T &&t)
Definition: iterator_util.h:22
std::decay_t< decltype(*bbm::begin(std::declval< T >()))> iterable_value_t
Definition: iterator_util.h:61
auto begin(T &&t)
Definition: iterator_util.h:29
CDF data structure.
Definition: cdf.h:29
size_t size(void) const
number of samples
Definition: cdf.h:65
bbm::iterable_value_t< C > value_type
Definition: cdf.h:30
std::decay_t< C > _cdf
Data.
Definition: cdf.h:129
index_t< value_type > index_type
Definition: cdf.h:31
constexpr cdf(const cdf &src)
Copy Constructor.
Definition: cdf.h:54
auto sample(const value_type &xi, index_mask_t< index_type > mask=true) const
sample the CDF given a random variable xi
Definition: cdf.h:85
constexpr cdf(void)
Trivial constructor.
Definition: cdf.h:34
constexpr cdf operator=(const cdf &src)
Assigmemnt.
Definition: cdf.h:57
auto pdf(const index_type &idx, index_mask_t< index_type > mask=true) const
querry the PDF that an index will be sampled.
Definition: cdf.h:113
constexpr cdf(const C &samples)
Constructor.
Definition: cdf.h:43
A wrapper for STL containers such as tuple, pair, and array. These containers force the programmer to...