summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/zipf.c15
-rw-r--r--lib/zipf.h4
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/zipf.c b/lib/zipf.c
index 21aaa36b..c7bb8a80 100644
--- a/lib/zipf.c
+++ b/lib/zipf.c
@@ -88,18 +88,20 @@ punt:
zs->nranges = f.nranges;
}
-static void shared_rand_init(struct zipf_state *zs, unsigned long nranges)
+static void shared_rand_init(struct zipf_state *zs, unsigned long nranges,
+ unsigned int seed)
{
memset(zs, 0, sizeof(*zs));
zs->nranges = nranges;
- init_rand(&zs->rand);
+ init_rand_seed(&zs->rand, seed);
zs->rand_off = __rand(&zs->rand);
}
-void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta)
+void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta,
+ unsigned int seed)
{
- shared_rand_init(zs, nranges);
+ shared_rand_init(zs, nranges, seed);
zs->theta = theta;
zs->zeta2 = pow(1.0, zs->theta) + pow(0.5, zs->theta);
@@ -129,9 +131,10 @@ unsigned long long zipf_next(struct zipf_state *zs)
return (__hash_long(val - 1) + zs->rand_off) % zs->nranges;
}
-void pareto_init(struct zipf_state *zs, unsigned long nranges, double h)
+void pareto_init(struct zipf_state *zs, unsigned long nranges, double h,
+ unsigned int seed)
{
- shared_rand_init(zs, nranges);
+ shared_rand_init(zs, nranges, seed);
zs->pareto_pow = log(h) / log(1.0 - h);
}
diff --git a/lib/zipf.h b/lib/zipf.h
index a23afe5e..dbcaffb2 100644
--- a/lib/zipf.h
+++ b/lib/zipf.h
@@ -14,10 +14,10 @@ struct zipf_state {
unsigned long rand_off;
};
-void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta);
+void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, unsigned int seed);
unsigned long long zipf_next(struct zipf_state *zs);
-void pareto_init(struct zipf_state *zs, unsigned long nranges, double h);
+void pareto_init(struct zipf_state *zs, unsigned long nranges, double h, unsigned int seed);
unsigned long long pareto_next(struct zipf_state *zs);
#endif