35 #include <cugar/linalg/vector.h> 36 #include <cugar/linalg/matrix.h> 48 template <
typename TDistribution, u
int32 NCOMP>
57 typedef TDistribution distribution_type;
59 static const uint32 NUM_COMPONENTS = NCOMP;
67 for (uint32 i = 0; i < NUM_COMPONENTS; ++i)
68 weights[i] = 1.0f / NUM_COMPONENTS;
74 uint32
size()
const {
return NCOMP; }
82 for (uint32 i = 0; i < NCOMP; ++i)
83 p += weights[i] * comps[i].
density(x);
92 return comps[i].density(x);
98 CUGAR_HOST_DEVICE
const distribution_type&
component(
const uint32 i)
const {
return comps[i]; }
103 CUGAR_HOST_DEVICE distribution_type&
component(
const uint32 i) {
return comps[i]; }
108 CUGAR_HOST_DEVICE
void set_component(
const uint32 i,
const distribution_type& c,
const float w) { comps[i] = c; weights[i] = w; }
113 CUGAR_HOST_DEVICE
void set_component(
const uint32 i,
const distribution_type& c) { comps[i] = c; }
118 CUGAR_HOST_DEVICE
float weight(
const uint32 i)
const {
return weights[i]; }
123 CUGAR_HOST_DEVICE
void set_weight(
const uint32 i,
const float w) { weights[i] = w; }
126 TDistribution comps[NCOMP];
127 float weights[NCOMP];
CUGAR_HOST_DEVICE float density(const uint32 i, const Vector2f x) const
Definition: mixtures.h:90
CUGAR_HOST_DEVICE uint32 size() const
Definition: mixtures.h:74
CUGAR_HOST_DEVICE float density(const Vector2f x) const
Definition: mixtures.h:79
CUGAR_HOST_DEVICE const distribution_type & component(const uint32 i) const
Definition: mixtures.h:98
CUGAR_HOST_DEVICE void set_component(const uint32 i, const distribution_type &c, const float w)
Definition: mixtures.h:108
Definition: mixtures.h:55
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_HOST_DEVICE float weight(const uint32 i) const
Definition: mixtures.h:118
CUGAR_HOST_DEVICE void set_component(const uint32 i, const distribution_type &c)
Definition: mixtures.h:113
CUGAR_HOST_DEVICE Mixture()
Definition: mixtures.h:64
Defines several random samplers.
CUGAR_HOST_DEVICE distribution_type & component(const uint32 i)
Definition: mixtures.h:103
CUGAR_HOST_DEVICE void set_weight(const uint32 i, const float w)
Definition: mixtures.h:123