]> gcc.gnu.org Git - gcc.git/commitdiff
re PR libstdc++/83237 (Values returned by std::poisson_distribution are not distribut...
authorMichele Pezzutti <mpezz@tiscali.it>
Sun, 24 Dec 2017 22:08:52 +0000 (23:08 +0100)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 24 Dec 2017 22:08:52 +0000 (22:08 +0000)
2017-12-24  Michele Pezzutti <mpezz@tiscali.it>

PR libstdc++/83237
* include/bits/random.tcc (poisson_distribution<>::operator()):
Fix __x = 1 case - see updated Errata of Devroye's treatise.
* testsuite/26_numerics/random/poisson_distribution/operators/
values.cc: Add test.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.

From-SVN: r255993

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/random.tcc
libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/values.cc
libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc

index c94e77169a27533fbebdcc822d421d6ab9bc3d54..bc523a0f056944d5cbb5effa2505872b2545b6c9 100644 (file)
@@ -1,3 +1,13 @@
+2017-12-24  Michele Pezzutti <mpezz@tiscali.it>
+
+       PR libstdc++/83237
+       * include/bits/random.tcc (poisson_distribution<>::operator()):
+       Fix __x = 1 case - see updated Errata of Devroye's treatise.
+       * testsuite/26_numerics/random/poisson_distribution/operators/
+       values.cc: Add test.
+       * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
+       line number.
+
 2017-12-24  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/83450
index 95bcf0a163e48bd04871cdf44e1f82bab99e5b32..c1ee083524933e6739f82939b2c0f3a680756269 100644 (file)
@@ -1301,6 +1301,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            const double __c2 = __param._M_c2b + __c1;
            const double __c3 = __c2 + 1;
            const double __c4 = __c3 + 1;
+           // 1 / 78
+           const double __178 = 0.0128205128205128205128205128205128L;
            // e^(1 / 78)
            const double __e178 = 1.0129030479320018583185514777512983L;
            const double __c5 = __c4 + __e178;
@@ -1340,7 +1342,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                else if (__u <= __c4)
                  __x = 0;
                else if (__u <= __c5)
-                 __x = 1;
+                 {
+                   __x = 1;
+                   // Only in the Errata, see libstdc++/83237.
+                   __w = __178;
+                 }
                else
                  {
                    const double __v = -std::log(1.0 - __aurng());
index 0039b7dbd0a67b69f9973277273c875d96ba0d5f..9655c405b298b62e9e1621b71f3d8db960e605ef 100644 (file)
@@ -42,6 +42,12 @@ void test01()
   std::poisson_distribution<> pd3(30.0);
   auto bpd3 = std::bind(pd3, eng);
   testDiscreteDist(bpd3, [](int n) { return poisson_pdf(n, 30.0); } );
+
+  // libstdc++/83237
+  std::poisson_distribution<> pd4(37.17);
+  auto bpd4 = std::bind(pd4, eng);
+  testDiscreteDist<100, 2000000>(bpd4, [](int n)
+                                { return poisson_pdf(n, 37.17); } );
 }
 
 int main()
index 22485222f28904fe87ecee983f048a5e4e7864fb..13c052daef851a009e76c63cae5239078bebbfa4 100644 (file)
@@ -11,4 +11,4 @@ auto x = std::generate_canonical<std::size_t,
 
 // { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 156 }
 
-// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3311 }
+// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3317 }
This page took 0.07115 seconds and 5 git commands to generate.