GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_intr.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/stats.h>
3 
4 void c_intr(DCELL * result, DCELL * values, int n, const void *closure)
5 {
6  DCELL center;
7  int count;
8  int diff;
9  int i;
10 
11  if (G_is_d_null_value(&values[n / 2])) {
12  G_set_d_null_value(result, 1);
13  return;
14  }
15 
16  center = values[n / 2];
17  count = 0;
18  diff = 0;
19 
20  for (i = 0; i < n; i++) {
21  if (G_is_d_null_value(&values[i]))
22  continue;
23 
24  count++;
25  if (values[i] != center)
26  diff++;
27  }
28 
29  count--;
30 
31  if (count <= 0)
32  *result = 0;
33  else
34  *result = (diff * 100.0 + (count / 2)) / count + 1;
35 }
void G_set_d_null_value(DCELL *dcellVals, int numVals)
Definition: null_val.c:176
int count
void c_intr(DCELL *result, DCELL *values, int n, const void *closure)
Definition: c_intr.c:4
int G_is_d_null_value(const DCELL *dcellVal)
Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in G_is_f_null_value().
Definition: null_val.c:306
int n
Definition: dataquad.c:291