GRASS 8 Programmer's Manual
8.6.0dev(2026)-5f4f7ad06c
Loading...
Searching...
No Matches
xfloor.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
/**********************************************************************
8
floor(x)
9
10
the largest integral value that is not greater than x
11
**********************************************************************/
12
13
int
f_floor
(
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
)
floor
(
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] =
floor
(
arg1
[i]);
57
return
0;
58
}
59
default
:
60
return
E_INV_TYPE
;
61
}
62
}
calc.h
E_INV_TYPE
@ E_INV_TYPE
Definition
calc.h:15
E_RES_TYPE
@ E_RES_TYPE
Definition
calc.h:14
E_ARG_HI
@ E_ARG_HI
Definition
calc.h:12
E_ARG_LO
@ E_ARG_LO
Definition
calc.h:11
IS_NULL_C
#define IS_NULL_C(x)
Definition
calc.h:26
SET_NULL_D
#define SET_NULL_D(x)
Definition
calc.h:32
columns
int columns
Definition
calc.c:11
SET_NULL_C
#define SET_NULL_C(x)
Definition
calc.h:30
IS_NULL_F
#define IS_NULL_F(x)
Definition
calc.h:27
IS_NULL_D
#define IS_NULL_D(x)
Definition
calc.h:28
SET_NULL_F
#define SET_NULL_F(x)
Definition
calc.h:31
AMI_STREAM
Definition
ami_stream.h:153
f_floor
func_t f_floor
gis.h
FCELL
float FCELL
Definition
gis.h:636
DCELL
double DCELL
Definition
gis.h:635
CELL
int CELL
Definition
gis.h:634
raster.h
FCELL_TYPE
#define FCELL_TYPE
Definition
raster.h:12
DCELL_TYPE
#define DCELL_TYPE
Definition
raster.h:13
CELL_TYPE
#define CELL_TYPE
Definition
raster.h:11
lib
calc
xfloor.c
Generated on Sat Apr 4 2026 07:00:45 for GRASS 8 Programmer's Manual by
1.9.8