Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,7 @@ public:
}

private:
_Ty1 _Gx0;
_Ty1 _Gx0 = 0.0;
};

_EXPORT_STD template <class _Ty = int>
Expand Down Expand Up @@ -2779,19 +2779,24 @@ public:
return _Mean;
}

static constexpr double _Small_threshold = 12.0;

void _Init(_Ty1 _Mean0) noexcept { // set internal state
_STL_ASSERT(0.0 < _Mean0, "invalid mean argument for poisson_distribution");
_Mean = _Mean0;
if (_Mean0 < _Small_threshold) {
_Small._Init(_Mean0);
return;
}
_Sqrt = _CSTD sqrt(2.0 * _Mean0);
_Logm = _CSTD log(_Mean0);
_Gx1 = _Mean0 * _Logm - _XLgamma(_Mean0 + 1.0);
_Small._Init(_Mean0);
}

_Ty1 _Mean;
_Ty1 _Sqrt;
_Ty1 _Logm;
_Ty1 _Gx1;
_Ty1 _Mean = 0.0;
_Ty1 _Sqrt = 0.0;
_Ty1 _Logm = 0.0;
_Ty1 _Gx1 = 0.0;
Comment on lines +2797 to +2799
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested. Now it seems clear that the member group {_Sqrt, _Logm, _Gx1} and the _Small member never logically coexist. So perhaps we can store them into a union with _Mean being the tag, which makes param_type smaller. Although such change is ABI breaking and can only be done since vNext.


_Small_poisson_distribution<_Ty> _Small;
};
Expand Down Expand Up @@ -2868,7 +2873,7 @@ public:
private:
template <class _Engine>
result_type _Eval(_Engine& _Eng, const param_type& _Par0) const {
if (_Par0._Mean < 12.0) {
if (_Par0._Mean < param_type::_Small_threshold) {
return _Par0._Small(_Eng);
}

Expand Down