GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
xshiftr.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
shiftr(a,b) = a >> b
8
****************************************************************/
9
10
int
f_shiftr
(
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] = arg1[i] >> arg2[i];
33
}
34
35
return
0;
36
}
CELL_TYPE
#define CELL_TYPE
Definition:
raster.h:11
SET_NULL_C
#define SET_NULL_C(x)
Definition:
calc.h:32
f_shiftr
int f_shiftr(int argc, const int *argt, void **args)
Definition:
xshiftr.c:10
E_ARG_TYPE
Definition:
calc.h:14
IS_NULL_C
#define IS_NULL_C(x)
Definition:
calc.h:28
E_ARG_HI
Definition:
calc.h:13
columns
int columns
Definition:
calc.c:12
raster.h
gis.h
E_ARG_LO
Definition:
calc.h:12
CELL
int CELL
Definition:
gis.h:613
E_RES_TYPE
Definition:
calc.h:15
calc.h
lib
calc
xshiftr.c
Generated on Tue Feb 14 2023 05:56:02 for GRASS GIS 8 Programmer's Manual by
1.8.13