GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
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
}
CELL_TYPE
#define CELL_TYPE
Definition:
raster.h:11
SET_NULL_C
#define SET_NULL_C(x)
Definition:
calc.h:32
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
f_shiftru
int f_shiftru(int argc, const int *argt, void **args)
Definition:
xshiftru.c:10
E_ARG_LO
Definition:
calc.h:12
CELL
int CELL
Definition:
gis.h:602
E_RES_TYPE
Definition:
calc.h:15
calc.h
lib
calc
xshiftru.c
Generated on Mon May 31 2021 05:21:32 for GRASS GIS 7 Programmer's Manual by
1.8.13