GRASS GIS 7 Programmer's Manual
7.8.4(2020)-exported
c_distinct.c
Go to the documentation of this file.
1
/*!
2
\file cluster/c_distinct.c
3
4
\brief Cluster library - Distinct value
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 Get distinct value
18
19
\param C pointer to Cluster structure
20
\param separation separation value
21
22
\return distinction value
23
*/
24
int
I_cluster_distinct
(
struct
Cluster *C,
double
separation)
25
{
26
int
class1, class2;
27
int
distinct;
28
double
dmin;
29
double
dsep;
30
31
/* compute sum of squares for each class */
32
I_cluster_sum2
(C);
33
34
/* find closest classes */
35
distinct = 1;
36
dmin = separation;
37
for
(class1 = 0; class1 < (C->nclasses - 1); class1++) {
38
if
(C->count[class1] < 2)
39
continue
;
40
for
(class2 = class1 + 1; class2 < C->nclasses; class2++) {
41
if
(C->count[class2] < 2)
42
continue
;
43
dsep =
I_cluster_separation
(C, class1, class2);
44
45
if
(dsep >= 0.0 && dsep < dmin) {
46
distinct = 0;
47
C->merge1 = class1;
48
C->merge2 = class2;
49
dmin = dsep;
50
}
51
}
52
}
53
54
return
distinct;
55
}
I_cluster_separation
double I_cluster_separation(struct Cluster *C, int class1, int class2)
?
Definition:
c_sep.c:26
I_cluster_sum2
int I_cluster_sum2(struct Cluster *C)
Compute sum of squares for each class.
Definition:
c_sum2.c:23
I_cluster_distinct
int I_cluster_distinct(struct Cluster *C, double separation)
Get distinct value.
Definition:
c_distinct.c:24
cluster
c_distinct.c
Generated on Thu Nov 19 2020 20:26:47 for GRASS GIS 7 Programmer's Manual by
1.8.20