#include <config.h>
-#include <math.h>
-
-#include <libpspp/misc.h>
-
-#include <libpspp/str.h>
-#include <libpspp/message.h>
-
-
-#include <data/dataset.h>
-#include <data/missing-values.h>
-#include <data/casereader.h>
-#include <data/casewriter.h>
-#include <data/casegrouper.h>
-#include <data/dictionary.h>
-#include <data/format.h>
-#include <data/case.h>
-
-#include <language/lexer/variable-parser.h>
-#include <language/command.h>
-#include <language/lexer/lexer.h>
-
-#include <output/tab.h>
-#include <output/text-item.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
#include <gsl/gsl_matrix.h>
-#include <gsl/gsl_statistics.h>
#include <gsl/gsl_permutation.h>
#include <gsl/gsl_sort_vector.h>
+#include <gsl/gsl_statistics.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
-#include <math/random.h>
+#include "data/case.h"
+#include "data/casegrouper.h"
+#include "data/casereader.h"
+#include "data/casewriter.h"
+#include "data/dataset.h"
+#include "data/dictionary.h"
+#include "data/format.h"
+#include "data/missing-values.h"
+#include "language/command.h"
+#include "language/lexer/lexer.h"
+#include "language/lexer/variable-parser.h"
+#include "libpspp/message.h"
+#include "libpspp/misc.h"
+#include "libpspp/str.h"
+#include "math/random.h"
+#include "output/tab.h"
+#include "output/text-item.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-#include "quick-cluster.h"
-
/*
Struct KMeans:
Holds all of the information for the functions.
const struct variable *wv; //Weighting variable
};
+static struct Kmeans *kmeans_create (struct casereader *cs,
+ const struct variable **variables,
+ int m, int ngroups, int maxiter);
+
+static void kmeans_randomize_centers (struct Kmeans *kmeans);
+
+static int kmeans_get_nearest_group (struct Kmeans *kmeans, struct ccase *c);
+
+static void kmeans_recalculate_centers (struct Kmeans *kmeans);
+
+static int
+kmeans_calculate_indexes_and_check_convergence (struct Kmeans *kmeans);
+
+static void kmeans_order_groups (struct Kmeans *kmeans);
+
+static void kmeans_cluster (struct Kmeans *kmeans);
+
+static void quick_cluster_show_centers (struct Kmeans *kmeans, bool initial);
+
+static void quick_cluster_show_number_cases (struct Kmeans *kmeans);
+
+static void quick_cluster_show_results (struct Kmeans *kmeans);
+
+int cmd_quick_cluster (struct lexer *lexer, struct dataset *ds);
+
+static void kmeans_destroy (struct Kmeans *kmeans);
/*
Creates and returns a struct of Kmeans with given casereader 'cs', parsed variables 'variables',