Statistics
| Branch: | Revision:

root / src / common / lcgrandom.h @ 81ad8b66

History | View | Annotate | Download (1.16 KB)

1 01873262 Georg Kunz
//==========================================================================
2
//  LCGRANDOM.H - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//==========================================================================
9
10
/*--------------------------------------------------------------*
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16
17
#ifndef __LCGRANDOM_H
18
#define __LCGRANDOM_H
19
20
#include "commondefs.h"
21
#include "intxtypes.h"
22
#include "exception.h"
23
24
NAMESPACE_BEGIN
25
26
#define GLRAND_MAX  0x7ffffffeL  /* = 2**31-2 */
27
28
/**
29
 * Our RNG on [0,1), for the layouting library and other non-simulation purposes.
30
 * C's rand() is not to be trusted.
31
 */
32
class COMMON_API LCGRandom
33
{
34
    private:
35
        int32 seed;
36
37
    public:
38
        LCGRandom(int32 seed=1);
39
40
        int32 getSeed() { return seed; }
41
        void setSeed(int32 seed);
42
43
        double next01();
44
45
        int draw(int range);
46
47
        void selfTest();
48
};
49
50
NAMESPACE_END
51
52
53
#endif