GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
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
}
lib
stats
c_intr.c
Generated on Thu Sep 26 2013 09:47:58 for GRASS Programmer's Manual by
1.8.4