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