12 #ifndef SST_CORE_RNG_DISCRETE_H 13 #define SST_CORE_RNG_DISCRETE_H 47 probabilities = (
double*)malloc(
sizeof(
double) * probsCount);
50 for ( uint32_t i = 0; i < probsCount; i++ ) {
51 probabilities[i] = prob_sum;
69 probabilities = (
double*)malloc(
sizeof(
double) * probsCount);
72 for ( uint32_t i = 0; i < probsCount; i++ ) {
73 probabilities[i] = prob_sum;
77 baseDistrib = baseDist;
78 deleteDistrib =
false;
88 if ( deleteDistrib ) {
delete baseDistrib; }
98 const double nextD = baseDistrib->nextUniform();
102 for ( ; index < probCount; index++ ) {
103 if ( probabilities[index] >= nextD ) {
break; }
106 return (
double)index;
123 if ( ser.mode() == SST::Core::Serialization::serializer::UNPACK ) {
124 probabilities = (
double*)malloc(
sizeof(
double) * probCount);
127 for ( uint32_t i = 0; i < probCount; i++ ) {
128 ser& probabilities[i];
164 #endif // SST_CORE_RNG_DISCRETE_H Implements the base class for random number generators for the SST core.
Definition: rng.h:29
Definition: constant.h:21
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
DiscreteDistribution(const double *probs, const uint32_t probsCount, SST::RNG::Random *baseDist)
Creates an exponential distribution with a specific lambda and a base random number generator...
Definition: discrete.h:64
double getNextDouble() override
Gets the next (random) double value in the distribution.
Definition: discrete.h:96
uint32_t probCount
Count of discrete probabilities.
Definition: discrete.h:156
Creates a discrete distribution for use within SST.
Definition: discrete.h:33
Implements a Mersenne-based RNG for use in the SST core or components.
Definition: mersenne.h:34
DiscreteDistribution(const double *probs, const uint32_t probsCount)
Creates a discrete probability distribution.
Definition: discrete.h:42
double * probabilities
The discrete probability list.
Definition: discrete.h:151
void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization function for checkpoint.
Definition: discrete.h:117
ImplementSerializable(SST::RNG::DiscreteDistribution) protected bool deleteDistrib
Serialization macro.
Definition: discrete.h:135
~DiscreteDistribution()
Destroys the exponential distribution.
Definition: discrete.h:84
DiscreteDistribution()
Default constructor.
Definition: discrete.h:112
Base class of statistical distributions in SST.
Definition: distrib.h:24