ZigTableGen
Function parameters
Parameters
- is_symmetric:bool
- r:f64
- v:f64
- f:fn (f64) f64
- f_inv:fn (f64) f64
- zero_case:fn (Random, f64) f64
Type definitions in this namespace
Types
Functions in this namespace
Functions
= blk: { @setEvalBranchQuota(30000); break :blk ZigTableGen(true, norm_r, norm_v, norm_f, norm_f_inv, norm_zero_case); }
Values
- NormDist
- = blk: { @setEvalBranchQuota(30000); break :blk ZigTableGen(true, norm_r, norm_v, norm_f, norm_f_inv, norm_zero_case); }
- norm_r
- = 3.6541528853610088
- norm_v
- = 0.00492867323399
- ExpDist
- = blk: { @setEvalBranchQuota(30000); break :blk ZigTableGen(false, exp_r, exp_v, exp_f, exp_f_inv, exp_zero_case); }
- exp_r
- = 7.69711747013104972
- exp_v
- = 0.0039496598225815571993
Source
Implementation
pub fn ZigTableGen(
comptime is_symmetric: bool,
comptime r: f64,
comptime v: f64,
comptime f: fn (f64) f64,
comptime f_inv: fn (f64) f64,
comptime zero_case: fn (Random, f64) f64,
) ZigTable {
var tables: ZigTable = undefined;
tables.is_symmetric = is_symmetric;
tables.r = r;
tables.pdf = f;
tables.zero_case = zero_case;
tables.x[0] = v / f(r);
tables.x[1] = r;
for (tables.x[2..256], 0..) |*entry, i| {
const last = tables.x[2 + i - 1];
entry.* = f_inv(v / last + f(last));
}
tables.x[256] = 0;
for (tables.f[0..], 0..) |*entry, i| {
entry.* = f(tables.x[i]);
}
return tables;
}