-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk_means.h
More file actions
33 lines (26 loc) · 1.18 KB
/
k_means.h
File metadata and controls
33 lines (26 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef __K_MEANS_H
#define __K_MEANS_H
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include<mpi.h>
/*<>Measures the Euclidean distance between two vectors v1, v2 with dim components<>*/
float euclidDistance(int dim, //no. dimensions
float *v1, //[numdims]
float *v2); //[numdims]
/*<>Returns the index of the cluster that is closest to the given vector<>*/
int getNearestClusterIndex(int numClusters, //no. clusters
int numCoords, //no. coordinates
float *vector, //[numCoords]
float **clusters); //[numClusters][numCoords]
/*<>Computes K clusters and stores them in **clusters based on vectorial group
**vectors and the limit - maximun number of algorithm iterations allowed<>*/
int k_means(float **vectors, //in: [numVectors][numDims]
int numDims, //num of coordinates in vector
int numVectors,
int numClusters,
float limit, //max num of iterations
int *vectorToClusterRelevance, //out: [numVectors]
float **clusters, //out: [numClusters][numDims]
MPI_Comm comm);
#endif //__K_MEANS_H