aboutsummaryrefslogtreecommitdiff
path: root/km-rand.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-02-04 15:33:35 -0500
committerPaul Duncan <pabs@pablotron.org>2019-02-04 15:33:35 -0500
commit159c42498365913f6ed400e13c77798d041a7d43 (patch)
tree96cc3b14bbbbd44dc5173e89b85cd2c8228e86e4 /km-rand.c
parentf4a38b43d43f9395d6042d234a5e0ada7455ace1 (diff)
downloadkmeans-159c42498365913f6ed400e13c77798d041a7d43.tar.bz2
kmeans-159c42498365913f6ed400e13c77798d041a7d43.zip
add rand-{path,erand48}, minor fixes
Diffstat (limited to 'km-rand.c')
-rw-r--r--km-rand.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/km-rand.c b/km-rand.c
index bb3a2cc..e777069 100644
--- a/km-rand.c
+++ b/km-rand.c
@@ -31,56 +31,3 @@ km_rand_fini(
rs->cbs->fini(rs);
}
}
-
-// libc random source get_floats
-static bool
-rand_libc_get_floats(
- km_rand_t * const rs,
- const size_t num_vals,
- float * const vals
-) {
- UNUSED(rs);
-
- // generate results
- for (size_t i = 0; i < num_vals; i++) {
- vals[i] = 1.0 * rand() / RAND_MAX;
- }
-
- // return success
- return true;
-}
-
-// fill sizes callback for system random source
-static bool
-rand_libc_get_sizes(
- km_rand_t * const rs,
- const size_t num_vals,
- size_t * const vals
-) {
- UNUSED(rs);
-
- // generate results
- for (size_t i = 0; i < num_vals; i++) {
- vals[i] = rand();
- }
-
- // return success
- return true;
-}
-
-// system random source callbacks
-static const km_rand_cbs_t
-RAND_LIBC_CBS = {
- .get_floats = rand_libc_get_floats,
- .get_sizes = rand_libc_get_sizes,
- .fini = NULL,
-};
-
-// init system random source (uses system rand())
-void
-km_rand_init_libc(
- km_rand_t * const rs
-) {
- rs->cbs = &RAND_LIBC_CBS;
- rs->data = NULL;
-}