SST  15.1.0
StructuralSimulationToolkit
constant.h
1 // Copyright 2009-2025 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2025, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_RNG_CONSTANT_H
13 #define SST_CORE_RNG_CONSTANT_H
14 
15 #include "distrib.h"
16 #include "math.h"
17 
18 namespace SST::RNG {
19 
20 /**
21  \class ConstantDistribution constant.h "sst/core/rng/constant.h"
22 
23  Implements a distribution which always returns a constant value (provided by the user). This
24  can be used in situations where the user may not want to apply a distribution.
25 */
27 {
28 
29 public:
30  /**
31  Creates a constant distribution which returns a constant value.
32  \param v Is the constant value the user wants returned by the distribution
33  */
34  explicit ConstantDistribution(double v) :
36  {
37  mean = v;
38  }
39 
40  /**
41  Destroys the constant distribution
42  */
44 
45  /**
46  Gets the next double for the distribution, in this case it will return the constant
47  value specified by the user
48  \return Constant value specified by the user when creating the class
49  */
50  double getNextDouble() override { return mean; }
51 
52  /**
53  Gets the constant value for the distribution
54  \return Constant value specified by the user when creating the class
55  */
56  double getMean() { return mean; }
57 
58  /**
59  Default constructor. FOR SERIALIZATION ONLY.
60  */
63  {}
64 
65  /**
66  Serialization function for checkpoint
67  */
68  void serialize_order(SST::Core::Serialization::serializer& ser) override { SST_SER(mean); }
69 
70  /**
71  Serialization macro
72  */
73  ImplementSerializable(SST::RNG::ConstantDistribution)
74 
75 protected:
76  /**
77  Describes the constant value to return from the distribution.
78  */
79  double mean;
80 };
81 
82 } // namespace SST::RNG
83 
85 
86 #endif // SST_CORE_RNG_CONSTANT_H
Definition: constant.h:18
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:42
void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization function for checkpoint.
Definition: constant.h:68
double getNextDouble() override
Gets the next double for the distribution, in this case it will return the constant value specified b...
Definition: constant.h:50
ConstantDistribution()
Default constructor.
Definition: constant.h:61
double getMean()
Gets the constant value for the distribution.
Definition: constant.h:56
~ConstantDistribution()
Destroys the constant distribution.
Definition: constant.h:43
Base class of statistical distributions in SST.
Definition: distrib.h:23
Implements a distribution which always returns a constant value (provided by the user).
Definition: constant.h:26
ConstantDistribution(double v)
Creates a constant distribution which returns a constant value.
Definition: constant.h:34