aboutsummaryrefslogtreecommitdiff
path: root/km-rand-libc.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-02-05 00:22:15 -0500
committerPaul Duncan <pabs@pablotron.org>2019-02-05 00:22:15 -0500
commitf557d1f49a2914c6084dd18efc783395228d8ce0 (patch)
tree51111fc899f01956cbab948b87c241478576870d /km-rand-libc.c
parentb5065ea43cb13c0b553874305b53963176c70f59 (diff)
downloadkmeans-f557d1f49a2914c6084dd18efc783395228d8ce0.tar.bz2
kmeans-f557d1f49a2914c6084dd18efc783395228d8ce0.zip
mv *.[hc] src/
Diffstat (limited to 'km-rand-libc.c')
-rw-r--r--km-rand-libc.c56
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;
-}