Home | History | Annotate | Download | only in lib

Lines Matching refs:zs

15 static void zipf_update(struct zipf_state *zs)
25 to_gen = min(zs->nranges, (uint64_t) ZIPF_MAX_GEN);
28 zs->zetan += pow(1.0 / (double) (i + 1), zs->theta);
31 static void shared_rand_init(struct zipf_state *zs, unsigned long nranges,
34 memset(zs, 0, sizeof(*zs));
35 zs->nranges = nranges;
37 init_rand_seed(&zs->rand, seed, 0);
38 zs->rand_off = __rand(&zs->rand);
41 void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta,
44 shared_rand_init(zs, nranges, seed);
46 zs->theta = theta;
47 zs->zeta2 = pow(1.0, zs->theta) + pow(0.5, zs->theta);
49 zipf_update(zs);
52 unsigned long long zipf_next(struct zipf_state *zs)
55 unsigned long long n = zs->nranges;
58 alpha = 1.0 / (1.0 - zs->theta);
59 eta = (1.0 - pow(2.0 / n, 1.0 - zs->theta)) / (1.0 - zs->zeta2 / zs->zetan);
61 rand_uni = (double) __rand(&zs->rand) / (double) FRAND32_MAX;
62 rand_z = rand_uni * zs->zetan;
66 else if (rand_z < (1.0 + pow(0.5, zs->theta)))
73 if (!zs->disable_hash)
76 return (val + zs->rand_off) % zs->nranges;
79 void pareto_init(struct zipf_state *zs, unsigned long nranges, double h,
82 shared_rand_init(zs, nranges, seed);
83 zs->pareto_pow = log(h) / log(1.0 - h);
86 unsigned long long pareto_next(struct zipf_state *zs)
88 double rand = (double) __rand(&zs->rand) / (double) FRAND32_MAX;
91 n = (zs->nranges - 1) * pow(rand, zs->pareto_pow);
93 if (!zs->disable_hash)
96 return (n + zs->rand_off) % zs->nranges;
99 void zipf_disable_hash(struct zipf_state *zs)
101 zs->disable_hash = true;