clcg32.h Source File

API: clcg32.h Source File
API
clcg32.h
1//==========================================================================
2// CLCG32.CC - part of
3// OMNeT++/OMNEST
4// Discrete System Simulation in C++
5//
6//==========================================================================
7
8/*--------------------------------------------------------------*
9 Copyright (C) 2002-2017 Andras Varga
10 Copyright (C) 2006-2017 OpenSim Ltd.
11
12 This file is distributed WITHOUT ANY WARRANTY. See the file
13 `license' for details on this and other legal matters.
14*--------------------------------------------------------------*/
15
16#ifndef __OMNETPP_CLCG32_H
17#define __OMNETPP_CLCG32_H
18
19#include "simkerneldefs.h"
20#include "globals.h"
21#include "crng.h"
22#include "cconfiguration.h"
23
24namespace omnetpp {
25
26
27#define LCG32_MAX 0x7ffffffeL /* = 2^31-2 */
28
42class SIM_API cLCG32 : public cRNG
43{
44 protected:
45 int32_t seed;
46
47 // 256 pre-generated seeds, spaced 8,388,608 values in the sequence.
48 // This covers the whole RNG period. Enough for 128 runs with 2 RNGs
49 // each, or 64 runs with 4 RNGs each -- assuming one run never uses
50 // more than 8 million random numbers per RNG.
51 static const int32_t autoSeeds[256];
52
53 public:
54 cLCG32() {}
55 virtual ~cLCG32() {}
56
57 virtual std::string str() const override;
58
60 virtual void initialize(int seedSet, int rngId, int numRngs,
61 int parsimProcId, int parsimNumPartitions,
62 cConfiguration *cfg) override;
63
65 virtual void selfTest() override;
66
68 virtual uint32_t intRand() override;
69
71 virtual uint32_t intRandMax() override;
72
74 virtual uint32_t intRand(uint32_t n) override;
75
77 virtual double doubleRand() override;
78
80 virtual double doubleRandNonz() override;
81
83 virtual double doubleRandIncl1() override;
84};
85
86} // namespace omnetpp
87
88
89#endif
90
91
Represents the configuration, as accessed by the simulation kernel.
Definition cconfiguration.h:77
virtual double doubleRandIncl1() override
virtual uint32_t intRandMax() override
virtual void initialize(int seedSet, int rngId, int numRngs, int parsimProcId, int parsimNumPartitions, cConfiguration *cfg) override
virtual void selfTest() override
virtual uint32_t intRand() override
virtual std::string str() const override
virtual double doubleRand() override
virtual uint32_t intRand(uint32_t n) override
virtual double doubleRandNonz() override