PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ kmeans()

static uint8_t kmeans ( POINT4D objs,
int *  clusters,
uint32_t  n,
POINT4D centers,
uint32_t  k 
)
static

Definition at line 90 of file lwkmeans.c.

91 {
92  uint8_t converged = LW_FALSE;
93 
94  for (uint32_t i = 0; i < KMEANS_MAX_ITERATIONS; i++)
95  {
96  LW_ON_INTERRUPT(break);
97  converged = update_r(objs, clusters, n, centers, k);
98  if (converged)
99  break;
100  update_means(objs, clusters, n, centers, k);
101  }
102  if (!converged)
103  lwerror("%s did not converge after %d iterations", __func__, KMEANS_MAX_ITERATIONS);
104  return converged;
105 }
#define LW_FALSE
Definition: liblwgeom.h:108
#define LW_ON_INTERRUPT(x)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define KMEANS_MAX_ITERATIONS
Definition: lwkmeans.c:20
static void update_means(POINT4D *objs, int *clusters, uint32_t n, POINT4D *centers, uint32_t k)
Definition: lwkmeans.c:67
static uint8_t update_r(POINT4D *objs, int *clusters, uint32_t n, POINT4D *centers, uint32_t k)
Definition: lwkmeans.c:33

References KMEANS_MAX_ITERATIONS, LW_FALSE, LW_ON_INTERRUPT, lwerror(), update_means(), and update_r().

Referenced by lwgeom_cluster_kmeans().

Here is the call graph for this function:
Here is the caller graph for this function: