You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contrib/restricted/boost/math/include/boost/math/distributions/detail/hypergeometric_quantile.hpp
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
namespaceboost{ namespacemath{ namespacedetail{
15
15
16
16
template <classT>
17
-
inlineunsignedround_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned lbound, unsigned/*ubound*/, const policies::discrete_quantile<policies::integer_round_down>&)
17
+
inlinestd::uint64_tround_x_from_p(std::uint64_t x, T p, T cum, T fudge_factor, std::uint64_t lbound, std::uint64_t/*ubound*/, const policies::discrete_quantile<policies::integer_round_down>&)
18
18
{
19
19
if((p < cum * fudge_factor) && (x != lbound))
20
20
{
@@ -25,7 +25,7 @@ inline unsigned round_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned
25
25
}
26
26
27
27
template <classT>
28
-
inlineunsignedround_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned/*lbound*/, unsigned ubound, const policies::discrete_quantile<policies::integer_round_up>&)
28
+
inlinestd::uint64_tround_x_from_p(std::uint64_t x, T p, T cum, T fudge_factor, std::uint64_t/*lbound*/, std::uint64_t ubound, const policies::discrete_quantile<policies::integer_round_up>&)
29
29
{
30
30
if((cum < p * fudge_factor) && (x != ubound))
31
31
{
@@ -36,29 +36,29 @@ inline unsigned round_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned
36
36
}
37
37
38
38
template <classT>
39
-
inlineunsignedround_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned lbound, unsigned ubound, const policies::discrete_quantile<policies::integer_round_inwards>&)
39
+
inlinestd::uint64_tround_x_from_p(std::uint64_t x, T p, T cum, T fudge_factor, std::uint64_t lbound, std::uint64_t ubound, const policies::discrete_quantile<policies::integer_round_inwards>&)
inlineunsignedround_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned lbound, unsigned ubound, const policies::discrete_quantile<policies::integer_round_outwards>&)
47
+
inlinestd::uint64_tround_x_from_p(std::uint64_t x, T p, T cum, T fudge_factor, std::uint64_t lbound, std::uint64_t ubound, const policies::discrete_quantile<policies::integer_round_outwards>&)
inlineunsignedround_x_from_p(unsigned x, T /*p*/, T /*cum*/, T /*fudge_factor*/, unsigned/*lbound*/, unsigned/*ubound*/, const policies::discrete_quantile<policies::integer_round_nearest>&)
55
+
inlinestd::uint64_tround_x_from_p(std::uint64_t x, T /*p*/, T /*cum*/, T /*fudge_factor*/, std::uint64_t/*lbound*/, std::uint64_t/*ubound*/, const policies::discrete_quantile<policies::integer_round_nearest>&)
56
56
{
57
57
return x;
58
58
}
59
59
60
60
template <classT>
61
-
inlineunsignedround_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned lbound, unsigned/*ubound*/, const policies::discrete_quantile<policies::integer_round_down>&)
61
+
inlinestd::uint64_tround_x_from_q(std::uint64_t x, T q, T cum, T fudge_factor, std::uint64_t lbound, std::uint64_t/*ubound*/, const policies::discrete_quantile<policies::integer_round_down>&)
62
62
{
63
63
if((q * fudge_factor > cum) && (x != lbound))
64
64
{
@@ -69,7 +69,7 @@ inline unsigned round_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned
69
69
}
70
70
71
71
template <classT>
72
-
inlineunsignedround_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned/*lbound*/, unsigned ubound, const policies::discrete_quantile<policies::integer_round_up>&)
72
+
inlinestd::uint64_tround_x_from_q(std::uint64_t x, T q, T cum, T fudge_factor, std::uint64_t/*lbound*/, std::uint64_t ubound, const policies::discrete_quantile<policies::integer_round_up>&)
73
73
{
74
74
if((q < cum * fudge_factor) && (x != ubound))
75
75
{
@@ -80,29 +80,29 @@ inline unsigned round_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned
80
80
}
81
81
82
82
template <classT>
83
-
inlineunsignedround_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned lbound, unsigned ubound, const policies::discrete_quantile<policies::integer_round_inwards>&)
83
+
inlinestd::uint64_tround_x_from_q(std::uint64_t x, T q, T cum, T fudge_factor, std::uint64_t lbound, std::uint64_t ubound, const policies::discrete_quantile<policies::integer_round_inwards>&)
84
84
{
85
85
if(q < 0.5)
86
86
returnround_x_from_q(x, q, cum, fudge_factor, lbound, ubound, policies::discrete_quantile<policies::integer_round_down>());
87
87
returnround_x_from_q(x, q, cum, fudge_factor, lbound, ubound, policies::discrete_quantile<policies::integer_round_up>());
88
88
}
89
89
90
90
template <classT>
91
-
inlineunsignedround_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned lbound, unsigned ubound, const policies::discrete_quantile<policies::integer_round_outwards>&)
91
+
inlinestd::uint64_tround_x_from_q(std::uint64_t x, T q, T cum, T fudge_factor, std::uint64_t lbound, std::uint64_t ubound, const policies::discrete_quantile<policies::integer_round_outwards>&)
92
92
{
93
93
if(q >= 0.5)
94
94
returnround_x_from_q(x, q, cum, fudge_factor, lbound, ubound, policies::discrete_quantile<policies::integer_round_down>());
95
95
returnround_x_from_q(x, q, cum, fudge_factor, lbound, ubound, policies::discrete_quantile<policies::integer_round_up>());
96
96
}
97
97
98
98
template <classT>
99
-
inlineunsignedround_x_from_q(unsigned x, T /*q*/, T /*cum*/, T /*fudge_factor*/, unsigned/*lbound*/, unsigned/*ubound*/, const policies::discrete_quantile<policies::integer_round_nearest>&)
99
+
inlinestd::uint64_tround_x_from_q(std::uint64_t x, T /*q*/, T /*cum*/, T /*fudge_factor*/, std::uint64_t/*lbound*/, std::uint64_t/*ubound*/, const policies::discrete_quantile<policies::integer_round_nearest>&)
100
100
{
101
101
return x;
102
102
}
103
103
104
104
template <classT, classPolicy>
105
-
unsignedhypergeometric_quantile_imp(T p, T q, unsigned r, unsigned n, unsigned N, const Policy& pol)
105
+
std::uint64_thypergeometric_quantile_imp(T p, T q, std::uint64_t r, std::uint64_t n, std::uint64_t N, const Policy& pol)
106
106
{
107
107
#ifdef _MSC_VER
108
108
# pragma warning(push)
@@ -113,8 +113,8 @@ unsigned hypergeometric_quantile_imp(T p, T q, unsigned r, unsigned n, unsigned
if(static_cast<std::uintmax_t>(count + i - k) > max_iter)
111
124
{
112
125
returnpolicies::raise_evaluation_error("cdf(non_central_beta_distribution<%1%>, %1%)", "Series did not converge, closest value was %1%", sum, pol); // LCOV_EXCL_LINE
@@ -542,6 +555,24 @@ namespace boost
542
555
T beta = x < y ?
543
556
ibeta_derivative(a + k, b, x, pol)
544
557
: ibeta_derivative(b, a + k, y, pol);
558
+
559
+
while (fabs(beta * pois) < tools::min_value<T>())
560
+
{
561
+
if ((k == 0) || (pois == 0))
562
+
return0; // Nothing else we can do!
563
+
//
564
+
// We only get here when a+k and b are large and x is small,
565
+
// in that case reduce k (bisect) until both terms are finite:
if(static_cast<std::uintmax_t>(count + i - k) > max_iter)
581
619
{
582
620
returnpolicies::raise_evaluation_error("pdf(non_central_beta_distribution<%1%>, %1%)", "Series did not converge, closest value was %1%", sum, pol); // LCOV_EXCL_LINE
0 commit comments