GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
c_stddev.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/stats.h>
6 
7 void c_stddev(DCELL * result, DCELL * values, int n, const void *closure)
8 {
9  DCELL var;
10 
11  c_var(&var, values, n, closure);
12 
13  if (Rast_is_d_null_value(&var))
14  Rast_set_d_null_value(result, 1);
15  else
16  *result = sqrt(var);
17 }
18 
19 void w_stddev(DCELL * result, DCELL(*values)[2], int n, const void *closure)
20 {
21  DCELL var;
22 
23  w_var(&var, values, n, closure);
24 
25  if (Rast_is_d_null_value(&var))
26  Rast_set_d_null_value(result, 1);
27  else
28  *result = sqrt(var);
29 }
#define Rast_is_d_null_value(dcellVal)
Definition: defs/raster.h:420
double DCELL
Definition: gis.h:603
void w_stddev(DCELL *result, DCELL(*values)[2], int n, const void *closure)
Definition: c_stddev.c:19
void c_stddev(DCELL *result, DCELL *values, int n, const void *closure)
Definition: c_stddev.c:7
stat_func c_var
float var(IClass_statistics *statistics, int band1, int band2)
Helper function for computing variance.
stat_func_w w_var
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
Definition: null_val.c:155