| author | |
| committer | |
| log | 3e94347e6152dd9a88f4bceb46bbc245ed7cef98 |
| tree | b58eddbcf200ac3ee8c5ebb2bf89d45aa0236061 |
| parent | 1b4bae6d69937043add14c0dac357c1a1b05f037 |
* 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 { |
| 116 | 116 | pub fn floatNorm(r: *Random, comptime T: type) T { |
| 117 | 117 | const value = ziggurat.next_f64(r, ziggurat.NormDist); |
| 118 | 118 | switch (T) { |
| 119 | f32 => return f32(value), | |
| 119 | f32 => return @floatCast(f32, value), | |
| 120 | 120 | f64 => return value, |
| 121 | 121 | else => @compileError("unknown floating point type"), |
| 122 | 122 | } |
| ... | ... | @@ -128,7 +128,7 @@ pub const Random = struct { |
| 128 | 128 | pub fn floatExp(r: *Random, comptime T: type) T { |
| 129 | 129 | const value = ziggurat.next_f64(r, ziggurat.ExpDist); |
| 130 | 130 | switch (T) { |
| 131 | f32 => return f32(value), | |
| 131 | f32 => return @floatCast(f32, value), | |
| 132 | 132 | f64 => return value, |
| 133 | 133 | else => @compileError("unknown floating point type"), |
| 134 | 134 | } |
std/rand/ziggurat.zig+6-2| ... | ... | @@ -84,12 +84,12 @@ fn ZigTableGen( |
| 84 | 84 | |
| 85 | 85 | for (tables.x[2..256]) |*entry, i| { |
| 86 | 86 | const last = tables.x[2 + i - 1]; |
| 87 | *entry = f_inv(v / last + f(last)); | |
| 87 | entry.* = f_inv(v / last + f(last)); | |
| 88 | 88 | } |
| 89 | 89 | tables.x[256] = 0; |
| 90 | 90 | |
| 91 | 91 | for (tables.f[0..]) |*entry, i| { |
| 92 | *entry = f(tables.x[i]); | |
| 92 | entry.* = f(tables.x[i]); | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return tables; |
| ... | ... | @@ -160,3 +160,7 @@ test "ziggurant exp dist sanity" { |
| 160 | 160 | _ = prng.random.floatExp(f64); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | ||
| 164 | test "ziggurat table gen" { | |
| 165 | const table = NormDist; | |
| 166 | } |