12 #include "Clustering_c.h"
13 #include "Clustering.h"
16 #include "macros_impl.h"
26 DEFINE_GETTER(Clustering,
int, verbose)
27 DEFINE_GETTER(Clustering,
int, spherical)
28 DEFINE_GETTER(Clustering,
int, update_index)
29 DEFINE_GETTER(Clustering,
int, frozen_centroids)
31 DEFINE_GETTER(Clustering,
int, min_points_per_centroid)
32 DEFINE_GETTER(Clustering,
int, max_points_per_centroid)
34 DEFINE_GETTER(Clustering,
int, seed)
37 DEFINE_GETTER(Clustering,
size_t, d)
40 DEFINE_GETTER(Clustering,
size_t, k)
47 params->niter = d.
niter;
48 params->nredo = d.
nredo;
49 params->seed = d.
seed;
52 params->verbose = d.verbose;
71 void faiss_Clustering_centroids(
72 FaissClustering* clustering,
float** centroids,
size_t* size) {
73 std::vector<float>& v =
reinterpret_cast<Clustering*
>(clustering)->centroids;
75 *centroids = v.data();
84 void faiss_Clustering_obj(
85 FaissClustering* clustering,
float** obj,
size_t* size) {
86 std::vector<float>& v =
reinterpret_cast<Clustering*
>(clustering)->obj;
96 int faiss_Clustering_new(FaissClustering** p_clustering,
int d,
int k) {
99 *p_clustering =
reinterpret_cast<FaissClustering*
>(c);
104 int faiss_Clustering_new_with_params(
108 *p_clustering =
reinterpret_cast<FaissClustering*
>(c);
114 int faiss_Clustering_train(
115 FaissClustering* clustering, idx_t n,
const float* x, FaissIndex* index) {
117 reinterpret_cast<Clustering*
>(clustering)->train(
118 n, x, *reinterpret_cast<Index*>(index));
123 void faiss_Clustering_free(FaissClustering* clustering) {
124 delete reinterpret_cast<Clustering*
>(clustering);
127 int faiss_kmeans_clustering (
size_t d,
size_t n,
size_t k,
int nredo
redo clustering this many times and keep best
int niter
clustering iterations
int nredo
redo clustering this many times and keep best
int spherical
(bool) do we want normalized centroids?
int seed
seed for the random number generator
bool frozen_centroids
use the centroids provided as input and do not change them during iterations
int frozen_centroids
(bool) use the centroids provided as input and do not change them during iterations ...
int max_points_per_centroid
to limit size of dataset
int min_points_per_centroid
otherwise you get a warning
float kmeans_clustering(size_t d, size_t n, size_t k, const float *x, float *centroids)
int seed
seed for the random number generator
bool update_index
update index after each iteration?
int niter
clustering iterations
int update_index
(bool) update index after each iteration?
bool spherical
do we want normalized centroids?
int min_points_per_centroid
otherwise you get a warning
int max_points_per_centroid
to limit size of dataset