1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // REQUIRES: long_tests
13 // template<class RealType = double>
14 // class cauchy_distribution
16 // template<class _URNG> result_type operator()(_URNG& g);
25 #include "test_macros.h"
28 f(double x
, double a
, double b
)
30 return 1/3.1415926535897932 * std::atan((x
- a
)/b
) + .5;
36 typedef std::cauchy_distribution
<> D
;
37 typedef std::mt19937 G
;
42 const int N
= 1000000;
43 std::vector
<D::result_type
> u
;
44 for (int i
= 0; i
< N
; ++i
)
46 std::sort(u
.begin(), u
.end());
47 for (int i
= 0; i
< N
; ++i
)
48 assert(std::abs(f(u
[i
], a
, b
) - double(i
) / N
) < .0013);
51 typedef std::cauchy_distribution
<> D
;
52 typedef std::mt19937 G
;
54 const double a
= -1.5;
57 const int N
= 1000000;
58 std::vector
<D::result_type
> u
;
59 for (int i
= 0; i
< N
; ++i
)
61 std::sort(u
.begin(), u
.end());
62 for (int i
= 0; i
< N
; ++i
)
63 assert(std::abs(f(u
[i
], a
, b
) - double(i
) / N
) < .0013);
66 typedef std::cauchy_distribution
<> D
;
67 typedef std::mt19937 G
;
72 const int N
= 1000000;
73 std::vector
<D::result_type
> u
;
74 for (int i
= 0; i
< N
; ++i
)
76 std::sort(u
.begin(), u
.end());
77 for (int i
= 0; i
< N
; ++i
)
78 assert(std::abs(f(u
[i
], a
, b
) - double(i
) / N
) < .0013);