1 | // $Id: random_distribution.cc 3900 2020-05-03 08:29:25Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2020 Peter Johansson |
---|
5 | |
---|
6 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
7 | |
---|
8 | The yat library is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License as |
---|
10 | published by the Free Software Foundation; either version 3 of the |
---|
11 | License, or (at your option) any later version. |
---|
12 | |
---|
13 | The yat library 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 GNU |
---|
16 | General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | */ |
---|
21 | |
---|
22 | #include <config.h> |
---|
23 | |
---|
24 | #include "Suite.h" |
---|
25 | |
---|
26 | #include "yat/random/ContinuousDistribution.h" |
---|
27 | #include "yat/random/DiscreteDistribution.h" |
---|
28 | |
---|
29 | using namespace theplu::yat; |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | void discrete_function(random::Discrete& distribution) |
---|
34 | { |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | void continuous_function(random::Continuous& distribution) |
---|
39 | { |
---|
40 | } |
---|
41 | |
---|
42 | |
---|
43 | template<class RND, typename ResType> |
---|
44 | void test_base(RND& rnd, ResType res) |
---|
45 | { |
---|
46 | res = rnd(); |
---|
47 | typename RND::param_type p = rnd.param(); |
---|
48 | res = rnd(p); |
---|
49 | rnd.param(p); |
---|
50 | test::avoid_compiler_warning(res); |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | template<class RND> |
---|
56 | void test_discrete(void) |
---|
57 | { |
---|
58 | RND rnd; |
---|
59 | discrete_function(rnd); |
---|
60 | unsigned long int result = 0; |
---|
61 | test_base(rnd, result); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | template<class RND> |
---|
66 | void test_continuous(void) |
---|
67 | { |
---|
68 | RND rnd; |
---|
69 | continuous_function(rnd); |
---|
70 | double result = 0.0; |
---|
71 | test_base(rnd, result); |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | int main(int argc, char* argv[]) |
---|
76 | { |
---|
77 | test::Suite suite(argc, argv); |
---|
78 | |
---|
79 | test_discrete<random::Bernoulli>(); |
---|
80 | test_discrete<random::Beta>(); |
---|
81 | test_discrete<random::NegativeBinomial>(); |
---|
82 | test_discrete<random::Hyperexponential>(); |
---|
83 | test_discrete<random::Weibull>(); |
---|
84 | test_discrete<random::Laplace>(); |
---|
85 | |
---|
86 | test_continuous<random::Cauchy>(); |
---|
87 | test_continuous<random::ChiSquared>(); |
---|
88 | test_continuous<random::ExtremeValue>(); |
---|
89 | test_continuous<random::FisherF>(); |
---|
90 | test_continuous<random::Gamma>(); |
---|
91 | test_continuous<random::Lognormal>(); |
---|
92 | test_continuous<random::StudentT>(); |
---|
93 | |
---|
94 | return suite.return_value(); |
---|
95 | } |
---|