NEURON
MLCG.h
Go to the documentation of this file.
1
// This may look like C code, but it is really -*- C++ -*-
2
/*
3
Copyright (C) 1988 Free Software Foundation
4
written by Dirk Grunwald (grunwald@cs.uiuc.edu)
5
6
This file is part of the GNU C++ Library. This library is free
7
software; you can redistribute it and/or modify it under the terms of
8
the GNU Library General Public License as published by the Free
9
Software Foundation; either version 2 of the License, or (at your
10
option) any later version. This library is distributed in the hope
11
that it will be useful, but WITHOUT ANY WARRANTY; without even the
12
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13
PURPOSE. See the GNU Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
*/
18
#ifndef _MLCG_h
19
#define _MLCG_h 1
20
#ifdef __GNUG__
21
//#pragma interface
22
#endif
23
24
#include <
RNG.h
>
25
#include <
math.h
>
26
27
//
28
// Multiplicative Linear Conguential Generator
29
//
30
31
class
MLCG
:
public
RNG
{
32
int32_t
initialSeedOne
;
33
int32_t
initialSeedTwo
;
34
int32_t
seedOne
;
35
int32_t
seedTwo
;
36
37
protected
:
38
39
public
:
40
MLCG
(
int32_t
seed1
= 0,
int32_t
seed2
= 1);
41
//
42
// Return a long-words word of random bits
43
//
44
virtual
uint32_t
asLong
();
45
virtual
void
reset
();
46
int32_t
seed1
();
47
void
seed1
(
int32_t
);
48
int32_t
seed2
();
49
void
seed2
(
int32_t
);
50
void
reseed
(
int32_t
,
int32_t
);
51
};
52
53
inline
int32_t
54
MLCG::seed1
()
55
{
56
return
(
seedOne
);
57
}
58
59
inline
void
60
MLCG::seed1
(
int32_t
s
)
61
{
62
initialSeedOne
=
s
;
63
reset
();
64
}
65
66
inline
int32_t
67
MLCG::seed2
()
68
{
69
return
(
seedTwo
);
70
}
71
72
inline
void
73
MLCG::seed2
(
int32_t
s
)
74
{
75
initialSeedTwo
=
s
;
76
reset
();
77
}
78
79
inline
void
80
MLCG::reseed
(
int32_t
s1,
int32_t
s2)
81
{
82
initialSeedOne
= s1;
83
initialSeedTwo
= s2;
84
reset
();
85
}
86
87
#endif
math.h
MLCG::MLCG
MLCG(int32_t seed1=0, int32_t seed2=1)
Definition:
MLCG.cpp:48
MLCG::seed1
int32_t seed1()
Definition:
MLCG.h:54
RNG
Definition:
RNG.h:55
MLCG::initialSeedOne
int32_t initialSeedOne
Definition:
MLCG.h:32
RNG.h
MLCG::reset
virtual void reset()
Definition:
MLCG.cpp:56
s
_CONST char * s
Definition:
system.cpp:74
MLCG::seed2
int32_t seed2()
Definition:
MLCG.h:67
MLCG::initialSeedTwo
int32_t initialSeedTwo
Definition:
MLCG.h:33
MLCG::asLong
virtual uint32_t asLong()
Definition:
MLCG.cpp:90
MLCG
Definition:
MLCG.h:31
MLCG::seedTwo
int32_t seedTwo
Definition:
MLCG.h:35
MLCG::seedOne
int32_t seedOne
Definition:
MLCG.h:34
MLCG::reseed
void reseed(int32_t, int32_t)
Definition:
MLCG.h:80
uint32_t
uint uint32_t
Definition:
openclfeatures.h:85
int32_t
#define int32_t
Definition:
nrnconf.h:1
src
gnu
MLCG.h