diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-02-05 00:22:15 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-02-05 00:22:15 -0500 |
commit | f557d1f49a2914c6084dd18efc783395228d8ce0 (patch) | |
tree | 51111fc899f01956cbab948b87c241478576870d /km-rand-libc.c | |
parent | b5065ea43cb13c0b553874305b53963176c70f59 (diff) | |
download | kmeans-f557d1f49a2914c6084dd18efc783395228d8ce0.tar.bz2 kmeans-f557d1f49a2914c6084dd18efc783395228d8ce0.zip |
mv *.[hc] src/
Diffstat (limited to 'km-rand-libc.c')
-rw-r--r-- | km-rand-libc.c | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/km-rand-libc.c b/km-rand-libc.c deleted file mode 100644 index da1e4b0..0000000 --- a/km-rand-libc.c +++ /dev/null @@ -1,56 +0,0 @@ -#include <stdbool.h> // bool -#include "util.h" -#include "km.h" - -// libc random source get_floats -static bool -on_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 -on_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 -LIBC_RAND_CBS = { - .get_floats = on_get_floats, - .get_sizes = on_get_sizes, - .fini = NULL, -}; - -// init system random source (uses system rand()) -void -km_rand_init_libc( - km_rand_t * const rs -) { - rs->cbs = &LIBC_RAND_CBS; - rs->data = NULL; -} |