clcg32.h

00001 //==========================================================================
00002 //  CLCG32.CC - part of
00003 //                 OMNeT++/OMNEST
00004 //              Discrete System Simulation in C++
00005 //
00006 // Contents:
00007 //   class cLCG32
00008 //
00009 //==========================================================================
00010 
00011 /*--------------------------------------------------------------*
00012   Copyright (C) 2002-2008 Andras Varga
00013   Copyright (C) 2006-2008 OpenSim Ltd.
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __CLCG32_H
00020 #define __CLCG32_H
00021 
00022 #include "simkerneldefs.h"
00023 #include "globals.h"
00024 #include "crng.h"
00025 #include "cconfiguration.h"
00026 
00027 NAMESPACE_BEGIN
00028 
00029 
00030 #define LCG32_MAX  0x7ffffffeL  /* = 2^31-2 */
00031 
00044 class SIM_API cLCG32 : public cRNG
00045 {
00046   protected:
00047     long seed;
00048 
00049     // 256 pre-generated seeds, spaced 8,388,608 values in the sequence.
00050     // This covers the whole RNG period. Enough for 128 runs with 2 RNGs
00051     // each, or 64 runs with 4 RNGs each -- assuming one run never uses
00052     // more than 8 million random numbers per RNG.
00053     static long autoSeeds[256];
00054 
00055   public:
00056     cLCG32() {}
00057     virtual ~cLCG32() {}
00058 
00060     virtual void initialize(int seedSet, int rngId, int numRngs,
00061                             int parsimProcId, int parsimNumPartitions,
00062                             cConfiguration *cfg);
00063 
00065     virtual void selfTest();
00066 
00068     virtual unsigned long intRand();
00069 
00071     virtual unsigned long intRandMax();
00072 
00074     virtual unsigned long intRand(unsigned long n);
00075 
00077     virtual double doubleRand();
00078 
00080     virtual double doubleRandNonz();
00081 
00083     virtual double doubleRandIncl1();
00084 };
00085 
00086 NAMESPACE_END
00087 
00088 
00089 #endif
00090 
00091 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3