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 RealType = double>
12 // class piecewise_constant_distribution
13 
14 // explicit piecewise_constant_distribution(const param_type& parm);
15 
16 #include <random>
17 
18 #include <cassert>
19 #include <vector>
20 
21 #include "test_macros.h"
22 
main(int,char **)23 int main(int, char**)
24 {
25     {
26         typedef std::piecewise_constant_distribution<> D;
27         typedef D::param_type P;
28         double b[] = {10, 14, 16, 17};
29         double p[] = {25, 62.5, 12.5};
30         P pa(b, b+4, p);
31         D d(pa);
32         std::vector<double> iv = d.intervals();
33         assert(iv.size() == 4);
34         assert(iv[0] == 10);
35         assert(iv[1] == 14);
36         assert(iv[2] == 16);
37         assert(iv[3] == 17);
38         std::vector<double> dn = d.densities();
39         assert(dn.size() == 3);
40         assert(dn[0] == .0625);
41         assert(dn[1] == .3125);
42         assert(dn[2] == .125);
43     }
44 
45   return 0;
46 }
47