19 #include "grass/N_pde.h"
20 #include "grass/glocale.h"
73 if (rows < 1 || cols < 1)
74 G_fatal_error(
"N_alloc_array_2d: cols and rows should be > 0");
76 if (type != CELL_TYPE && type != FCELL_TYPE && type != DCELL_TYPE)
78 (
"N_alloc_array_2d: Wrong data type, should be CELL_TYPE, FCELL_TYPE or DCELL_TYPE");
92 if (data->
type == CELL_TYPE) {
97 "N_alloc_array_2d: CELL array allocated rows_intern %i cols_intern %i offset %i",
100 else if (data->
type == FCELL_TYPE) {
105 "N_alloc_array_2d: FCELL array allocated rows_intern %i cols_intern %i offset %i",
109 else if (data->
type == DCELL_TYPE) {
114 "N_alloc_array_2d: DCELL array allocated rows_intern %i cols_intern %i offset %i",
131 G_debug(3,
"N_free_array_2d: free N_array_2d");
234 "N_is_array_2d_value_null: null value is of type CELL at pos [%i][%i]",
243 "N_is_array_2d_value_null: null value is of type FCELL at pos [%i][%i]",
252 "N_is_array_2d_value_null: null value is of type DCELL at pos [%i][%i]",
263 "N_is_array_2d_value_null: null value is of type CELL at pos [%i][%i]",
270 data->
offset]), CELL_TYPE);
274 "N_is_array_2d_value_null: null value is of type FCELL at pos [%i][%i]",
281 data->
offset]), FCELL_TYPE);
285 "N_is_array_2d_value_null: null value is of type DCELL at pos [%i][%i]",
292 data->
offset]), DCELL_TYPE);
317 switch (data->
type) {
323 return (CELL) fvalue;
326 return (CELL) dvalue;
349 switch (data->
type) {
352 return (FCELL) value;
355 return (FCELL) fvalue;
358 return (FCELL) dvalue;
381 switch (data->
type) {
384 return (DCELL) value;
387 return (DCELL) fvalue;
390 return (DCELL) dvalue;
411 G_debug(6,
"N_put_array_2d_value: put value to array");
430 data->
offset] = *((CELL *) value);
434 data->
offset] = *((FCELL *) value);
438 data->
offset] = *((DCELL *) value);
459 "N_put_array_2d_value_null: put null value to array pos [%i][%i]",
526 switch (data->
type) {
528 fvalue = (FCELL) value;
532 dvalue = (DCELL) value;
556 switch (data->
type) {
558 cvalue = (CELL) value;
562 dvalue = (DCELL) value;
586 switch (data->
type) {
588 cvalue = (CELL) value;
592 fvalue = (FCELL) value;
611 fprintf(stdout,
"N_array_2d \n");
612 fprintf(stdout,
"Cols %i\n", data->
cols);
613 fprintf(stdout,
"Rows: %i\n", data->
rows);
614 fprintf(stdout,
"Array type: %i\n", data->
type);
615 fprintf(stdout,
"Offset: %i\n", data->
offset);
616 fprintf(stdout,
"Internal cols: %i\n", data->
cols_intern);
617 fprintf(stdout,
"Internal rows: %i\n", data->
rows_intern);
618 fprintf(stdout,
"CELL array pointer: %p\n", data->
cell_array);
619 fprintf(stdout,
"FCELL array pointer: %p\n", data->
fcell_array);
620 fprintf(stdout,
"DCELL array pointer: %p\n", data->
dcell_array);
640 for (j = 0 - data->
offset; j < data->rows + data->
offset; j++) {
642 if (data->
type == CELL_TYPE)
644 else if (data->
type == FCELL_TYPE)
646 else if (data->
type == DCELL_TYPE)
649 fprintf(stdout,
"\n");
651 fprintf(stdout,
"\n");
728 if (rows < 1 || cols < 1 || depths < 1)
730 (
"N_alloc_array_3d: depths, cols and rows should be > 0");
732 if (type != DCELL_TYPE && type != FCELL_TYPE)
734 (
"N_alloc_array_3d: Wrong data type, should be FCELL_TYPE or DCELL_TYPE");
749 if (data->
type == FCELL_TYPE) {
754 "N_alloc_array_3d: float array allocated rows_intern %i cols_intern %i depths_intern %i offset %i",
758 else if (data->
type == DCELL_TYPE) {
763 "N_alloc_array_3d: double array allocated rows_intern %i cols_intern %i depths_intern %i offset %i",
781 G_debug(3,
"N_free_array_3d: free N_array_3d");
884 "N_is_array_3d_value_null: null value is of type DCELL_TYPE at pos [%i][%i][%i]",
896 "N_is_array_3d_value_null: null value is of type DCELL_TYPE at pos [%i][%i][%i]",
910 "N_is_array_3d_value_null: null value is of type DCELL_TYPE at pos [%i][%i][%i]",
926 "N_is_array_3d_value_null: null value is of type DCELL_TYPE at pos [%i][%i][%i]",
963 switch (data->
type) {
966 return (
float)fvalue;
969 return (
float)dvalue;
992 switch (data->
type) {
996 return (
double)fvalue;
999 return (
double)dvalue;
1022 G_debug(6,
"N_put_array_3d_value: put value to array at pos [%i][%i][%i]",
1030 = *((
float *)value);
1037 = *((
double *)value);
1077 "N_put_array_3d_value_null: put null value to array at pos [%i][%i][%i]",
1104 fcell_array[(depth +
1118 dcell_array[(depth +
1150 if (data->
type == DCELL_TYPE) {
1151 dval = (double)value;
1177 if (data->
type == FCELL_TYPE) {
1178 fval = (double)value;
1197 fprintf(stdout,
"N_array_3d \n");
1198 fprintf(stdout,
"Cols %i\n", data->
cols);
1199 fprintf(stdout,
"Rows: %i\n", data->
rows);
1200 fprintf(stdout,
"Depths: %i\n", data->
depths);
1201 fprintf(stdout,
"Array type: %i\n", data->
type);
1202 fprintf(stdout,
"Offset: %i\n", data->
offset);
1203 fprintf(stdout,
"Internal cols: %i\n", data->
cols_intern);
1204 fprintf(stdout,
"Internal rows: %i\n", data->
rows_intern);
1205 fprintf(stdout,
"Internal depths: %i\n", data->
depths_intern);
1206 fprintf(stdout,
"FCELL array pointer: %p\n", data->
fcell_array);
1207 fprintf(stdout,
"DCELL array pointer: %p\n", data->
dcell_array);
1226 for (k = 0; k < data->
depths; k++) {
1227 for (j = 0; j < data->
rows; j++) {
1228 for (i = 0; i < data->
cols; i++) {
1229 if (data->
type == FCELL_TYPE)
1231 else if (data->
type == DCELL_TYPE)