A piece of code that implements the K Means algorithm in a number of vectors. The number of vectors, vector dimensions and final clusters are defined in compile time. Also the vectors are randomly generated.
This implementation takes advantage of multiple cores and vector processing. OpenMP and gcc optimization is used respectively.
gcc kmeans.c -o kmeans -O3 -fopenmp
- Load vectors from a file
- Initialize centers randomly (not needed for the time)