GRASS GIS 7 Programmer's Manual
7.8.2(2019)-exported
xceil.c
Go to the documentation of this file.
1
2
#include <math.h>
3
4
#include <grass/gis.h>
5
#include <grass/raster.h>
6
#include <grass/calc.h>
7
8
/**********************************************************************
9
ceil(x)
10
11
the smallest integral value that is not less than x
12
**********************************************************************/
13
14
int
f_ceil
(
int
argc,
const
int
*argt,
void
**args)
15
{
16
int
i;
17
18
if
(argc < 1)
19
return
E_ARG_LO;
20
if
(argc > 1)
21
return
E_ARG_HI;
22
23
if
(argt[0] != argt[1])
24
return
E_RES_TYPE;
25
26
switch
(argt[1]) {
27
case
CELL_TYPE:
28
{
29
CELL *res = args[0];
30
CELL *arg1 = args[1];
31
32
for
(i = 0; i <
columns
; i++)
33
if
(IS_NULL_C(&arg1[i]))
34
SET_NULL_C(&res[i]);
35
else
36
res[i] = arg1[i];
37
return
0;
38
}
39
case
FCELL_TYPE:
40
{
41
FCELL *res = args[0];
42
FCELL *arg1 = args[1];
43
44
for
(i = 0; i <
columns
; i++)
45
if
(IS_NULL_F(&arg1[i]))
46
SET_NULL_F(&res[i]);
47
else
48
res[i] = (FCELL) ceil(arg1[i]);
49
return
0;
50
}
51
case
DCELL_TYPE:
52
{
53
DCELL *res = args[0];
54
DCELL *arg1 = args[1];
55
56
for
(i = 0; i <
columns
; i++)
57
if
(IS_NULL_D(&arg1[i]))
58
SET_NULL_D(&res[i]);
59
else
60
res[i] = ceil(arg1[i]);
61
return
0;
62
}
63
default
:
64
return
E_INV_TYPE;
65
}
66
}
f_ceil
int f_ceil(int argc, const int *argt, void **args)
Definition:
xceil.c:13
columns
int columns
Definition:
calc.c:12
calc
xceil.c
Generated on Sat Jan 25 2020 17:06:53 for GRASS GIS 7 Programmer's Manual by
1.8.16