diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-02-04 15:33:35 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-02-04 15:33:35 -0500 |
commit | 159c42498365913f6ed400e13c77798d041a7d43 (patch) | |
tree | 96cc3b14bbbbd44dc5173e89b85cd2c8228e86e4 /km-rand.c | |
parent | f4a38b43d43f9395d6042d234a5e0ada7455ace1 (diff) | |
download | kmeans-159c42498365913f6ed400e13c77798d041a7d43.tar.bz2 kmeans-159c42498365913f6ed400e13c77798d041a7d43.zip |
add rand-{path,erand48}, minor fixes
Diffstat (limited to 'km-rand.c')
-rw-r--r-- | km-rand.c | 53 |
1 files changed, 0 insertions, 53 deletions
@@ -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; -} |