MCPcopy Create free account
hub / github.com/Tencent/embedx / AliasSampling

Class AliasSampling

src/sampler/sampling/alias_sampling.cc:22–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace embedx {
21
22class AliasSampling : public Sampling {
23 private:
24 vec_float_t alias_probs_;
25 vec_int_t alias_tables_;
26
27 public:
28 static std::unique_ptr<Sampling> Create(const vec_float_t& probs);
29
30 public:
31 int_t Next() const noexcept override;
32 int_t Next(int begin, int end) const noexcept override;
33
34 private:
35 // Always return true.
36 bool Init(const vec_float_t& probs);
37
38 void Clear() noexcept {
39 alias_probs_.clear();
40 alias_tables_.clear();
41 }
42
43 void Resize(size_t size) {
44 alias_probs_.resize(size, 0);
45 alias_tables_.resize(size, 0);
46 }
47};
48
49std::unique_ptr<Sampling> AliasSampling::Create(const vec_float_t& probs) {
50 std::unique_ptr<Sampling> sampling(new AliasSampling);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected