GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_sum2.c
Go to the documentation of this file.
1 #include <grass/cluster.h>
2 
3 /* compute sum of squares for each class */
4 int I_cluster_sum2(struct Cluster *C)
5 {
6  int p, band, class;
7  double q;
8 
9  /*
10  fprintf (stderr, "I_cluster_sum2(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
11  */
12  for (class = 0; class < C->nclasses; class++)
13  for (band = 0; band < C->nbands; band++)
14  C->sum2[band][class] = 0;
15 
16  for (p = 0; p < C->npoints; p++) {
17  class = C->class[p];
18  if (class < 0)
19  continue;
20  for (band = 0; band < C->nbands; band++) {
21  q = C->points[band][p];
22  C->sum2[band][class] += q * q;
23  }
24  }
25 
26  return 0;
27 }
tuple q
Definition: forms.py:2019
#define C
Definition: intr_char.c:17
int I_cluster_sum2(struct Cluster *C)
Definition: c_sum2.c:4
for(cat=0;;cat++)
Definition: g3dcats.c:140