mirror of
https://github.com/ziglang/zig.git
synced 2025-02-10 14:40:16 +00:00
* 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
This commit is contained in:
parent
1b4bae6d69
commit
3e94347e61
@ -116,7 +116,7 @@ pub const Random = struct {
|
||||
pub fn floatNorm(r: *Random, comptime T: type) T {
|
||||
const value = ziggurat.next_f64(r, ziggurat.NormDist);
|
||||
switch (T) {
|
||||
f32 => return f32(value),
|
||||
f32 => return @floatCast(f32, value),
|
||||
f64 => return value,
|
||||
else => @compileError("unknown floating point type"),
|
||||
}
|
||||
@ -128,7 +128,7 @@ pub const Random = struct {
|
||||
pub fn floatExp(r: *Random, comptime T: type) T {
|
||||
const value = ziggurat.next_f64(r, ziggurat.ExpDist);
|
||||
switch (T) {
|
||||
f32 => return f32(value),
|
||||
f32 => return @floatCast(f32, value),
|
||||
f64 => return value,
|
||||
else => @compileError("unknown floating point type"),
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ fn ZigTableGen(
|
||||
|
||||
for (tables.x[2..256]) |*entry, i| {
|
||||
const last = tables.x[2 + i - 1];
|
||||
*entry = f_inv(v / last + f(last));
|
||||
entry.* = f_inv(v / last + f(last));
|
||||
}
|
||||
tables.x[256] = 0;
|
||||
|
||||
for (tables.f[0..]) |*entry, i| {
|
||||
*entry = f(tables.x[i]);
|
||||
entry.* = f(tables.x[i]);
|
||||
}
|
||||
|
||||
return tables;
|
||||
@ -160,3 +160,7 @@ test "ziggurant exp dist sanity" {
|
||||
_ = prng.random.floatExp(f64);
|
||||
}
|
||||
}
|
||||
|
||||
test "ziggurat table gen" {
|
||||
const table = NormDist;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user