17#include <grass/N_pde.h>
48 G_fatal_error(
"N_copy_array_2d: the arrays are not of equal size");
51 G_fatal_error(
"N_copy_array_2d: the arrays are not of equal size");
53 G_debug(3,
"N_copy_array_2d: copy source array to target array size %i",
58 for (i = 0; i <
source->cols_intern *
source->rows_intern; i++) {
142 double norm = 0.0, tmp = 0.0;
143 double v1 = 0.0, v2 = 0.0;
146 G_fatal_error(
"N_norm_array_2d: the arrays are not of equal size");
149 G_fatal_error(
"N_norm_array_2d: the arrays are not of equal size");
151 G_debug(3,
"N_norm_array_2d: norm of a and b size %i",
176 v2 = (
double)
b->fcell_array[i];
180 v2 = (
double)
b->dcell_array[i];
189 norm +=
fabs(v2 - v1);
243 for (
j = 0;
j < a->
rows;
j++) {
244 for (i = 0; i < a->
cols; i++) {
259 "N_calc_array_2d_stats: compute array stats, min %g, max %g, sum "
261 *
min, *
max, *sum, *nonull);
301 double va = 0.0,
vb = 0.0,
vc = 0.0;
310 G_fatal_error(
"N_math_array_2d: the arrays are not of equal size");
312 G_fatal_error(
"N_math_array_2d: the arrays are not of equal size");
314 G_fatal_error(
"N_math_array_2d: the arrays have different offsets");
316 G_debug(3,
"N_math_array_2d: mathematical calculations, size: %i",
324 G_debug(3,
"N_math_array_2d: array of type DCELL_TYPE created");
328 G_debug(3,
"N_math_array_2d: array of type FCELL_TYPE created");
332 G_debug(3,
"N_math_array_2d: array of type CELL_TYPE created");
339 "N_math_array_2d: the arrays are not of equal size");
342 "N_math_array_2d: the arrays are not of equal size");
345 "N_math_array_2d: the arrays have different offsets");
349#pragma omp for private(va, vb, vc, setnull)
417 int i = 0,
count = 0;
419 G_debug(3,
"N_convert_array_2d_null_to_zero: convert array of size %i",
448 "N_convert_array_2d_null_to_zero: %i values of type CELL_TYPE "
453 "N_convert_array_2d_null_to_zero: %i values of type "
454 "FCELL_TYPE are converted",
458 "N_convert_array_2d_null_to_zero: %i values of type "
459 "DCELL_TYPE are converted",
488 G_fatal_error(
"N_copy_array_3d: the arrays are not of equal size");
491 G_fatal_error(
"N_copy_array_3d: the arrays are not of equal size");
494 G_fatal_error(
"N_copy_array_3d: the arrays are not of equal size");
496 G_debug(3,
"N_copy_array_3d: copy source array to target array size %i",
556 double norm = 0.0, tmp = 0.0;
557 double v1 = 0.0, v2 = 0.0;
560 G_fatal_error(
"N_norm_array_3d: the arrays are not of equal size");
563 G_fatal_error(
"N_norm_array_3d: the arrays are not of equal size");
566 G_fatal_error(
"N_norm_array_3d: the arrays are not of equal size");
568 G_debug(3,
"N_norm_array_3d: norm of a and b size %i",
588 v2 = (
double)
b->fcell_array[i];
593 v2 = (
double)
b->dcell_array[i];
602 norm +=
fabs(v2 - v1);
661 for (k = 0; k < a->
depths; k++) {
662 for (
j = 0;
j < a->
rows;
j++) {
663 for (i = 0; i < a->
cols; i++) {
679 "N_calc_array_3d_stats: compute array stats, min %g, max %g, sum "
681 *
min, *
max, *sum, *nonull);
725 double va = 0.0,
vb = 0.0,
vc = 0.0;
732 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
734 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
736 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
738 G_fatal_error(
"N_math_array_3d: the arrays have different offsets");
740 G_debug(3,
"N_math_array_3d: mathematical calculations, size: %i",
749 G_debug(3,
"N_math_array_3d: array of type DCELL_TYPE created");
754 G_debug(3,
"N_math_array_3d: array of type FCELL_TYPE created");
760 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
762 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
764 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
766 G_fatal_error(
"N_math_array_3d: the arrays have different offsets");
831 int i = 0,
count = 0;
833 G_debug(3,
"N_convert_array_3d_null_to_zero: convert array of size %i",
858 "N_convert_array_3d_null_to_zero: %i values of type FCELL_TYPE "
864 "N_convert_array_3d_null_to_zero: %i values of type DCELL_TYPE "
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
void Rast3d_set_null_value(void *, int, int)
Fills the vector pointed to by c with nofElts NULL-values of type.
int Rast3d_is_null_value_num(const void *, int)
#define Rast_is_f_null_value(fcellVal)
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
void Rast_set_f_null_value(FCELL *, int)
To set a number of FCELL raster values to NULL.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
#define Rast_is_d_null_value(dcellVal)
#define Rast_is_c_null_value(cellVal)
void N_put_array_3d_value_null(N_array_3d *data, int col, int row, int depth)
This function writes a null value to the N_array_3d data at position col, row, depth.
N_array_3d * N_alloc_array_3d(int cols, int rows, int depths, int offset, int type)
Allocate memory for a N_array_3d data structure.
void N_put_array_2d_f_value(N_array_2d *data, int col, int row, FCELL value)
Writes a FCELL value to the N_array_2d struct at position col, row.
void N_put_array_3d_f_value(N_array_3d *data, int col, int row, int depth, float value)
This function writes a float value to the N_array_3d data at position col, row, depth.
DCELL N_get_array_2d_d_value(N_array_2d *data, int col, int row)
Returns the value of type DCELL at position col, row.
int N_is_array_3d_value_null(N_array_3d *data, int col, int row, int depth)
This function returns 1 if value of N_array_3d data at position col, row, depth is of type null,...
int N_is_array_2d_value_null(N_array_2d *data, int col, int row)
Returns 1 if the value of N_array_2d struct at position col, row is of type null, otherwise 0.
void N_put_array_3d_d_value(N_array_3d *data, int col, int row, int depth, double value)
Writes a double value to the N_array_3d struct at position col, row, depth.
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
double N_get_array_3d_d_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
void N_put_array_2d_value_null(N_array_2d *data, int col, int row)
Writes the null value to the N_array_2d struct at position col, row.
void N_put_array_2d_c_value(N_array_2d *data, int col, int row, CELL value)
Writes a CELL value to the N_array_2d struct at position col, row.
void N_put_array_2d_d_value(N_array_2d *data, int col, int row, DCELL value)
Writes a DCELL value to the N_array_2d struct at position col, row.
int N_convert_array_3d_null_to_zero(N_array_3d *a)
Convert all null values to zero values.
int N_convert_array_2d_null_to_zero(N_array_2d *a)
Convert all null values to zero values.
double N_norm_array_3d(N_array_3d *a, N_array_3d *b, int type)
Calculate the norm of the two input arrays.
void N_calc_array_3d_stats(N_array_3d *a, double *min, double *max, double *sum, int *nonull, int withoffset)
Calculate basic statistics of the N_array_3d struct.
void N_calc_array_2d_stats(N_array_2d *a, double *min, double *max, double *sum, int *nonull, int withoffset)
Calculate basic statistics of the N_array_2d struct.
void N_copy_array_3d(N_array_3d *source, N_array_3d *target)
Copy the source N_array_3d struct to the target N_array_3d struct.
void N_copy_array_2d(N_array_2d *source, N_array_2d *target)
Copy the source N_array_2d struct to the target N_array_2d struct.
double N_norm_array_2d(N_array_2d *a, N_array_2d *b, int type)
Calculate the norm of the two input arrays.
N_array_3d * N_math_array_3d(N_array_3d *a, N_array_3d *b, N_array_3d *result, int type)
Perform calculations with two input arrays, the result is written to a third array.
N_array_2d * N_math_array_2d(N_array_2d *a, N_array_2d *b, N_array_2d *result, int type)
Perform calculations with two input arrays, the result is written to a third array.