20 #include <grass/N_pde.h>
51 G_fatal_error(
"N_copy_array_2d: the arrays are not of equal size");
54 G_fatal_error(
"N_copy_array_2d: the arrays are not of equal size");
56 G_debug(3,
"N_copy_array_2d: copy source array to target array size %i",
145 double norm = 0.0, tmp = 0.0;
146 double v1 = 0.0, v2 = 0.0;
149 G_fatal_error(
"N_norm_array_2d: the arrays are not of equal size");
152 G_fatal_error(
"N_norm_array_2d: the arrays are not of equal size");
154 G_debug(3,
"N_norm_array_2d: norm of a and b size %i",
175 v2 = (
double)
b->cell_array[i];
179 v2 = (
double)
b->fcell_array[i];
183 v2 = (
double)
b->dcell_array[i];
192 norm += fabs(v2 - v1);
214 int *nonull,
int withoffset)
222 if (withoffset == 1) {
246 for (j = 0; j < a->
rows; j++) {
247 for (i = 0; i < a->
cols; i++) {
262 "N_calc_array_2d_stats: compute array stats, min %g, max %g, sum "
264 *
min, *
max, *sum, *nonull);
303 int i, j, setnull = 0;
304 double va = 0.0, vb = 0.0, vc = 0.0;
313 G_fatal_error(
"N_math_array_2d: the arrays are not of equal size");
315 G_fatal_error(
"N_math_array_2d: the arrays are not of equal size");
317 G_fatal_error(
"N_math_array_2d: the arrays have different offsets");
319 G_debug(3,
"N_math_array_2d: mathematical calculations, size: %i",
327 G_debug(3,
"N_math_array_2d: array of type DCELL_TYPE created");
331 G_debug(3,
"N_math_array_2d: array of type FCELL_TYPE created");
335 G_debug(3,
"N_math_array_2d: array of type CELL_TYPE created");
342 "N_math_array_2d: the arrays are not of equal size");
345 "N_math_array_2d: the arrays are not of equal size");
348 "N_math_array_2d: the arrays have different offsets");
352 #pragma omp for private(va, vb, vc, setnull)
420 int i = 0,
count = 0;
422 G_debug(3,
"N_convert_array_2d_null_to_zero: convert array of size %i",
451 "N_convert_array_2d_null_to_zero: %i values of type CELL_TYPE "
456 "N_convert_array_2d_null_to_zero: %i values of type "
457 "FCELL_TYPE are converted",
461 "N_convert_array_2d_null_to_zero: %i values of type "
462 "DCELL_TYPE are converted",
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");
497 G_fatal_error(
"N_copy_array_3d: the arrays are not of equal size");
499 G_debug(3,
"N_copy_array_3d: copy source array to target array size %i",
559 double norm = 0.0, tmp = 0.0;
560 double v1 = 0.0, v2 = 0.0;
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");
569 G_fatal_error(
"N_norm_array_3d: the arrays are not of equal size");
571 G_debug(3,
"N_norm_array_3d: norm of a and b size %i",
591 v2 = (
double)
b->fcell_array[i];
596 v2 = (
double)
b->dcell_array[i];
605 norm += fabs(v2 - v1);
628 int *nonull,
int withoffset)
636 if (withoffset == 1) {
643 for (k = 0 - a->
offset; k < a->depths + a->
offset; k++) {
664 for (k = 0; k < a->
depths; k++) {
665 for (j = 0; j < a->
rows; j++) {
666 for (i = 0; i < a->
cols; i++) {
682 "N_calc_array_3d_stats: compute array stats, min %g, max %g, sum "
684 *
min, *
max, *sum, *nonull);
727 int i, j, k, setnull = 0;
728 double va = 0.0, vb = 0.0, vc = 0.0;
735 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
737 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
739 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
741 G_fatal_error(
"N_math_array_3d: the arrays have different offsets");
743 G_debug(3,
"N_math_array_3d: mathematical calculations, size: %i",
752 G_debug(3,
"N_math_array_3d: array of type DCELL_TYPE created");
757 G_debug(3,
"N_math_array_3d: array of type FCELL_TYPE created");
763 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
765 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
767 G_fatal_error(
"N_math_array_3d: the arrays are not of equal size");
769 G_fatal_error(
"N_math_array_3d: the arrays have different offsets");
772 for (k = 0 - a->
offset; k < a->depths + a->
offset; k++) {
834 int i = 0,
count = 0;
836 G_debug(3,
"N_convert_array_3d_null_to_zero: convert array of size %i",
861 "N_convert_array_3d_null_to_zero: %i values of type FCELL_TYPE "
867 "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.
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.
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.
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.
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
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.
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.
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.
double N_norm_array_2d(N_array_2d *a, N_array_2d *b, int type)
Calculate the norm of the two input arrays.