[libcxx] r322556 - Change an internal table of constants for the poisson distribution from

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 06:54:36 PST 2018


Author: marshall
Date: Tue Jan 16 06:54:36 2018
New Revision: 322556

URL: http://llvm.org/viewvc/llvm-project?rev=322556&view=rev
Log:
Change an internal table of constants for the poisson distribution from
type 'result_type' to 'double'. The only thing that we ever do with
these numbers is to promote them to 'double' and use them in a division.
For small result_types, the values were getting truncated, skewing the
results. Thanks to James Nagurne for the suggestion.


Modified:
    libcxx/trunk/include/random

Modified: libcxx/trunk/include/random
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=322556&r1=322555&r2=322556&view=diff
==============================================================================
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Tue Jan 16 06:54:36 2018
@@ -4673,7 +4673,7 @@ poisson_distribution<_IntType>::operator
             double __py;
             if (__x < 10)
             {
-                const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
+                const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
                                              40320, 362880};
                 __px = -__pr.__mean_;
                 __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];




More information about the cfe-commits mailing list