GRASS GIS 8 Programmer's Manual 8.4.1(2025)-45ca3179ab
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/****************************************************************
6mul(a,b) = a * b
7****************************************************************/
8
9int 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}
int columns
Definition calc.c:11
int f_mul(int argc, const int *argt, void **args)
Definition xmul.c:9