GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
xshiftru.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 /****************************************************************
7 shiftru(a,b) = (unsigned) a >> b
8 ****************************************************************/
9 
10 int f_shiftru(int argc, const int *argt, void **args)
11 {
12  CELL *res = args[0];
13  CELL *arg1 = args[1];
14  CELL *arg2 = args[2];
15  int i;
16 
17  if (argc < 2)
18  return E_ARG_LO;
19  if (argc > 2)
20  return E_ARG_HI;
21 
22  if (argt[1] != CELL_TYPE || argt[2] != CELL_TYPE)
23  return E_ARG_TYPE;
24 
25  if (argt[0] != CELL_TYPE)
26  return E_RES_TYPE;
27 
28  for (i = 0; i < columns; i++) {
29  if (IS_NULL_C(&arg1[i]) || IS_NULL_C(&arg2[i]))
30  SET_NULL_C(&res[i]);
31  else
32  res[i] = ((unsigned int)arg1[i]) >> arg2[i];
33  }
34 
35  return 0;
36 }
#define CELL_TYPE
Definition: raster.h:11
#define SET_NULL_C(x)
Definition: calc.h:32
#define IS_NULL_C(x)
Definition: calc.h:28
Definition: calc.h:13
int columns
Definition: calc.c:12
int f_shiftru(int argc, const int *argt, void **args)
Definition: xshiftru.c:10
Definition: calc.h:12
int CELL
Definition: gis.h:613