GRASS GIS 7 Programmer's Manual  7.0.5(2016)-r00000
c_sum2.c
Go to the documentation of this file.
1 
14 #include <grass/cluster.h>
15 
23 int I_cluster_sum2(struct Cluster *C)
24 {
25  int p, band, class;
26  double q;
27 
28  G_debug(3, "I_cluster_sum2(npoints=%d,nclasses=%d,nbands=%d)",
29  C->npoints, C->nclasses, C->nbands);
30 
31  for (class = 0; class < C->nclasses; class++)
32  for (band = 0; band < C->nbands; band++)
33  C->sum2[band][class] = 0;
34 
35  for (p = 0; p < C->npoints; p++) {
36  class = C->class[p];
37  if (class < 0)
38  continue;
39  for (band = 0; band < C->nbands; band++) {
40  q = C->points[band][p];
41  C->sum2[band][class] += q * q;
42  }
43  }
44 
45  return 0;
46 }
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
int I_cluster_sum2(struct Cluster *C)
Compute sum of squares for each class.
Definition: c_sum2.c:23