SST  14.1.0
StructuralSimulationToolkit
constant.h
1 // Copyright 2009-2024 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-2024, 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 using namespace SST::RNG;
19 
20 namespace SST {
21 namespace RNG {
22 
23 /**
24  \class ConstantDistribution constant.h "sst/core/rng/constant.h"
25 
26  Implements a distribution which always returns a constant value (provided by the user). This
27  can be used in situations where the user may not want to apply a distribution.
28 */
30 {
31 
32 public:
33  /**
34  Creates a constant distribution which returns a constant value.
35  \param v Is the constant value the user wants returned by the distribution
36  */
37  ConstantDistribution(double v) : RandomDistribution() { mean = v; }
38 
39  /**
40  Destroys the constant distribution
41  */
43 
44  /**
45  Gets the next double for the distribution, in this case it will return the constant
46  value specified by the user
47  \return Constant value specified by the user when creating the class
48  */
49  double getNextDouble() override { return mean; }
50 
51  /**
52  Gets the constant value for the distribution
53  \return Constant value specified by the user when creating the class
54  */
55  double getMean() { return mean; }
56 
57  /**
58  Default constructor. FOR SERIALIZATION ONLY.
59  */
61 
62  /**
63  Serialization function for checkpoint
64  */
65  void serialize_order(SST::Core::Serialization::serializer& ser) override { ser& mean; }
66 
67  /**
68  Serialization macro
69  */
70  ImplementSerializable(SST::RNG::ConstantDistribution)
71 
72 protected:
73  /**
74  Describes the constant value to return from the distribution.
75  */
76  double mean;
77 };
78 
80 
81 } // namespace RNG
82 } // namespace SST
83 
84 #endif // SST_CORE_RNG_CONSTANT_H
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:43
Definition: action.cc:18
void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization function for checkpoint.
Definition: constant.h:65
double getNextDouble() override
Gets the next double for the distribution, in this case it will return the constant value specified b...
Definition: constant.h:49
ConstantDistribution()
Default constructor.
Definition: constant.h:60
double getMean()
Gets the constant value for the distribution.
Definition: constant.h:55
~ConstantDistribution()
Destroys the constant distribution.
Definition: constant.h:42
Base class of statistical distributions in SST.
Definition: distrib.h:24
Implements a distribution which always returns a constant value (provided by the user).
Definition: constant.h:29
ConstantDistribution(double v)
Creates a constant distribution which returns a constant value.
Definition: constant.h:37