NEST  2.6.0,not_revisioned_source_dir@0
uniform_randomdev.h
Go to the documentation of this file.
1 /*
2  * uniform_randomdev.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef UNIFORM_RANDOMDEV_H
24 #define UNIFORM_RANDOMDEV_H
25 
26 #include <cmath>
27 #include "randomgen.h"
28 #include "randomdev.h"
29 #include "lockptr.h"
30 
31 /************************************************************/
32 /* Class UniformRNG */
33 /* */
34 /* Generates an RNG which returns integer random numbers */
35 /* uniformly distributed between two limits. */
36 /* */
37 /* Arguments: */
38 /* - pointer to an RNG */
39 /* */
40 /* Author: */
41 /* Hans Ekkehard Plesser */
42 /* */
43 /* History: */
44 /* HEP, 2004-08-05 */
45 /* */
46 /************************************************************/
47 
48 namespace librandom {
49 
50 /*BeginDocumentation
51 Name: rdevdict::uniform - uniform random deviate generator
52 Description: Generates uniformly distributed numbers in the interval [low, high).
53 
54 Parameters:
55  low - lower interval boundary, included
56  high - upper interval boudnary, excluded
57 
58 SeeAlso: CreateRDV, RandomArray, rdevdict
59 Author: Hans Ekkehard Plesser
60 */
61 
69  class UniformRandomDev : public RandomDev
70  {
71 
72  public:
73 
74  // accept only lockPTRs for initialization,
75  // otherwise creation of a lock ptr would
76  // occur as side effect---might be unhealthy
78  UniformRandomDev(); // threaded
79 
80  using RandomDev::operator();
81  double operator()(RngPtr rthrd) const; // threaded
82 
84  void set_status(const DictionaryDatum&);
85 
87  void get_status(DictionaryDatum&) const;
88 
89  private:
90  double low_;
91  double high_;
92  double delta_;
93  };
94 
95  inline
97  {
98  return low_ + delta_ * rthrd->drand();
99  }
100 
101 }
102 # endif
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
virtual double operator()(void)
Operator delivering doubles.
Definition: randomdev.h:199
double high_
upper bound, excluded
Definition: uniform_randomdev.h:91
void get_status(DictionaryDatum &) const
get distribution parameters from SLI dict
Definition: uniform_randomdev.cpp:62
double delta_
interval width
Definition: uniform_randomdev.h:92
double low_
lower bound, included
Definition: uniform_randomdev.h:90
UniformRandomDev()
Definition: uniform_randomdev.cpp:38
Abstract base class for access to non-uniform random deviate generators.
Definition: randomdev.h:131
void set_status(const DictionaryDatum &)
set distribution parameters from SLI dict
Definition: uniform_randomdev.cpp:46
Class UniformRandomDev Create uniformly distributed random numbers in [low, high).
Definition: uniform_randomdev.h:69