]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 26_numerics / random / negative_binomial_distribution / operators / values.cc
1 // { dg-do run { target c++11 } }
2 // { dg-require-cstdint "" }
3 // { dg-require-cmath "" }
4 //
5 // Copyright (C) 2011-2023 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12 //
13 // This 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
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
21
22 // 26.5.8.3.4 Class template negative_binomial_distribution
23 // [rand.dist.bern.negbin]
24
25 #include <random>
26 #include <functional>
27 #include <testsuite_random.h>
28
29 // { dg-additional-options "-DSIMULATOR_TEST" { target simulator } }
30
31 #ifdef SIMULATOR_TEST
32 # define ARGS 100, 1000
33 #else
34 # define ARGS
35 #endif
36
37 void test01()
38 {
39 using namespace __gnu_test;
40
41 std::mt19937 eng;
42
43 std::negative_binomial_distribution<> nbd1(5, 0.3);
44 auto bnbd1 = std::bind(nbd1, eng);
45 testDiscreteDist<ARGS>(bnbd1, [](int n)
46 { return negative_binomial_pdf(n, 5, 0.3); } );
47
48 std::negative_binomial_distribution<> nbd2(55, 0.3);
49 auto bnbd2 = std::bind(nbd2, eng);
50 testDiscreteDist<ARGS>(bnbd2, [](int n)
51 { return negative_binomial_pdf(n, 55, 0.3); } );
52
53 std::negative_binomial_distribution<> nbd3(10, 0.75);
54 auto bnbd3 = std::bind(nbd3, eng);
55 testDiscreteDist<ARGS>(bnbd3, [](int n)
56 { return negative_binomial_pdf(n, 10, 0.75); } );
57 }
58
59 int main()
60 {
61 test01();
62 return 0;
63 }