GRASS GIS 8 Programmer's Manual 8.2.1(2023)-exported
xand2.c
Go to the documentation of this file.
1
2#include <grass/gis.h>
3#include <grass/raster.h>
4#include <grass/calc.h>
5
6/****************************************************************
7and2(a,b,c,...) = a && b && c && ...
8
9Differs from and() in that the boolean axioms:
10
11 false && x == false
12 x && false == false
13
14hold even when x is null.
15****************************************************************/
16
17int f_and2(int argc, const int *argt, void **args)
18{
19 CELL *res = args[0];
20 CELL **argz = (CELL **) args;
21 int i, j;
22
23 if (argc < 1)
24 return E_ARG_LO;
25
26 if (argt[0] != CELL_TYPE)
27 return E_RES_TYPE;
28
29 for (i = 1; i <= argc; i++)
30 if (argt[i] != CELL_TYPE)
31 return E_ARG_TYPE;
32
33 for (i = 0; i < columns; i++) {
34 res[i] = 1;
35 for (j = 1; j <= argc; j++) {
36 if (!IS_NULL_C(&argz[j][i]) && !argz[j][i]) {
37 res[i] = 0;
38 break;
39 }
40 if (IS_NULL_C(&argz[j][i]))
41 SET_NULL_C(&res[i]);
42 }
43 }
44
45 return 0;
46}
int columns
Definition: calc.c:12
int f_and2(int argc, const int *argt, void **args)
Definition: xand2.c:17