]>
Commit | Line | Data |
---|---|---|
0ce91914 | 1 | // { dg-options "-DSIMULATOR_TEST" { target simulator } } |
52066eae | 2 | // { dg-do run { target c++11 } } |
113b21bd PC |
3 | // { dg-require-cstdint "" } |
4 | // { dg-require-cmath "" } | |
5 | // | |
7adcbafe | 6 | // Copyright (C) 2011-2022 Free Software Foundation, Inc. |
113b21bd PC |
7 | // |
8 | // This file is part of the GNU ISO C++ Library. This library is free | |
9 | // software; you can redistribute it and/or modify it under the | |
10 | // terms of the GNU General Public License as published by the | |
11 | // Free Software Foundation; either version 3, or (at your option) | |
12 | // any later version. | |
13 | // | |
14 | // This library 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 along | |
20 | // with this library; see the file COPYING3. If not see | |
21 | // <http://www.gnu.org/licenses/>. | |
22 | ||
23 | // 26.5.8.4.1 Class template poisson_distribution [rand.dist.pois.poisson] | |
24 | ||
25 | #include <random> | |
26 | #include <functional> | |
27 | #include <testsuite_random.h> | |
28 | ||
29 | void test01() | |
30 | { | |
31 | using namespace __gnu_test; | |
32 | ||
33 | std::mt19937 eng; | |
34 | ||
35 | std::poisson_distribution<> pd1(3.0); | |
36 | auto bpd1 = std::bind(pd1, eng); | |
37 | testDiscreteDist(bpd1, [](int n) { return poisson_pdf(n, 3.0); } ); | |
38 | ||
39 | std::poisson_distribution<> pd2(15.0); | |
40 | auto bpd2 = std::bind(pd2, eng); | |
41 | testDiscreteDist(bpd2, [](int n) { return poisson_pdf(n, 15.0); } ); | |
42 | ||
43 | std::poisson_distribution<> pd3(30.0); | |
44 | auto bpd3 = std::bind(pd3, eng); | |
45 | testDiscreteDist(bpd3, [](int n) { return poisson_pdf(n, 30.0); } ); | |
73986c31 | 46 | |
0ce91914 HPN |
47 | // This can take extremely long on simulators, timing out the test. |
48 | #ifndef SIMULATOR_TEST | |
73986c31 MP |
49 | // libstdc++/83237 |
50 | std::poisson_distribution<> pd4(37.17); | |
51 | auto bpd4 = std::bind(pd4, eng); | |
52 | testDiscreteDist<100, 2000000>(bpd4, [](int n) | |
53 | { return poisson_pdf(n, 37.17); } ); | |
0ce91914 | 54 | #endif |
113b21bd PC |
55 | } |
56 | ||
57 | int main() | |
58 | { | |
59 | test01(); | |
60 | return 0; | |
61 | } |