GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
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 SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Original author CERL
10 */
11
12#include <grass/cluster.h>
13
14/*!
15 \brief Get distinct value
16
17 \param C pointer to Cluster structure
18 \param separation separation value
19
20 \return distinction value
21 */
23{
24 int class1, class2;
25 int distinct;
26 double dmin;
27 double dsep;
28
29 /* compute sum of squares for each class */
31
32 /* find closest classes */
33 distinct = 1;
34 dmin = separation;
35 for (class1 = 0; class1 < (C->nclasses - 1); class1++) {
36 if (C->count[class1] < 2)
37 continue;
38 for (class2 = class1 + 1; class2 < C->nclasses; class2++) {
39 if (C->count[class2] < 2)
40 continue;
42
43 if (dsep >= 0.0 && dsep < dmin) {
44 distinct = 0;
45 C->merge1 = class1;
46 C->merge2 = class2;
47 dmin = dsep;
48 }
49 }
50 }
51
52 return distinct;
53}
int I_cluster_distinct(struct Cluster *C, double separation)
Get distinct value.
Definition c_distinct.c:22
double I_cluster_separation(struct Cluster *, int, int)
?
Definition c_sep.c:24
int I_cluster_sum2(struct Cluster *)
Compute sum of squares for each class.
Definition c_sum2.c:21
int * count
Definition cluster.h:18
int nclasses
Definition cluster.h:26
int merge2
Definition cluster.h:27
int merge1
Definition cluster.h:27