NEURON
DiscUnif.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
#pragma once
19
20
#include "
Random.h
"
21
22
//
23
// The interval [lo..hi)
24
//
25
26
class
DiscreteUniform
:
public
Random
{
27
long
pLow
;
28
long
pHigh
;
29
double
delta
;
30
public
:
31
DiscreteUniform
(
long
low
,
long
high
,
RNG
*gen);
32
33
long
low
();
34
long
low
(
long
x);
35
long
high
();
36
long
high
(
long
x);
37
38
virtual
double
operator()
();
39
};
40
41
42
inline
DiscreteUniform::DiscreteUniform
(
long
low,
long
high,
RNG
*gen)
43
:
Random
(gen)
44
{
45
pLow
= (
low
<
high
) ?
low
:
high
;
46
pHigh
= (
low
<
high
) ?
high
:
low
;
47
delta
= (
pHigh
-
pLow
) + 1;
48
}
49
50
inline
long
DiscreteUniform::low
() {
return
pLow
; }
51
52
inline
long
DiscreteUniform::low
(
long
x) {
53
long
tmp =
pLow
;
54
pLow
= x;
55
delta
= (
pHigh
-
pLow
) + 1;
56
return
tmp;
57
}
58
59
inline
long
DiscreteUniform::high
() {
return
pHigh
; }
60
61
inline
long
DiscreteUniform::high
(
long
x) {
62
long
tmp =
pHigh
;
63
pHigh
= x;
64
delta
= (
pHigh
-
pLow
) + 1;
65
return
tmp;
66
}
Random.h
DiscreteUniform
Definition:
DiscUnif.h:26
DiscreteUniform::DiscreteUniform
DiscreteUniform(long low, long high, RNG *gen)
Definition:
DiscUnif.h:42
DiscreteUniform::low
long low()
Definition:
DiscUnif.h:50
DiscreteUniform::delta
double delta
Definition:
DiscUnif.h:29
DiscreteUniform::high
long high()
Definition:
DiscUnif.h:59
DiscreteUniform::pHigh
long pHigh
Definition:
DiscUnif.h:28
DiscreteUniform::pLow
long pLow
Definition:
DiscUnif.h:27
DiscreteUniform::operator()
virtual double operator()()
Definition:
DiscUnif.cpp:23
RNG
Definition:
RNG.h:5
Random
Definition:
Random.h:24
src
gnu
DiscUnif.h