]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/values.cc
1 // { dg-options "-DSIMULATOR_TEST" { target simulator } }
2 // { dg-do run { target c++11 } }
3 // { dg-require-cstdint "" }
4 // { dg-require-cmath "" }
6 // Copyright (C) 2011-2022 Free Software Foundation, Inc.
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)
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.
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/>.
23 // 26.5.8.4.1 Class template poisson_distribution [rand.dist.pois.poisson]
27 #include <testsuite_random.h>
31 using namespace __gnu_test
;
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); } );
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); } );
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); } );
47 // This can take extremely long on simulators, timing out the test.
48 #ifndef SIMULATOR_TEST
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); } );