diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-26 10:13:55 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-27 12:20:44 -0700 |
| commit | 41dd2beaacade94c5c98400a4a655aea07b9e2f3 (patch) | |
| tree | d7cd75c3ded0e8517e801f62dbb883d93f3cd585 /lib/std/rand/ziggurat.zig | |
| parent | 6f4343b61afe36a709e713735947561a2b76bce8 (diff) | |
| download | zig-41dd2beaacade94c5c98400a4a655aea07b9e2f3.tar.gz zig-41dd2beaacade94c5c98400a4a655aea07b9e2f3.zip | |
compiler-rt: math functions reorg
* unify the logic for exporting math functions from compiler-rt,
with the appropriate suffixes and prefixes.
- add all missing f128 and f80 exports. Functions with missing
implementations call other functions and have TODO comments.
- also add f16 functions
* move math functions from freestanding libc to compiler-rt (#7265)
* enable all the f128 and f80 code in the stage2 compiler and behavior
tests (#11161).
* update std lib to use builtins rather than `std.math`.
Diffstat (limited to 'lib/std/rand/ziggurat.zig')
| -rw-r--r-- | lib/std/rand/ziggurat.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/std/rand/ziggurat.zig b/lib/std/rand/ziggurat.zig index 5c18d0023b..b05ce7fd73 100644 --- a/lib/std/rand/ziggurat.zig +++ b/lib/std/rand/ziggurat.zig @@ -33,7 +33,7 @@ pub fn next_f64(random: Random, comptime tables: ZigTable) f64 { }; const x = u * tables.x[i]; - const test_x = if (tables.is_symmetric) math.fabs(x) else x; + const test_x = if (tables.is_symmetric) @fabs(x) else x; // equivalent to |u| < tables.x[i+1] / tables.x[i] (or u < tables.x[i+1] / tables.x[i]) if (test_x < tables.x[i + 1]) { @@ -106,18 +106,18 @@ const norm_r = 3.6541528853610088; const norm_v = 0.00492867323399; fn norm_f(x: f64) f64 { - return math.exp(-x * x / 2.0); + return @exp(-x * x / 2.0); } fn norm_f_inv(y: f64) f64 { - return math.sqrt(-2.0 * math.ln(y)); + return @sqrt(-2.0 * @log(y)); } fn norm_zero_case(random: Random, u: f64) f64 { var x: f64 = 1; var y: f64 = 0; while (-2.0 * y < x * x) { - x = math.ln(random.float(f64)) / norm_r; - y = math.ln(random.float(f64)); + x = @log(random.float(f64)) / norm_r; + y = @log(random.float(f64)); } if (u < 0) { @@ -151,13 +151,13 @@ const exp_r = 7.69711747013104972; const exp_v = 0.0039496598225815571993; fn exp_f(x: f64) f64 { - return math.exp(-x); + return @exp(-x); } fn exp_f_inv(y: f64) f64 { - return -math.ln(y); + return -@log(y); } fn exp_zero_case(random: Random, _: f64) f64 { - return exp_r - math.ln(random.float(f64)); + return exp_r - @log(random.float(f64)); } test "exp dist sanity" { |
