NEST  2.6.0,not_revisioned_source_dir@0
random_numbers.h
Go to the documentation of this file.
1 /*
2  * random_numbers.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 RANDOM_NUMBERS_H
24 #define RANDOM_NUMBERS_H
25 
26 #include "slitype.h"
27 #include "slimodule.h"
28 
29 #include <string>
30 
31 #ifndef DICT_H
32 class Dictionary;
33 #endif
34 
35 #ifndef DICTDATUM_H
36 class DictionaryDatum;
37 #endif
38 
42 class RandomNumbers: public SLIModule
43 {
44  public:
45 
46  static SLIType RngType; // actual RNG
47  static SLIType RngFactoryType; // random generator factory
48 
49  static SLIType RdvType; // random deviate generator
50  static SLIType RdvFactoryType; // random deviate generator factory
51 
52 
55 
56  const std::string name(void) const
57  {
58  return "RandomNumbers";
59  }
60 
61  const std::string commandstring(void) const
62  {
63  return std::string("(librandom) run");
64  }
65 
71  void init(SLIInterpreter *);
72 
74  static const Dictionary& get_rngdict();
75 
77  static const Dictionary& get_rdvdict();
78 
79  // RNG creation function
81  {
82  public:
83  void execute(SLIInterpreter *) const;
84  };
85 
86  // RNG creation function
88  {
89  public:
90  void execute(SLIInterpreter *) const;
91  };
92 
94  {
95  public:
96  void execute(SLIInterpreter *) const;
97  };
98 
100  {
101  public:
102  void execute(SLIInterpreter *) const;
103  };
104 
105  // RNG access functions
106  class IrandFunction: public SLIFunction
107  {
108  public:
109  void execute(SLIInterpreter *) const;
110  };
111 
112  class DrandFunction: public SLIFunction
113  {
114  public:
115  void execute(SLIInterpreter *) const;
116  };
117 
118  class SeedFunction: public SLIFunction
119  {
120  public:
121  void execute(SLIInterpreter *) const;
122  };
123 
125  {
126  public:
127  void execute(SLIInterpreter *) const;
128  };
129 
131  {
132  public:
133  void execute(SLIInterpreter *) const;
134  };
135 
136 
137  // create function
140 
141  // set/get functions
144 
145  // access functions
149 
152 
153 private:
154 
156  template <typename NumberGenerator>
157  void register_rng_(const std::string& name, Dictionary& dict);
158 
160  template <typename DeviateGenerator>
161  void register_rdv_(const std::string& name, Dictionary& dict);
162 
165 };
166 
167 inline
169 {
170  assert(rngdict_);
171  return *rngdict_;
172 }
173 
174 inline
176 {
177  assert(rdvdict_);
178  return *rdvdict_;
179 }
180 
181 #endif
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:249
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:200
RandomArrayFunction randomarrayfunction
Definition: random_numbers.h:150
GetStatus_vFunction getstatus_vfunction
Definition: random_numbers.h:143
static const Dictionary & get_rdvdict()
Returns global random deviate generator dictionary.
Definition: random_numbers.h:175
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:235
static Dictionary * rdvdict_
manages random deviate generators
Definition: random_numbers.h:164
~RandomNumbers()
Definition: random_numbers.cpp:66
SetStatus_vdFunction setstatus_vdfunction
Definition: random_numbers.h:142
const std::string name(void) const
Return name of the module.
Definition: random_numbers.h:56
Definition: slifunction.h:35
static SLIType RngType
Definition: random_numbers.h:46
static const Dictionary & get_rngdict()
Returns global random number generator dictionary.
Definition: random_numbers.h:168
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:264
assert(pNet!=0)
static SLIType RdvFactoryType
Definition: random_numbers.h:50
A class that associates names and tokens.
Definition: dict.h:45
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:184
static SLIType RdvType
Definition: random_numbers.h:49
static SLIType RngFactoryType
Definition: random_numbers.h:47
IrandFunction irandfunction
Definition: random_numbers.h:147
SeedFunction seedfunction
Definition: random_numbers.h:146
DrandFunction drandfunction
Definition: random_numbers.h:148
void init(SLIInterpreter *)
Initializes the random number module.
Definition: random_numbers.cpp:91
Definition: interpret.h:69
Definition: slitype.h:49
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:218
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:168
CreateRDVFunction createrdvfunction
Definition: random_numbers.h:139
Definition: random_numbers.h:80
Provides random numbers and deviates to SLI.
Definition: random_numbers.h:42
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:302
Definition: random_numbers.h:130
Base class for all SLI Interpreter modules.
Definition: slimodule.h:34
CreateRNGFunction createrngfunction
Definition: random_numbers.h:138
Definition: random_numbers.h:93
Definition: random_numbers.h:106
Definition: random_numbers.h:87
void execute(SLIInterpreter *) const
Definition: random_numbers.cpp:279
void register_rdv_(const std::string &name, Dictionary &dict)
Utility function for registering deviate generators.
Definition: random_numbers.cpp:84
Definition: random_numbers.h:99
void register_rng_(const std::string &name, Dictionary &dict)
Utility function for registering number generators.
Definition: random_numbers.cpp:76
RandomFunction randomfunction
Definition: random_numbers.h:151
Definition: random_numbers.h:124
Definition: random_numbers.h:112
const std::string commandstring(void) const
Return sli command sequence to be executed for initialisation.
Definition: random_numbers.h:61
Definition: random_numbers.h:118
RandomNumbers()
Definition: random_numbers.h:53
static Dictionary * rngdict_
manages random number generators
Definition: random_numbers.h:163