Skip to content

Commit dea7233

Browse files
author
redi
committed
PR libstdc++/83833 fix chi_squared_distribution::param(const param&)
PR libstdc++/83833 * include/bits/random.h (chi_squared_distribution::param): Update gamma distribution parameter. * testsuite/26_numerics/random/chi_squared_distribution/83833.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256708 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 7a87e57 commit dea7233

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

libstdc++-v3/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
2018-01-15 Jonathan Wakely <[email protected]>
22

3+
PR libstdc++/83833
4+
* include/bits/random.h (chi_squared_distribution::param): Update
5+
gamma distribution parameter.
6+
* testsuite/26_numerics/random/chi_squared_distribution/83833.cc: New
7+
test.
8+
39
PR libstdc++/83830
410
* include/std/type_traits (has_unique_object_representations_v): Add
511
variable template.

libstdc++-v3/include/bits/random.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2643,7 +2643,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
26432643
*/
26442644
void
26452645
param(const param_type& __param)
2646-
{ _M_param = __param; }
2646+
{
2647+
_M_param = __param;
2648+
typedef typename std::gamma_distribution<result_type>::param_type
2649+
param_type;
2650+
_M_gd.param(param_type{__param.n() / 2});
2651+
}
26472652

26482653
/**
26492654
* @brief Returns the greatest lower bound value of the distribution.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (C) 2018 Free Software Foundation, Inc.
2+
//
3+
// This file is part of the GNU ISO C++ Library. This library is free
4+
// software; you can redistribute it and/or modify it under the
5+
// terms of the GNU General Public License as published by the
6+
// Free Software Foundation; either version 3, or (at your option)
7+
// any later version.
8+
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License along
15+
// with this library; see the file COPYING3. If not see
16+
// <http://www.gnu.org/licenses/>.
17+
18+
// { dg-do run { target c++11 } }
19+
20+
#include <random>
21+
#include <testsuite_hooks.h>
22+
23+
void
24+
test01()
25+
{
26+
std::default_random_engine r1, r2;
27+
using chi = std::chi_squared_distribution<double>;
28+
chi::param_type p(5);
29+
chi d1(p);
30+
chi d2;
31+
d2.param(p);
32+
VERIFY( d1(r1) == d2(r2) ); // PR libstdc++/83833
33+
}
34+
35+
int
36+
main()
37+
{
38+
test01();
39+
}

0 commit comments

Comments
 (0)