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

faster randn with ifelse #9126

Merged
merged 1 commit into from
Nov 23, 2014
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
2 changes: 1 addition & 1 deletion base/random.jl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ function randmtzig_randn(rng::MersenneTwister=GLOBAL_RNG)
r = randi(rng) r = randi(rng)
rabs = int64(r>>1) # One bit for the sign rabs = int64(r>>1) # One bit for the sign
idx = rabs & 0xFF idx = rabs & 0xFF
x = (r&1 != 0x000000000 ? -rabs : rabs)*wi[idx+1] x = ifelse(r % Bool, -rabs, rabs)*wi[idx+1]
if rabs < ki[idx+1] if rabs < ki[idx+1]
return x # 99.3% of the time we return here 1st try return x # 99.3% of the time we return here 1st try
elseif idx == 0 elseif idx == 0
Expand Down