From 376afcf135e5e209c4a2da3f0d58fb7a79f9e6a2 Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Sun, 23 Nov 2014 20:07:31 +0530 Subject: [PATCH] faster randn with ifelse --- base/random.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/random.jl b/base/random.jl index af916e706005e..1e344729b3c19 100644 --- a/base/random.jl +++ b/base/random.jl @@ -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