authorgravatar for tgschultz@gmail.comtgschultz <tgschultz@gmail.com> 2018-06-27 11:30:15-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-27 12:30:15-04:00
log3e94347e6152dd9a88f4bceb46bbc245ed7cef98
treeb58eddbcf200ac3ee8c5ebb2bf89d45aa0236061
parent1b4bae6d69937043add14c0dac357c1a1b05f037

Fix up some std.rand syntax #1161 (#1162)

* Fix old syntax in rand Ziggurat somehow did not get updated to latest syntax * Fix broken float casts f32 float casts somehow not updated to latest syntax

2 files changed, 8 insertions(+), 4 deletions(-)

std/rand/index.zig+2-2
......@@ -116,7 +116,7 @@ pub const Random = struct {
116116 pub fn floatNorm(r: *Random, comptime T: type) T {
117117 const value = ziggurat.next_f64(r, ziggurat.NormDist);
118118 switch (T) {
119 f32 => return f32(value),
119 f32 => return @floatCast(f32, value),
120120 f64 => return value,
121121 else => @compileError("unknown floating point type"),
122122 }
......@@ -128,7 +128,7 @@ pub const Random = struct {
128128 pub fn floatExp(r: *Random, comptime T: type) T {
129129 const value = ziggurat.next_f64(r, ziggurat.ExpDist);
130130 switch (T) {
131 f32 => return f32(value),
131 f32 => return @floatCast(f32, value),
132132 f64 => return value,
133133 else => @compileError("unknown floating point type"),
134134 }
std/rand/ziggurat.zig+6-2
......@@ -84,12 +84,12 @@ fn ZigTableGen(
8484
8585 for (tables.x[2..256]) |*entry, i| {
8686 const last = tables.x[2 + i - 1];
87 *entry = f_inv(v / last + f(last));
87 entry.* = f_inv(v / last + f(last));
8888 }
8989 tables.x[256] = 0;
9090
9191 for (tables.f[0..]) |*entry, i| {
92 *entry = f(tables.x[i]);
92 entry.* = f(tables.x[i]);
9393 }
9494
9595 return tables;
......@@ -160,3 +160,7 @@ test "ziggurant exp dist sanity" {
160160 _ = prng.random.floatExp(f64);
161161 }
162162}
163
164test "ziggurat table gen" {
165 const table = NormDist;
166}