18 #include <grass/N_pde.h>
63 G_debug(5,
"N_create_gradient_2d: create N_gradient_2d");
85 G_debug(5,
"N_copy_gradient_2d: copy N_gradient_2d");
87 if (!source || !target)
90 target->
NC = source->
NC;
91 target->
SC = source->
SC;
92 target->
WC = source->
WC;
93 target->
EC = source->
EC;
117 double NC = 0, SC = 0, WC = 0, EC = 0;
126 5,
"N_get_gradient_2d: calculate N_gradient_2d NC %g SC %g WC %g EC %g",
185 double TC,
double BC)
189 G_debug(5,
"N_create_gradient_3d: create N_gradient_3d");
213 G_debug(5,
"N_copy_gradient_3d: copy N_gradient_3d");
215 if (!source || !target)
218 target->
NC = source->
NC;
219 target->
SC = source->
SC;
220 target->
WC = source->
WC;
221 target->
EC = source->
EC;
222 target->
TC = source->
TC;
223 target->
BC = source->
BC;
250 double NC, SC, WC, EC, TC, BC;
261 "N_get_gradient_3d: calculate N_gradient_3d NC %g SC %g WC %g EC "
263 NC, SC, WC, EC, TC, BC);
327 double WC,
double EC,
328 double SWS,
double SES)
333 "N_create_gradient_neighbours_x: create N_gradient_neighbours_x");
358 G_debug(6,
"N_copy_gradient_neighbours_x: copy N_gradient_neighbours_x");
360 if (!source || !target)
363 target->
NWN = source->
NWN;
364 target->
NEN = source->
NEN;
365 target->
WC = source->
WC;
366 target->
EC = source->
EC;
367 target->
SWS = source->
SWS;
368 target->
SES = source->
SES;
419 double NC,
double SC,
420 double SWW,
double SEE)
425 "N_create_gradient_neighbours_y: create N_gradient_neighbours_y");
450 G_debug(6,
"N_copy_gradient_neighbours_y: copy N_gradient_neighbours_y");
452 if (!source || !target)
455 target->
NWW = source->
NWW;
456 target->
NEE = source->
NEE;
457 target->
NC = source->
NC;
458 target->
SC = source->
SC;
459 target->
SWW = source->
SWW;
460 target->
SEE = source->
SEE;
514 double NEZ,
double WZ,
515 double CZ,
double EZ,
516 double SWZ,
double SZ,
522 "N_create_gradient_neighbours_z: create N_gradient_neighbours_z");
550 G_debug(6,
"N_copy_gradient_neighbours_z: copy N_gradient_neighbours_z");
552 if (!source || !target)
555 target->
NWZ = source->
NWZ;
556 target->
NZ = source->
NZ;
557 target->
NEZ = source->
NEZ;
558 target->
WZ = source->
WZ;
559 target->
CZ = source->
CZ;
560 target->
EZ = source->
EZ;
561 target->
SWZ = source->
SWZ;
562 target->
SZ = source->
SZ;
563 target->
SEZ = source->
SEZ;
625 "N_create_gradient_neighbours_2d: create N_gradient_neighbours_2d");
655 G_debug(5,
"N_copy_gradient_neighbours_2d: copy N_gradient_neighbours_2d");
657 if (!source || !target)
693 double NWN, NEN, WC, EC, SWS, SES;
694 double NWW, NEE, NC, SC, SWW, SEE;
717 "N_get_gradient_neighbours_2d: calculate N_gradient_neighbours_x "
718 "NWN %g NEN %g WC %g EC %g SWS %g SES %g",
719 NWN, NEN, WC, EC, SWS, SES);
722 "N_get_gradient_neighbours_2d: calculate N_gradient_neighbours_y "
723 "NWW %g NEE %g NC %g SC %g SWW %g SEE %g",
724 NWW, NEE, NC, SC, SWW, SEE);
816 "N_create_gradient_neighbours_3d: create N_gradient_neighbours_3d");
857 G_debug(5,
"N_copy_gradient_neighbours_3d: copy N_gradient_neighbours_3d");
859 if (!source || !target)
901 "N_alloc_gradient_field_2d: allocate a N_gradient_field_2d struct");
944 G_debug(3,
"N_copy_gradient_field_2d: copy N_gradient_field_2d");
946 if (!source || !target)
963 fprintf(stdout,
"N_gradient_field_2d \n");
964 fprintf(stdout,
"Cols %i\n", field->
cols);
965 fprintf(stdout,
"Rows: %i\n", field->
rows);
966 fprintf(stdout,
"X array pointer: %p\n", (
void *)field->
x_array);
967 fprintf(stdout,
"Y array pointer: %p\n", (
void *)field->
y_array);
968 fprintf(stdout,
"Min %g\n", field->
min);
969 fprintf(stdout,
"Max %g\n", field->
max);
970 fprintf(stdout,
"Sum %g\n", field->
sum);
971 fprintf(stdout,
"Mean %g\n", field->
mean);
972 fprintf(stdout,
"Nonull %i\n", field->
nonull);
973 fprintf(stdout,
"X array info \n");
975 fprintf(stdout,
"Y array info \n");
998 "N_alloc_gradient_field_3d: allocate a N_gradient_field_3d struct");
1044 G_debug(3,
"N_copy_gradient_field_3d: copy N_gradient_field_3d");
1046 if (!source || !target)
1065 fprintf(stdout,
"N_gradient_field_3d \n");
1066 fprintf(stdout,
"Cols %i\n", field->
cols);
1067 fprintf(stdout,
"Rows: %i\n", field->
rows);
1068 fprintf(stdout,
"Depths %i\n", field->
depths);
1069 fprintf(stdout,
"X array pointer: %p\n", (
void *)field->
x_array);
1070 fprintf(stdout,
"Y array pointer: %p\n", (
void *)field->
y_array);
1071 fprintf(stdout,
"Z array pointer: %p\n", (
void *)field->
z_array);
1072 fprintf(stdout,
"Min %g\n", field->
min);
1073 fprintf(stdout,
"Max %g\n", field->
max);
1074 fprintf(stdout,
"Sum %g\n", field->
sum);
1075 fprintf(stdout,
"Mean %g\n", field->
mean);
1076 fprintf(stdout,
"Nonull %i\n", field->
nonull);
1077 fprintf(stdout,
"X array info \n");
1079 fprintf(stdout,
"Y array info \n");
1081 fprintf(stdout,
"Z array info \n");
void G_free(void *)
Free allocated memory.
int G_debug(int, const char *,...) __attribute__((format(printf
void N_print_array_3d_info(N_array_3d *data)
Write the info of the array to stdout.
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
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.
void N_print_array_2d_info(N_array_2d *data)
This function writes the data info of the array data to stdout.
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_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d 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_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.
int N_copy_gradient_neighbours_2d(N_gradient_neighbours_2d *source, N_gradient_neighbours_2d *target)
copy a N_gradient_neighbours_2d structure
N_gradient_neighbours_y * N_alloc_gradient_neighbours_y(void)
Allocate a N_gradient_neighbours_y structure.
N_gradient_neighbours_3d * N_alloc_gradient_neighbours_3d(void)
Allocate a N_gradient_neighbours_3d structure.
int N_copy_gradient_3d(N_gradient_3d *source, N_gradient_3d *target)
copy a N_gradient_3d structure
N_gradient_2d * N_alloc_gradient_2d(void)
Allocate a N_gradient_2d structure.
N_gradient_3d * N_get_gradient_3d(N_gradient_field_3d *field, N_gradient_3d *gradient, int col, int row, int depth)
Return a N_gradient_3d structure calculated from the input gradient field at position [depth][row][co...
N_gradient_2d * N_create_gradient_2d(double NC, double SC, double WC, double EC)
allocate and initialize a N_gradient_2d structure
N_gradient_neighbours_2d * N_alloc_gradient_neighbours_2d(void)
Allocate a N_gradient_neighbours_2d structure.
void N_free_gradient_field_3d(N_gradient_field_3d *field)
Free's a N_gradient_neighbours_3d structure.
N_gradient_neighbours_2d * N_create_gradient_neighbours_2d(N_gradient_neighbours_x *x, N_gradient_neighbours_y *y)
Allocate and initialize a N_gradient_neighbours_2d structure.
int N_copy_gradient_field_3d(N_gradient_field_3d *source, N_gradient_field_3d *target)
Copy N_gradient_field_3d structure from source to target.
int N_copy_gradient_neighbours_x(N_gradient_neighbours_x *source, N_gradient_neighbours_x *target)
copy a N_gradient_neighbours_x structure
void N_free_gradient_neighbours_2d(N_gradient_neighbours_2d *grad)
Free's a N_gradient_neighbours_2d structure.
void N_print_gradient_field_2d_info(N_gradient_field_2d *field)
Print gradient field information to stdout.
N_gradient_neighbours_x * N_alloc_gradient_neighbours_x(void)
Allocate a N_gradient_neighbours_x structure.
N_gradient_neighbours_y * N_create_gradient_neighbours_y(double NWW, double NEE, double NC, double SC, double SWW, double SEE)
Allocate and initialize a N_gradient_neighbours_y structure.
void N_print_gradient_field_3d_info(N_gradient_field_3d *field)
Print gradient field information to stdout.
void N_free_gradient_neighbours_z(N_gradient_neighbours_z *grad)
Free's a N_gradient_neighbours_z structure.
int N_copy_gradient_neighbours_z(N_gradient_neighbours_z *source, N_gradient_neighbours_z *target)
copy a N_gradient_neighbours_z structure
int N_copy_gradient_neighbours_3d(N_gradient_neighbours_3d *source, N_gradient_neighbours_3d *target)
copy a N_gradient_neighbours_3d structure
N_gradient_field_2d * N_alloc_gradient_field_2d(int cols, int rows)
Allocate a N_gradient_field_2d.
N_gradient_neighbours_2d * N_get_gradient_neighbours_2d(N_gradient_field_2d *field, N_gradient_neighbours_2d *gradient, int col, int row)
Return a N_gradient_neighbours_2d structure calculated from the input gradient field at position [row...
N_gradient_3d * N_create_gradient_3d(double NC, double SC, double WC, double EC, double TC, double BC)
allocate and initialize a N_gradient_3d structure
N_gradient_3d * N_alloc_gradient_3d(void)
Allocate a N_gradient_3d structure.
N_gradient_2d * N_get_gradient_2d(N_gradient_field_2d *field, N_gradient_2d *gradient, int col, int row)
Return a N_gradient_2d structure calculated from the input gradient field at position [row][col].
void N_free_gradient_2d(N_gradient_2d *grad)
Free's a N_gradient_2d structure.
int N_copy_gradient_neighbours_y(N_gradient_neighbours_y *source, N_gradient_neighbours_y *target)
copy a N_gradient_neighbours_y structure
N_gradient_neighbours_z * N_alloc_gradient_neighbours_z(void)
Allocate a N_gradient_neighbours_z structure.
int N_copy_gradient_2d(N_gradient_2d *source, N_gradient_2d *target)
copy a N_gradient_2d structure
void N_free_gradient_3d(N_gradient_3d *grad)
Free's a N_gradient_3d structure.
void N_free_gradient_neighbours_y(N_gradient_neighbours_y *grad)
Free's a N_gradient_neighbours_y structure.
N_gradient_neighbours_x * N_create_gradient_neighbours_x(double NWN, double NEN, double WC, double EC, double SWS, double SES)
Allocate and initialize a N_gradient_neighbours_x structure.
N_gradient_field_3d * N_alloc_gradient_field_3d(int cols, int rows, int depths)
Allocate a N_gradient_field_3d.
void N_free_gradient_field_2d(N_gradient_field_2d *field)
Free's a N_gradient_neighbours_2d structure.
N_gradient_neighbours_3d * N_create_gradient_neighbours_3d(N_gradient_neighbours_x *xt, N_gradient_neighbours_x *xc, N_gradient_neighbours_x *xb, N_gradient_neighbours_y *yt, N_gradient_neighbours_y *yc, N_gradient_neighbours_y *yb, N_gradient_neighbours_z *zt, N_gradient_neighbours_z *zb)
Allocate and initialize a N_gradient_neighbours_3d structure.
void N_free_gradient_neighbours_x(N_gradient_neighbours_x *grad)
Free's a N_gradient_neighbours_x structure.
N_gradient_neighbours_z * N_create_gradient_neighbours_z(double NWZ, double NZ, double NEZ, double WZ, double CZ, double EZ, double SWZ, double SZ, double SEZ)
Allocate and initialize a N_gradient_neighbours_z structure.
int N_copy_gradient_field_2d(N_gradient_field_2d *source, N_gradient_field_2d *target)
Copy N_gradient_field_2d structure from source to target.
void N_free_gradient_neighbours_3d(N_gradient_neighbours_3d *grad)
Free's a N_gradient_neighbours_3d structure.
Gradient between the cells in X and Y direction.
Gradient between the cells in X, Y and Z direction.
Gradient between the cell neighbours in X and Y direction.
N_gradient_neighbours_y * y
N_gradient_neighbours_x * x
Gradient between the cell neighbours in X, Y and Z direction.
N_gradient_neighbours_y * yb
N_gradient_neighbours_z * zb
N_gradient_neighbours_y * yt
N_gradient_neighbours_z * zt
N_gradient_neighbours_y * yc
N_gradient_neighbours_x * xb
N_gradient_neighbours_x * xt
N_gradient_neighbours_x * xc
Gradient between the cell neighbours in X direction.
Gradient between the cell neighbours in Y direction.
Gradient between the cell neighbours in Z direction.