GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_max.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 
3 void c_max(DCELL * result, DCELL * values, int n, const void *closure)
4 {
5  DCELL max;
6  int i;
7 
8  G_set_d_null_value(&max, 1);
9 
10  for (i = 0; i < n; i++) {
11  if (G_is_d_null_value(&values[i]))
12  continue;
13 
14  if (G_is_d_null_value(&max) || max < values[i])
15  max = values[i];
16  }
17 
18  if (G_is_d_null_value(&max))
19  G_set_d_null_value(result, 1);
20  else
21  *result = max;
22 }
23 
24 void w_max(DCELL * result, DCELL(*values)[2], int n, const void *closure)
25 {
26  DCELL max;
27  int i;
28 
29  G_set_d_null_value(&max, 1);
30 
31  for (i = 0; i < n; i++) {
32  if (G_is_d_null_value(&values[i][0]))
33  continue;
34 
35  if (G_is_d_null_value(&max) || max < values[i][0])
36  max = values[i][0];
37  }
38 
39  if (G_is_d_null_value(&max))
40  G_set_d_null_value(result, 1);
41  else
42  *result = max;
43 }
void G_set_d_null_value(DCELL *dcellVals, int numVals)
Definition: null_val.c:176
void c_max(DCELL *result, DCELL *values, int n, const void *closure)
Definition: c_max.c:3
#define max(x, y)
Definition: draw2.c:69
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
void w_max(DCELL *result, DCELL(*values)[2], int n, const void *closure)
Definition: c_max.c:24
int n
Definition: dataquad.c:291