mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Update mixture distribution
update storeage of c++ class update sampling -> uses std::lower_bound for O(log(N)) sampling of the distribution implemented from_xml_element updated settings.rst include a mixture in the regression tests
This commit is contained in:
parent
1c219600a1
commit
e7fa663b3d
7 changed files with 98 additions and 30 deletions
|
|
@ -243,13 +243,17 @@ public:
|
|||
//! \return Sampled value
|
||||
double sample(uint64_t* seed) const;
|
||||
|
||||
// d and p property
|
||||
const vector<UPtrDist>& d() const { return d_; }
|
||||
const vector<double>& p() const { return p_; }
|
||||
private:
|
||||
vector<UPtrDist> d_; //!< Pointer to sub-distributions
|
||||
vector<double> p_; //!< tabulated probability density
|
||||
vector<double> c_; //!< cumulative distribution
|
||||
struct Pair {
|
||||
double cummulative_probability_ {0.0};
|
||||
UPtrDist distribution_;
|
||||
// bool operator<(const Pair& o) const {
|
||||
// return cummulative_probability_ < o.cummulative_probability_;
|
||||
//}
|
||||
bool operator<(double p) const { return cummulative_probability_ < p; }
|
||||
};
|
||||
|
||||
vector<Pair> distribution_; //!< sub-distributions + cummulative probabilities
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue