Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes incorrect rounding in rejection method. #1159

Merged
Merged
Changes from 2 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
14 changes: 8 additions & 6 deletions stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -2290,9 +2290,10 @@ private:
_Ty _Res;
_Ty1 _Yx;
for (;;) { // generate a tentative value
_Yx = static_cast<_Ty1>(_CSTD tan(_Pi * _NRAND(_Eng, _Ty1)));
_Res = static_cast<_Ty>(_Par0._Sqrt * _Yx + _Par0._Mean);
if (_Ty{0} <= _Res) {
_Yx = static_cast<_Ty1>(_CSTD tan(_Pi * _NRAND(_Eng, _Ty1)));
const _Ty1 _Mx{_Par0._Sqrt * _Yx + _Par0._Mean};
if (0.0 <= _Mx) {
_Res = static_cast<_Ty>(_Mx);
break;
}
}
Expand Down Expand Up @@ -2472,9 +2473,10 @@ private:
for (;;) { // generate and reject
_Ty1 _Yx;
for (;;) { // generate a tentative value
_Yx = static_cast<_Ty1>(_CSTD tan(_Pi * _NRAND(_Eng, _Ty1)));
_Res = static_cast<_Ty>(_Par0._Sqrt * _Yx + _Par0._Mean);
if (_Ty{0} <= _Res && _Res <= _Par0._Tx) {
_Yx = static_cast<_Ty1>(_CSTD tan(_Pi * _NRAND(_Eng, _Ty1)));
const _Ty1 _Mx{_Par0._Sqrt * _Yx + _Par0._Mean};
if (0.0 <= _Mx && _Mx < _Par0._Tx + _Ty{1}) {
MattStephanson marked this conversation as resolved.
Show resolved Hide resolved
_Res = static_cast<_Ty>(_Mx);
break;
}
}
Expand Down