aboutsummaryrefslogtreecommitdiff
path: root/km.h
diff options
context:
space:
mode:
Diffstat (limited to 'km.h')
-rw-r--r--km.h51
1 files changed, 24 insertions, 27 deletions
diff --git a/km.h b/km.h
index 6f09009..866e941 100644
--- a/km.h
+++ b/km.h
@@ -5,14 +5,6 @@
#include <stdint.h> // uint8_t
#include <stdio.h> // FILE
-typedef enum {
- KM_INIT_TYPE_RAND,
- KM_INIT_TYPE_FORGY,
- KM_INIT_TYPE_LAST,
-} km_init_type_t;
-
-km_init_type_t km_get_init_type(const char * const);
-
// forward typedef for callbacks
typedef struct km_rand_t_ km_rand_t;
@@ -85,22 +77,6 @@ _Bool km_set_normalize(km_set_t * const);
// get pointer to data set row
float *km_set_get_row(const km_set_t *, const size_t);
-// init cluster set by picking random centroids
-_Bool km_init_rand(
- km_set_t *,
- const size_t,
- const size_t,
- km_rand_t *
-);
-
-// init cluster set by picking random rows from set
-_Bool km_init_forgy(
- km_set_t * const,
- const size_t,
- const km_set_t * const,
- km_rand_t *
-);
-
typedef struct {
float d2;
size_t cluster;
@@ -197,7 +173,7 @@ typedef struct {
void (*on_error)(const char * const, void *);
} km_load_cbs_t;
-// load set from file
+// load set from file handle
_Bool
km_load(
FILE * const fh,
@@ -205,11 +181,32 @@ km_load(
void * const cb_data
);
-_Bool
-km_load_path(
+// load set from path
+_Bool km_load_path(
const char * const path,
const km_load_cbs_t * const cbs,
void * const cb_data
);
+typedef enum {
+ // init cluster set by picking random centroids
+ KM_INIT_TYPE_RAND,
+
+ // init cluster set by picking random rows from set
+ KM_INIT_TYPE_FORGY,
+
+ KM_INIT_TYPE_LAST,
+} km_init_type_t;
+
+km_init_type_t km_init_get_type(const char * const);
+
+// init cluster set using given method
+_Bool km_init(
+ km_set_t * const,
+ const km_init_type_t,
+ const size_t,
+ const km_set_t * const,
+ km_rand_t * const
+);
+
#endif /* KM_H */