Debian Codegraph @

libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <random>
10
11 // template<class IntType = int>
12 // class discrete_distribution
13
14 // explicit discrete_distribution(const param_type& parm);
15
16 #include <random>
17
18 #include <cassert>
19 #include <vector>
20
21 #include "test_macros.h"
22
23 int main(int, char**)
24 {
25 {
26 typedef std::discrete_distribution<> D;
27 typedef D::param_type P;
28 double p0[] = {10, 30};
29 P pa(p0, p0+2);
30 D d(pa);
31 std::vector<double> p = d.probabilities();
32 assert(p.size() == 2);
33 assert(p[0] == 0.25);
34 assert(p[1] == 0.75);
35 }
36
37 return 0;
38 }