From 2947bcefdfc971f9729003a51cfe4d65f33b19db Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 5 Feb 2019 01:26:15 -0500 Subject: add comments, remove cruft --- src/main.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 20ce9af..8bae71c 100644 --- a/src/main.c +++ b/src/main.c @@ -12,14 +12,21 @@ #include "util.h" #include "km.h" +// maximum number of clusters to test #define MAX_CLUSTERS 10 + +// number of tests to run on each cluster size #define NUM_TESTS 100 #define MAX_BEST 10 +// output image size #define IM_WIDTH 128 #define IM_HEIGHT 128 #define IM_STRIDE (3 * IM_WIDTH) +// static output image data buffer +static uint8_t im_data[3 * IM_WIDTH * IM_HEIGHT]; + typedef struct { float score; km_set_t set; @@ -75,22 +82,6 @@ ctx_best_sort( ); } -/* - * static void - * ctx_best_walk( - * const ctx_t * const ctx, - * void (*on_best)(const km_set_t * const, const size_t, const float, void *), - * void * const cb_data - * ) { - * if (on_best) { - * // walk best sets and emit each one - * for (size_t i = 0; i < ctx_get_max_best(ctx); i++) { - * on_best(&(ctx->best[i].set), i, ctx->best[i].score, cb_data); - * } - * } - * } - */ - static bool load_on_shape( const km_shape_t * const shape, @@ -222,9 +213,6 @@ FIND_CBS = { .on_best = find_on_best, }; -// static image data buffer -static uint8_t im_data[3 * IM_WIDTH * IM_HEIGHT]; - static void ctx_save_png( const ctx_t * const ctx, @@ -266,7 +254,7 @@ static const char USAGE_FORMAT[] = "Arguments:\n" "* init: Cluster init method (one of \"rand\" or \"set\").\n" "* data_path: Path to input data file.\n" - "* png_path: Path to output file (optional).\n" + "* png_path: Path to output PNG (optional).\n" ""; int main(int argc, char *argv[]) { @@ -281,8 +269,9 @@ int main(int argc, char *argv[]) { const char * const data_path = argv[2]; const char * const png_path = (argc > 3) ? argv[3] : NULL; - // init random seed + // init rng srand(getpid()); + const int rand_seed = rand(); // init context ctx_t ctx; @@ -290,7 +279,7 @@ int main(int argc, char *argv[]) { ctx.init_type = km_init_get_type(init_type_name); // init ctx rng - km_rand_init_erand48(&(ctx.rs), rand()); + km_rand_init_erand48(&(ctx.rs), rand_seed); // init data set km_set_t set; -- cgit v1.2.3