GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-0b29c8ef57
c_divr.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/stats.h>
3 
4 void c_divr(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
5 {
6  int count;
7  DCELL prev;
8  int i;
9 
10  /* sort the array of values, then count differences */
11 
12  n = sort_cell(values, n);
13 
14  if (n == 0) {
15  *result = 0;
16  return;
17  }
18 
19  count = 1;
20  prev = values[0];
21 
22  for (i = 0; i < n; i++)
23  if (values[i] != prev) {
24  prev = values[i];
25  count++;
26  }
27 
28  *result = (DCELL)count;
29 }
void c_divr(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
Definition: c_divr.c:4
int sort_cell(DCELL *, int)
Definition: sort_cell.c:27
double DCELL
Definition: gis.h:629
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition: gis.h:47
int count