GRASS 8 Programmer's Manual
8.6.0dev(2026)-56a9afeb9f
Loading...
Searching...
No Matches
xmul.c
Go to the documentation of this file.
1
#include <
grass/gis.h
>
2
#include <
grass/raster.h
>
3
#include <
grass/calc.h
>
4
5
/****************************************************************
6
mul(a,b) = a * b
7
****************************************************************/
8
9
int
f_mul
(
int
argc
,
const
int
*
argt
,
void
**args)
10
{
11
int
i,
j
;
12
13
if
(
argc
< 1)
14
return
E_ARG_LO
;
15
16
for
(i = 1; i <=
argc
; i++)
17
if
(
argt
[i] !=
argt
[0])
18
return
E_ARG_TYPE
;
19
20
switch
(
argt
[0]) {
21
case
CELL_TYPE
: {
22
CELL
*res = args[0];
23
CELL
**
argz
= (
CELL
**)args;
24
25
for
(i = 0; i <
columns
; i++) {
26
res[i] = 1;
27
for
(
j
= 1;
j
<=
argc
;
j
++) {
28
if
(
IS_NULL_C
(&
argz
[
j
][i])) {
29
SET_NULL_C
(&res[i]);
30
break
;
31
}
32
res[i] *=
argz
[
j
][i];
33
}
34
}
35
return
0;
36
}
37
case
FCELL_TYPE
: {
38
FCELL
*res = args[0];
39
FCELL
**
argz
= (
FCELL
**)args;
40
41
for
(i = 0; i <
columns
; i++) {
42
res[i] = 1;
43
for
(
j
= 1;
j
<=
argc
;
j
++) {
44
if
(
IS_NULL_F
(&
argz
[
j
][i])) {
45
SET_NULL_F
(&res[i]);
46
break
;
47
}
48
res[i] *=
argz
[
j
][i];
49
}
50
}
51
return
0;
52
}
53
case
DCELL_TYPE
: {
54
DCELL
*res = args[0];
55
DCELL
**
argz
= (
DCELL
**)args;
56
57
for
(i = 0; i <
columns
; i++) {
58
res[i] = 1;
59
for
(
j
= 1;
j
<=
argc
;
j
++) {
60
if
(
IS_NULL_D
(&
argz
[
j
][i])) {
61
SET_NULL_D
(&res[i]);
62
break
;
63
}
64
res[i] *=
argz
[
j
][i];
65
}
66
}
67
return
0;
68
}
69
default
:
70
return
E_INV_TYPE
;
71
}
72
}
calc.h
E_INV_TYPE
@ E_INV_TYPE
Definition
calc.h:15
E_ARG_TYPE
@ E_ARG_TYPE
Definition
calc.h:13
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_mul
func_t f_mul
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
xmul.c
Generated on Sat Apr 4 2026 17:44:23 for GRASS 8 Programmer's Manual by
1.9.8