1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | *
|
---|
6 | *
|
---|
7 | * This file is part of MoleCuilder.
|
---|
8 | *
|
---|
9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
10 | * it under the terms of the GNU General Public License as published by
|
---|
11 | * the Free Software Foundation, either version 2 of the License, or
|
---|
12 | * (at your option) any later version.
|
---|
13 | *
|
---|
14 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public License
|
---|
20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
21 | */
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * \file RandomNumberDistribution_Encapsulation_impl.hpp
|
---|
25 | *
|
---|
26 | * Herein we place specializations of specific functions for specific distributions.
|
---|
27 | *
|
---|
28 | * Created on: Jan 5, 2011
|
---|
29 | * Author: heber
|
---|
30 | */
|
---|
31 |
|
---|
32 | // include config.h
|
---|
33 | #ifdef HAVE_CONFIG_H
|
---|
34 | #include <config.h>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include "CodePatterns/MemDebug.hpp"
|
---|
38 |
|
---|
39 | #include <limits>
|
---|
40 |
|
---|
41 | #include "RandomNumberDistribution_Encapsulation.hpp"
|
---|
42 |
|
---|
43 | /* ========= manipulatedclone() ================ */
|
---|
44 |
|
---|
45 | template <>
|
---|
46 | RandomNumberDistribution_Encapsulation< boost::uniform_smallint<> >::
|
---|
47 | RandomNumberDistribution_Encapsulation (const RandomNumberDistribution_Parameters&_params) :
|
---|
48 | distribution_type(_params.min, _params.max)
|
---|
49 | {}
|
---|
50 |
|
---|
51 | template <>
|
---|
52 | RandomNumberDistribution_Encapsulation< boost::uniform_int<> >::
|
---|
53 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
54 | distribution_type(_params.min, _params.max)
|
---|
55 | {}
|
---|
56 |
|
---|
57 | template <>
|
---|
58 | RandomNumberDistribution_Encapsulation< boost::uniform_real<> >::
|
---|
59 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
60 | distribution_type(_params.min, _params.max)
|
---|
61 | {}
|
---|
62 |
|
---|
63 | template <>
|
---|
64 | RandomNumberDistribution_Encapsulation< boost::bernoulli_distribution<> >::
|
---|
65 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
66 | distribution_type(_params.p)
|
---|
67 | {}
|
---|
68 |
|
---|
69 | template <>
|
---|
70 | RandomNumberDistribution_Encapsulation< boost::binomial_distribution<> >::
|
---|
71 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
72 | distribution_type((int)_params.t, _params.p)
|
---|
73 | {}
|
---|
74 |
|
---|
75 | template <>
|
---|
76 | RandomNumberDistribution_Encapsulation< boost::cauchy_distribution<> >::
|
---|
77 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
78 | distribution_type(_params.median, _params.sigma)
|
---|
79 | {}
|
---|
80 |
|
---|
81 | template <>
|
---|
82 | RandomNumberDistribution_Encapsulation< boost::gamma_distribution<> >::
|
---|
83 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
84 | distribution_type(_params.alpha)
|
---|
85 | {}
|
---|
86 |
|
---|
87 | template <>
|
---|
88 | RandomNumberDistribution_Encapsulation< boost::poisson_distribution<> >::
|
---|
89 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
90 | distribution_type(_params.mean)
|
---|
91 | {}
|
---|
92 |
|
---|
93 | template <>
|
---|
94 | RandomNumberDistribution_Encapsulation< boost::geometric_distribution<> >::
|
---|
95 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
96 | distribution_type(_params.p)
|
---|
97 | {}
|
---|
98 |
|
---|
99 | template <>
|
---|
100 | RandomNumberDistribution_Encapsulation< boost::triangle_distribution<> >::
|
---|
101 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
102 | distribution_type(_params.a, _params.b, _params.c)
|
---|
103 | {}
|
---|
104 |
|
---|
105 | template <>
|
---|
106 | RandomNumberDistribution_Encapsulation< boost::exponential_distribution<> >::
|
---|
107 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
108 | distribution_type(_params.lambda)
|
---|
109 | {}
|
---|
110 |
|
---|
111 | template <>
|
---|
112 | RandomNumberDistribution_Encapsulation< boost::normal_distribution<> >::
|
---|
113 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
114 | distribution_type(_params.mean, _params.sigma)
|
---|
115 | {}
|
---|
116 |
|
---|
117 | template <>
|
---|
118 | RandomNumberDistribution_Encapsulation< boost::lognormal_distribution<> >::
|
---|
119 | RandomNumberDistribution_Encapsulation(const RandomNumberDistribution_Parameters&_params) :
|
---|
120 | distribution_type(_params.mean, _params.sigma)
|
---|
121 | {}
|
---|
122 |
|
---|
123 | /* =============== min() ======================= */
|
---|
124 |
|
---|
125 | template <>
|
---|
126 | double RandomNumberDistribution_Encapsulation< boost::uniform_smallint<> >::min() const
|
---|
127 | {
|
---|
128 | return distribution_type.min();
|
---|
129 | }
|
---|
130 |
|
---|
131 | template <>
|
---|
132 | double RandomNumberDistribution_Encapsulation< boost::uniform_int<> >::min() const
|
---|
133 | {
|
---|
134 | return distribution_type.min();
|
---|
135 | }
|
---|
136 |
|
---|
137 | template <>
|
---|
138 | double RandomNumberDistribution_Encapsulation< boost::uniform_01<> >::min() const
|
---|
139 | {
|
---|
140 | return distribution_type.min();
|
---|
141 | }
|
---|
142 |
|
---|
143 | template <>
|
---|
144 | double RandomNumberDistribution_Encapsulation< boost::uniform_real<> >::min() const
|
---|
145 | {
|
---|
146 | return distribution_type.min();
|
---|
147 | }
|
---|
148 |
|
---|
149 | template <>
|
---|
150 | double RandomNumberDistribution_Encapsulation< boost::bernoulli_distribution<> >::min() const
|
---|
151 | {
|
---|
152 | return 0.;
|
---|
153 | }
|
---|
154 |
|
---|
155 | template <>
|
---|
156 | double RandomNumberDistribution_Encapsulation< boost::binomial_distribution<> >::min() const
|
---|
157 | {
|
---|
158 | return 0.;
|
---|
159 | }
|
---|
160 |
|
---|
161 | template <>
|
---|
162 | double RandomNumberDistribution_Encapsulation< boost::cauchy_distribution<> >::min() const
|
---|
163 | {
|
---|
164 | return std::numeric_limits<double>::min();
|
---|
165 | }
|
---|
166 |
|
---|
167 | template <>
|
---|
168 | double RandomNumberDistribution_Encapsulation< boost::gamma_distribution<> >::min() const
|
---|
169 | {
|
---|
170 | return 0.;
|
---|
171 | }
|
---|
172 |
|
---|
173 | template <>
|
---|
174 | double RandomNumberDistribution_Encapsulation< boost::poisson_distribution<> >::min() const
|
---|
175 | {
|
---|
176 | return 0.;
|
---|
177 | }
|
---|
178 |
|
---|
179 | template <>
|
---|
180 | double RandomNumberDistribution_Encapsulation< boost::geometric_distribution<> >::min() const
|
---|
181 | {
|
---|
182 | return 0.;
|
---|
183 | }
|
---|
184 |
|
---|
185 | template <>
|
---|
186 | double RandomNumberDistribution_Encapsulation< boost::triangle_distribution<> >::min() const
|
---|
187 | {
|
---|
188 | return distribution_type.a();
|
---|
189 | }
|
---|
190 |
|
---|
191 | template <>
|
---|
192 | double RandomNumberDistribution_Encapsulation< boost::exponential_distribution<> >::min() const
|
---|
193 | {
|
---|
194 | return 0.;
|
---|
195 | }
|
---|
196 |
|
---|
197 | template <>
|
---|
198 | double RandomNumberDistribution_Encapsulation< boost::normal_distribution<> >::min() const
|
---|
199 | {
|
---|
200 | return std::numeric_limits<double>::min();
|
---|
201 | }
|
---|
202 |
|
---|
203 | template <>
|
---|
204 | double RandomNumberDistribution_Encapsulation< boost::lognormal_distribution<> >::min() const
|
---|
205 | {
|
---|
206 | return 0.;
|
---|
207 | }
|
---|
208 |
|
---|
209 | /* =============== max() ======================= */
|
---|
210 |
|
---|
211 | template <>
|
---|
212 | double RandomNumberDistribution_Encapsulation< boost::uniform_smallint<> >::max() const
|
---|
213 | {
|
---|
214 | return distribution_type.max();
|
---|
215 | }
|
---|
216 |
|
---|
217 | template <>
|
---|
218 | double RandomNumberDistribution_Encapsulation< boost::uniform_int<> >::max() const
|
---|
219 | {
|
---|
220 | return distribution_type.max();
|
---|
221 | }
|
---|
222 |
|
---|
223 | template <>
|
---|
224 | double RandomNumberDistribution_Encapsulation< boost::uniform_01<> >::max() const
|
---|
225 | {
|
---|
226 | return distribution_type.max();
|
---|
227 | }
|
---|
228 |
|
---|
229 | template <>
|
---|
230 | double RandomNumberDistribution_Encapsulation< boost::uniform_real<> >::max() const
|
---|
231 | {
|
---|
232 | return distribution_type.max();
|
---|
233 | }
|
---|
234 |
|
---|
235 | template <>
|
---|
236 | double RandomNumberDistribution_Encapsulation< boost::bernoulli_distribution<> >::max() const
|
---|
237 | {
|
---|
238 | return 1.;
|
---|
239 | }
|
---|
240 |
|
---|
241 | template <>
|
---|
242 | double RandomNumberDistribution_Encapsulation< boost::binomial_distribution<> >::max() const
|
---|
243 | {
|
---|
244 | return distribution_type.t();
|
---|
245 | }
|
---|
246 |
|
---|
247 | template <>
|
---|
248 | double RandomNumberDistribution_Encapsulation< boost::cauchy_distribution<> >::max() const
|
---|
249 | {
|
---|
250 | return std::numeric_limits<double>::max();
|
---|
251 | }
|
---|
252 |
|
---|
253 | template <>
|
---|
254 | double RandomNumberDistribution_Encapsulation< boost::gamma_distribution<> >::max() const
|
---|
255 | {
|
---|
256 | return std::numeric_limits<double>::max();
|
---|
257 | }
|
---|
258 |
|
---|
259 | template <>
|
---|
260 | double RandomNumberDistribution_Encapsulation< boost::poisson_distribution<> >::max() const
|
---|
261 | {
|
---|
262 | return std::numeric_limits<double>::max();
|
---|
263 | }
|
---|
264 |
|
---|
265 | template <>
|
---|
266 | double RandomNumberDistribution_Encapsulation< boost::geometric_distribution<> >::max() const
|
---|
267 | {
|
---|
268 | return std::numeric_limits<double>::max();
|
---|
269 | }
|
---|
270 |
|
---|
271 | template <>
|
---|
272 | double RandomNumberDistribution_Encapsulation< boost::triangle_distribution<> >::max() const
|
---|
273 | {
|
---|
274 | return distribution_type.c();
|
---|
275 | }
|
---|
276 |
|
---|
277 | template <>
|
---|
278 | double RandomNumberDistribution_Encapsulation< boost::exponential_distribution<> >::max() const
|
---|
279 | {
|
---|
280 | return std::numeric_limits<double>::max();
|
---|
281 | }
|
---|
282 |
|
---|
283 | template <>
|
---|
284 | double RandomNumberDistribution_Encapsulation< boost::normal_distribution<> >::max() const
|
---|
285 | {
|
---|
286 | return std::numeric_limits<double>::max();
|
---|
287 | }
|
---|
288 |
|
---|
289 | template <>
|
---|
290 | double RandomNumberDistribution_Encapsulation< boost::lognormal_distribution<> >::max() const
|
---|
291 | {
|
---|
292 | return std::numeric_limits<double>::max();
|
---|
293 | }
|
---|
294 |
|
---|
295 | /* =============== p() ======================= */
|
---|
296 |
|
---|
297 | template <>
|
---|
298 | double RandomNumberDistribution_Encapsulation< boost::bernoulli_distribution<> >::p() const
|
---|
299 | {
|
---|
300 | return distribution_type.p();
|
---|
301 | }
|
---|
302 |
|
---|
303 | template <>
|
---|
304 | double RandomNumberDistribution_Encapsulation< boost::binomial_distribution<> >::p() const
|
---|
305 | {
|
---|
306 | return distribution_type.p();
|
---|
307 | }
|
---|
308 |
|
---|
309 | template <>
|
---|
310 | double RandomNumberDistribution_Encapsulation< boost::geometric_distribution<> >::p() const
|
---|
311 | {
|
---|
312 | return distribution_type.p();
|
---|
313 | }
|
---|
314 |
|
---|
315 |
|
---|
316 | /* =============== t() ======================= */
|
---|
317 |
|
---|
318 | template <>
|
---|
319 | double RandomNumberDistribution_Encapsulation< boost::binomial_distribution<> >::t() const
|
---|
320 | {
|
---|
321 | return distribution_type.t();
|
---|
322 | }
|
---|
323 |
|
---|
324 | /* =============== median() ======================= */
|
---|
325 |
|
---|
326 | template <>
|
---|
327 | double RandomNumberDistribution_Encapsulation< boost::cauchy_distribution<> >::median() const
|
---|
328 | {
|
---|
329 | return distribution_type.median();
|
---|
330 | }
|
---|
331 |
|
---|
332 | /* =============== sigma() ======================= */
|
---|
333 |
|
---|
334 | template <>
|
---|
335 | double RandomNumberDistribution_Encapsulation< boost::cauchy_distribution<> >::sigma() const
|
---|
336 | {
|
---|
337 | return distribution_type.sigma();
|
---|
338 | }
|
---|
339 |
|
---|
340 | template <>
|
---|
341 | double RandomNumberDistribution_Encapsulation< boost::normal_distribution<> >::sigma() const
|
---|
342 | {
|
---|
343 | return distribution_type.sigma();
|
---|
344 | }
|
---|
345 |
|
---|
346 | template <>
|
---|
347 | double RandomNumberDistribution_Encapsulation< boost::lognormal_distribution<> >::sigma() const
|
---|
348 | {
|
---|
349 | return distribution_type.sigma();
|
---|
350 | }
|
---|
351 |
|
---|
352 | /* =============== alpha() ======================= */
|
---|
353 |
|
---|
354 | template <>
|
---|
355 | double RandomNumberDistribution_Encapsulation< boost::gamma_distribution<> >::alpha() const
|
---|
356 | {
|
---|
357 | return distribution_type.alpha();
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | /* =============== mean() ======================= */
|
---|
362 |
|
---|
363 | template <>
|
---|
364 | double RandomNumberDistribution_Encapsulation< boost::poisson_distribution<> >::mean() const
|
---|
365 | {
|
---|
366 | return distribution_type.mean();
|
---|
367 | }
|
---|
368 |
|
---|
369 | template <>
|
---|
370 | double RandomNumberDistribution_Encapsulation< boost::normal_distribution<> >::mean() const
|
---|
371 | {
|
---|
372 | return distribution_type.mean();
|
---|
373 | }
|
---|
374 |
|
---|
375 | template <>
|
---|
376 | double RandomNumberDistribution_Encapsulation< boost::lognormal_distribution<> >::mean() const
|
---|
377 | {
|
---|
378 | return distribution_type.mean();
|
---|
379 | }
|
---|
380 |
|
---|
381 | /* =============== a() ======================= */
|
---|
382 |
|
---|
383 | template <>
|
---|
384 | double RandomNumberDistribution_Encapsulation< boost::triangle_distribution<> >::a() const
|
---|
385 | {
|
---|
386 | return distribution_type.a();
|
---|
387 | }
|
---|
388 |
|
---|
389 |
|
---|
390 | /* =============== b() ======================= */
|
---|
391 |
|
---|
392 | template <>
|
---|
393 | double RandomNumberDistribution_Encapsulation< boost::triangle_distribution<> >::b() const
|
---|
394 | {
|
---|
395 | return distribution_type.b();
|
---|
396 | }
|
---|
397 |
|
---|
398 |
|
---|
399 | /* =============== c() ======================= */
|
---|
400 |
|
---|
401 | template <>
|
---|
402 | double RandomNumberDistribution_Encapsulation< boost::triangle_distribution<> >::c() const
|
---|
403 | {
|
---|
404 | return distribution_type.c();
|
---|
405 | }
|
---|
406 |
|
---|
407 |
|
---|
408 | /* =============== lambda() ======================= */
|
---|
409 |
|
---|
410 | template <>
|
---|
411 | double RandomNumberDistribution_Encapsulation< boost::exponential_distribution<> >::lambda() const
|
---|
412 | {
|
---|
413 | return distribution_type.lambda();
|
---|
414 | }
|
---|
415 |
|
---|
416 |
|
---|