diff options
Diffstat (limited to 'km-rand.c')
-rw-r--r-- | km-rand.c | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -4,22 +4,22 @@ // fill buffer with N random floats bool -km_rand_fill( +km_rand_get_floats( km_rand_t * const rs, const size_t num_floats, float * const floats ) { - return rs->cbs->fill(rs, num_floats, floats); + return rs->cbs->get_floats(rs, num_floats, floats); } // fill buffer with N random size_ts bool -km_rand_fill_sizes( +km_rand_get_sizes( km_rand_t * const rs, const size_t num_sizes, size_t * const sizes ) { - return rs->cbs->fill_sizes(rs, num_sizes, sizes); + return rs->cbs->get_sizes(rs, num_sizes, sizes); } // finalize random source @@ -32,18 +32,18 @@ km_rand_fini( } } -// fill callback for system random source +// libc random source get_floats static bool -system_on_fill( +rand_libc_get_floats( km_rand_t * const rs, - const size_t num_floats, - float * const floats + const size_t num_vals, + float * const vals ) { UNUSED(rs); - // generate random cluster centers - for (size_t i = 0; i < num_floats; i++) { - floats[i] = 1.0 * rand() / RAND_MAX; + // generate results + for (size_t i = 0; i < num_vals; i++) { + vals[i] = 1.0 * rand() / RAND_MAX; } // return success @@ -52,16 +52,16 @@ system_on_fill( // fill sizes callback for system random source static bool -system_on_fill_sizes( +rand_libc_get_sizes( km_rand_t * const rs, - const size_t num_sizes, - size_t * const sizes + const size_t num_vals, + size_t * const vals ) { UNUSED(rs); - // generate random size_ts - for (size_t i = 0; i < num_sizes; i++) { - sizes[i] = rand(); + // generate results + for (size_t i = 0; i < num_vals; i++) { + vals[i] = rand(); } // return success @@ -70,17 +70,17 @@ system_on_fill_sizes( // system random source callbacks static const km_rand_cbs_t -SYSTEM_CBS = { - .fill = system_on_fill, - .fill_sizes = system_on_fill_sizes, +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_system( +km_rand_init_libc( km_rand_t * const rs ) { - rs->cbs = &SYSTEM_CBS; + rs->cbs = &RAND_LIBC_CBS; rs->data = NULL; } |