Skip to content

Commit

Permalink
Merge pull request #9126 from JuliaLang/rf/randn-ifelse
Browse files Browse the repository at this point in the history
faster randn with ifelse
  • Loading branch information
ViralBShah committed Nov 23, 2014
2 parents c9da7cb + 376afcf commit a331fec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ function randmtzig_randn(rng::MersenneTwister=GLOBAL_RNG)
r = randi(rng)
rabs = int64(r>>1) # One bit for the sign
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]
return x # 99.3% of the time we return here 1st try
elseif idx == 0
Expand Down

0 comments on commit a331fec

Please sign in to comment.