GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
c_sum2.c
Go to the documentation of this file.
1
/*!
2
\file cluster/c_sum2.c
3
4
\brief Cluster library - Sum of squares
5
6
(C) 2001-2009 by the GRASS Development Team
7
8
This program is free software under the GNU General Public License
9
(>=v2). Read the file COPYING that comes with GRASS for details.
10
11
\author Original author CERL
12
*/
13
14
#include <
grass/cluster.h
>
15
16
/*!
17
\brief Compute sum of squares for each class
18
19
\param C pointer to Cluster structure
20
21
\return 0
22
*/
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)"
, C->
npoints
,
29
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
}
I_cluster_sum2
int I_cluster_sum2(struct Cluster *C)
Compute sum of squares for each class.
Definition:
c_sum2.c:23
cluster.h
G_debug
int G_debug(int, const char *,...) __attribute__((format(printf
Cluster
Definition:
cluster.h:7
Cluster::sum2
double ** sum2
Definition:
cluster.h:22
Cluster::npoints
int npoints
Definition:
cluster.h:9
Cluster::nclasses
int nclasses
Definition:
cluster.h:26
Cluster::points
DCELL ** points
Definition:
cluster.h:10
Cluster::nbands
int nbands
Definition:
cluster.h:8
lib
cluster
c_sum2.c
Generated on Sun Dec 22 2024 07:38:11 for GRASS GIS 8 Programmer's Manual by
1.9.1