2
2
#include <grass/gis.h>
3
#include <grass/raster.h>
4
5
#include "expression.h"
5
6
#include "func_proto.h"
7
8
/****************************************************************
9
add(a,b,c,...) = a + b + c + ...
9
10
****************************************************************/
11
12
int f_add(int argc, const int *argt, void **args)
20
if (argt[1] != argt[0] || argt[2] != argt[0])
19
for (i = 1; i <= argc; i++)
20
if (argt[i] != argt[0])
26
26
CELL *res = args[0];
27
CELL **argz = (CELL **) args;
30
29
for (i = 0; i < columns; i++) {
31
if (IS_NULL_C(&arg1[i]) || IS_NULL_C(&arg2[i]))
34
res[i] = arg1[i] + arg2[i];
31
for (j = 1; j <= argc; j++) {
32
if (IS_NULL_C(&argz[j][i])) {
40
43
FCELL *res = args[0];
41
FCELL *arg1 = args[1];
42
FCELL *arg2 = args[2];
44
FCELL **argz = (FCELL **) args;
44
46
for (i = 0; i < columns; i++) {
45
if (IS_NULL_F(&arg1[i]) || IS_NULL_F(&arg2[i]))
48
res[i] = arg1[i] + arg2[i];
48
for (j = 1; j <= argc; j++) {
49
if (IS_NULL_F(&argz[j][i])) {
54
60
DCELL *res = args[0];
55
DCELL *arg1 = args[1];
56
DCELL *arg2 = args[2];
61
DCELL **argz = (DCELL **) args;
58
63
for (i = 0; i < columns; i++) {
59
if (IS_NULL_D(&arg1[i]) || IS_NULL_D(&arg2[i]))
62
res[i] = arg1[i] + arg2[i];
65
for (j = 1; j <= argc; j++) {
66
if (IS_NULL_D(&argz[j][i])) {