mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
initialize Discrete distribution with sequence of integers
This commit is contained in:
parent
e24aa7b8f7
commit
2d20cd31f2
2 changed files with 14 additions and 0 deletions
|
|
@ -39,6 +39,7 @@ class Discrete : public Distribution {
|
|||
public:
|
||||
explicit Discrete(pugi::xml_node node);
|
||||
Discrete(const double* x, const double* p, int n);
|
||||
Discrete(const double* p, int n);
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
|
|||
|
|
@ -41,6 +41,19 @@ Discrete::Discrete(const double* x, const double* p, int n)
|
|||
this->init_alias(x_vec, p_vec);
|
||||
}
|
||||
|
||||
Discrete::Discrete(const double* p, int n)
|
||||
{
|
||||
std::vector<double> p_vec(p, p + n);
|
||||
std::vector<double> x_vec(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
x_vec[i] = i;
|
||||
}
|
||||
|
||||
this->init_alias(x_vec, p_vec);
|
||||
}
|
||||
|
||||
void Discrete::init_alias(vector<double>& x, vector<double>& p)
|
||||
{
|
||||
x_ = x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue