PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ update_means()

static void update_means ( POINT2D **  objs,
int *  clusters,
uint32_t  n,
POINT2D **  centers,
uint32_t weights,
uint32_t  k 
)
static

Definition at line 65 of file lwkmeans.c.

References POINT2D::x, and POINT2D::y.

Referenced by kmeans().

66 {
67  uint32_t i;
68 
69  memset(weights, 0, sizeof(int) * k);
70  for (i = 0; i < k; i++)
71  {
72  centers[i]->x = 0.0;
73  centers[i]->y = 0.0;
74  }
75  for (i = 0; i < n; i++)
76  {
77  centers[clusters[i]]->x += objs[i]->x;
78  centers[clusters[i]]->y += objs[i]->y;
79  weights[clusters[i]] += 1;
80  }
81  for (i = 0; i < k; i++)
82  {
83  centers[i]->x /= weights[i];
84  centers[i]->y /= weights[i];
85  }
86 }
unsigned int uint32_t
Definition: uthash.h:78
double x
Definition: liblwgeom.h:327
double y
Definition: liblwgeom.h:327
Here is the caller graph for this function: