GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-19539757c0
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * MODULE: Grass PDE Numerical Library
4  * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
5  * soerengebbert <at> gmx <dot> de
6  *
7  * PURPOSE: gradient management functions
8  * part of the gpde library
9  *
10  * COPYRIGHT: (C) 2000 by the GRASS Development Team
11  *
12  * This program is free software under the GNU General Public
13  * License (>=v2). Read the file COPYING that comes with GRASS
14  * for details.
15  *
16  *****************************************************************************/
17
18 #include <grass/N_pde.h>
19
20 /*!
21  * \brief Allocate a N_gradient_2d structure
22  *
23  * \return N_gradient_2d *
24  *
25  * */
27 {
29
31
33 }
34
35 /*!
36  * \brief Free's a N_gradient_2d structure
37  *
38  * \return void
39  *
40  * */
42 {
44  grad = NULL;
45
46  return;
47 }
48
49 /*!
50  * \brief allocate and initialize a N_gradient_2d structure
51  *
52  * \param NC double - the gradient between northern and center cell
53  * \param SC double - the gradient between southern and center cell
54  * \param WC double - the gradient between western and center cell
55  * \param EC double - the gradient between eastern and center cell
56  * \return N_gradient_2d *
57  *
58  * */
59 N_gradient_2d *N_create_gradient_2d(double NC, double SC, double WC, double EC)
60 {
62
64
66
67  grad->NC = NC;
68  grad->SC = SC;
69  grad->WC = WC;
70  grad->EC = EC;
71
73 }
74
75 /*!
76  * \brief copy a N_gradient_2d structure
77  *
78  * \param source - the source N_gradient_2d struct
79  * \param target - the target N_gradient_2d struct
80  * \return int - 1 success, 0 failure while copying
81  *
82  * */
84 {
86
87  if (!source || !target)
88  return 0;
89
90  target->NC = source->NC;
91  target->SC = source->SC;
92  target->WC = source->WC;
93  target->EC = source->EC;
94
95  return 1;
96 }
97
98 /*!
99  * \brief Return a N_gradient_2d structure calculated from the input gradient
100  * field at position [row][col]
101  *
102  * This function returns the gradient of a cell at position [row][col] from the
103  * input gradient field. Returned is a new structure of type N_gradient_2d.
104  *
105  * \param field N_gradient_field_2d * - A two dimensional gradient field
106  * \param gradient N_gradient_2d * - the gradient structure which should be
107  * filled with data, if a NULL pointer is given, a new structure will be created
108  * \param col int
109  * \param row int
110  * \return N_gradient_2d * - the new or filled gradient structure
111  *
112  *
113  * */
115  N_gradient_2d *gradient, int col, int row)
116 {
117  double NC = 0, SC = 0, WC = 0, EC = 0;
119
120  NC = N_get_array_2d_d_value(field->y_array, col, row);
121  SC = N_get_array_2d_d_value(field->y_array, col, row + 1);
122  WC = N_get_array_2d_d_value(field->x_array, col, row);
123  EC = N_get_array_2d_d_value(field->x_array, col + 1, row);
124
125  G_debug(
126  5, "N_get_gradient_2d: calculate N_gradient_2d NC %g SC %g WC %g EC %g",
127  NC, SC, WC, EC);
128
129  /*if gradient is a NULL pointer, create a new one */
130  if (!grad) {
131  grad = N_create_gradient_2d(NC, SC, WC, EC);
132  }
133  else {
134  grad->NC = NC;
135  grad->SC = SC;
136  grad->WC = WC;
137  grad->EC = EC;
138  }
139
141 }
142
143 /*!
144  * \brief Allocate a N_gradient_3d structure
145  *
146  * \return N_gradient_3d *
147  *
148  * */
150 {
152
154
156 }
157
158 /*!
159  * \brief Free's a N_gradient_3d structure
160  *
161  * \return void
162  *
163  * */
165 {
167  grad = NULL;
168
169  return;
170 }
171
172 /*!
173  * \brief allocate and initialize a N_gradient_3d structure
174  *
175  * \param NC double - the gradient between northern and center cell
176  * \param SC double - the gradient between southern and center cell
177  * \param WC double - the gradient between western and center cell
178  * \param EC double - the gradient between eastern and center cell
179  * \param TC double - the gradient between top and center cell
180  * \param BC double - the gradient between bottom and center cell
181  * \return N_gradient_3d *
182  *
183  * */
184 N_gradient_3d *N_create_gradient_3d(double NC, double SC, double WC, double EC,
185  double TC, double BC)
186 {
188
190
192
193  grad->NC = NC;
194  grad->SC = SC;
195  grad->WC = WC;
196  grad->EC = EC;
197  grad->TC = TC;
198  grad->BC = BC;
199
201 }
202
203 /*!
204  * \brief copy a N_gradient_3d structure
205  *
206  * \param source - the source N_gradient_3d struct
207  * \param target - the target N_gradient_3d struct
208  * \return int - 1 success, 0 failure while copying
209  *
210  * */
212 {
214
215  if (!source || !target)
216  return 0;
217
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;
224
225  return 1;
226 }
227
228 /*!
229  * \brief Return a N_gradient_3d structure calculated from the input gradient
230  * field at position [depth][row][col]
231  *
232  * This function returns the gradient of a 3d cell at position
233  * [depth][row][col] from the input gradient field. Returned is a new structure
234  * of type N_gradient_3d.
235  *
236  * \param field N_gradient_field_3d * - A three dimensional gradient field
237  * \param gradient N_gradient_3d * - an existing gradient structure or a NULL
238  * pointer, if a NULL pointer is providet a new structure will be returned
239  * \param col int
240  * \param row int
241  * \param depth int
242  * \return N_gradient_3d *
243  *
244  *
245  * */
247  N_gradient_3d *gradient, int col, int row,
248  int depth)
249 {
250  double NC, SC, WC, EC, TC, BC;
252
253  NC = N_get_array_3d_d_value(field->y_array, col, row, depth);
254  SC = N_get_array_3d_d_value(field->y_array, col, row + 1, depth);
255  WC = N_get_array_3d_d_value(field->x_array, col, row, depth);
256  EC = N_get_array_3d_d_value(field->x_array, col + 1, row, depth);
257  BC = N_get_array_3d_d_value(field->z_array, col, row, depth);
258  TC = N_get_array_3d_d_value(field->z_array, col, row, depth + 1);
259
260  G_debug(6,
261  "N_get_gradient_3d: calculate N_gradient_3d NC %g SC %g WC %g EC "
262  "%g TC %g BC %g",
263  NC, SC, WC, EC, TC, BC);
264
265  /*if gradient is a NULL pointer, create a new one */
266  if (!grad) {
267  grad = N_create_gradient_3d(NC, SC, WC, EC, TC, BC);
268  }
269  else {
270  grad->NC = NC;
271  grad->SC = SC;
272  grad->WC = WC;
273  grad->EC = EC;
274  grad->BC = BC;
275  grad->TC = TC;
276  }
277
279 }
280
281 /*!
282  * \brief Allocate a N_gradient_neighbours_x structure
283  *
284  * This structure contains all neighbour gradients in x direction of one cell
285  *
286  * \return N_gradient_neighbours_x *
287  *
288  * */
290 {
292
295
297 }
298
299 /*!
300  * \brief Free's a N_gradient_neighbours_x structure
301  *
302  * \return void
303  *
304  * */
306 {
308  grad = NULL;
309
310  return;
311 }
312
313 /*!
314  * \brief Allocate and initialize a N_gradient_neighbours_x structure
315  *
316  * \param NWN double - the gradient between north-west and northern cell
317  * \param NEN double - the gradient between north-east and northern cell
318  * \param WC double - the gradient between western and center cell
319  * \param EC double - the gradient between eastern and center cell
320  * \param SWS double - the gradient between south-west and southern cell
321  * \param SES double - the gradient between south-east and southern cell
322  * \return N_gradient_neighbours_x *
323
324  *
325  * */
327  double WC, double EC,
328  double SWS, double SES)
329 {
331
332  G_debug(6,
334
336
337  grad->NWN = NWN;
338  grad->NEN = NEN;
339  grad->WC = WC;
340  grad->EC = EC;
341  grad->SWS = SWS;
342  grad->SES = SES;
343
345 }
346
347 /*!
348  * \brief copy a N_gradient_neighbours_x structure
349  *
350  * \param source - the source N_gradient_neighbours_x struct
351  * \param target - the target N_gradient_neighbours_x struct
352  * \return int - 1 success, 0 failure while copying
353  *
354  * */
357 {
359
360  if (!source || !target)
361  return 0;
362
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;
369
370  return 1;
371 }
372
373 /*!
374  * \brief Allocate a N_gradient_neighbours_y structure
375  *
376  * This structure contains all neighbour gradients in y direction of one cell
377  *
378  * \return N_gradient_neighbours_y *
379  *
380  * */
382 {
384
387
389 }
390
391 /*!
392  * \brief Free's a N_gradient_neighbours_y structure
393  *
394  * \return void
395  *
396  * */
398 {
400  grad = NULL;
401
402  return;
403 }
404
405 /*!
406  * \brief Allocate and initialize a N_gradient_neighbours_y structure
407  *
408  * \param NWW double - the gradient between north-west and western cell
409  * \param NEE double - the gradient between north-east and eastern cell
410  * \param NC double - the gradient between northern and center cell
411  * \param SC double - the gradient between southern and center cell
412  * \param SWW double - the gradient between south-west and western cell
413  * \param SEE double - the gradient between south-east and eastern cell
414  * \return N_gradient_neighbours_y *
415
416  *
417  * */
419  double NC, double SC,
420  double SWW, double SEE)
421 {
423
424  G_debug(6,
426
428
429  grad->NWW = NWW;
430  grad->NEE = NEE;
431  grad->NC = NC;
432  grad->SC = SC;
433  grad->SWW = SWW;
434  grad->SEE = SEE;
435
437 }
438
439 /*!
440  * \brief copy a N_gradient_neighbours_y structure
441  *
442  * \param source - the source N_gradient_neighbours_y struct
443  * \param target - the target N_gradient_neighbours_y struct
444  * \return int - 1 success, 0 failure while copying
445  *
446  * */
449 {
451
452  if (!source || !target)
453  return 0;
454
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;
461
462  return 1;
463 }
464
465 /*!
466  * \brief Allocate a N_gradient_neighbours_z structure
467  *
468  * This structure contains all neighbour gradients in z direction of one cell
469  *
470  * \return N_gradient_neighbours_z *
471  *
472  * */
474 {
476
479
481 }
482
483 /*!
484  * \brief Free's a N_gradient_neighbours_z structure
485  *
486  * \return void
487  *
488  * */
490 {
492  grad = NULL;
493
494  return;
495 }
496
497 /*!
498  * \brief Allocate and initialize a N_gradient_neighbours_z structure
499  *
500  * \param NWZ double - the gradient between upper and lower north-western cells
501  * \param NZ double - the gradient between upper and lower northern cells
502  * \param NEZ double - the gradient between upper and lower north-eastern cells
503  * \param WZ double - the gradient between upper and lower western cells
504  * \param CZ double - the gradient between upper and lower center cells
505  * \param EZ double - the gradient between upper and lower eastern cells
506  * \param SWZ double - the gradient between upper and lower south-western cells
507  * \param SZ double - the gradient between upper and lower southern cells
508  * \param SEZ double - the gradient between upper and lower south-eastern cells
509  * \return N_gradient_neighbours_z *
510
511  *
512  * */
514  double NEZ, double WZ,
515  double CZ, double EZ,
516  double SWZ, double SZ,
517  double SEZ)
518 {
520
521  G_debug(6,
523
525
526  grad->NWZ = NWZ;
527  grad->NZ = NZ;
528  grad->NEZ = NEZ;
529  grad->WZ = WZ;
530  grad->CZ = CZ;
531  grad->EZ = EZ;
532  grad->SWZ = SWZ;
533  grad->SZ = SZ;
534  grad->SEZ = SEZ;
535
537 }
538
539 /*!
540  * \brief copy a N_gradient_neighbours_z structure
541  *
542  * \param source - the source N_gradient_neighbours_z struct
543  * \param target - the target N_gradient_neighbours_z struct
544  * \return int - 1 success, 0 failure while copying
545  *
546  * */
549 {
551
552  if (!source || !target)
553  return 0;
554
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;
564
565  return 1;
566 }
567
568 /*!
569  * \brief Allocate a N_gradient_neighbours_2d structure
570  *
571  * This structure contains all neighbour gradients in all directions of one cell
572  * in a 2d raster layer
573  *
574  * \return N_gradient_neighbours_2d *
575  *
576  * */
578 {
580
583
586
588 }
589
590 /*!
591  * \brief Free's a N_gradient_neighbours_2d structure
592  *
593  * \return void
594  *
595  * */
597 {
598
601
603  grad = NULL;
604
605  return;
606 }
607
608 /*!
609  * \brief Allocate and initialize a N_gradient_neighbours_2d structure
610  *
611  * The parameter N_gradient_neighbours x and y are copied into the new allocated
612  * structure and can be deleted after the initializing
613  *
614  * \return N_gradient_neighbours_2d * -- if failure NULL is returned
615  *
616  * */
620 {
622  int fail = 0;
623
624  G_debug(5,
626
628
630  fail++;
632  fail++;
633
634  if (fail > 0) {
636  grad = NULL;
637  }
638
640 }
641
642 /*!
643  * \brief copy a N_gradient_neighbours_2d structure
644  *
645  * \param source - the source N_gradient_neighbours_2d struct
646  * \param target - the target N_gradient_neighbours_2d struct
647  * \return int - 1 success, 0 failure while copying
648  *
649  * */
652 {
653  int fail = 0;
654
656
657  if (!source || !target)
658  return 0;
659
660  if (!(N_copy_gradient_neighbours_x(source->x, target->x)))
661  fail++;
662  if (!(N_copy_gradient_neighbours_y(source->y, target->y)))
663  fail++;
664
665  if (fail > 0) {
666  return 0;
667  }
668
669  return 1;
670 }
671
672 /*!
673  * \brief Return a N_gradient_neighbours_2d structure calculated from the input
674  * gradient field at position [row][col]
675  *
676  * This function returns the gradient neighbours in x and y dierection
677  * of a cell at position [row][col] from the input gradient field.
678  * Returned is a pointer to a structure of type N_gradient_neighbours_2d.
679  *
680  * \param field N_gradient_field_2d * - A two dimensional gradient field
681  * \param gradient N_gradient_neighbours_2d * - the gradient structure which
682  * should be filled with data, if a NULL pointer is given, a new structure will
683  * be created \param col int \param row int \return N_gradient_neighbours_2d * -
684  * the new or filled gradient structure
685  *
686  *
687  * */
691  int row)
692 {
693  double NWN, NEN, WC, EC, SWS, SES;
694  double NWW, NEE, NC, SC, SWW, SEE;
698
699  NWN = N_get_array_2d_d_value(field->x_array, col, row - 1);
700  NEN = N_get_array_2d_d_value(field->x_array, col + 1, row - 1);
701  WC = N_get_array_2d_d_value(field->x_array, col, row);
702  EC = N_get_array_2d_d_value(field->x_array, col + 1, row);
703  SWS = N_get_array_2d_d_value(field->x_array, col, row + 1);
704  SES = N_get_array_2d_d_value(field->x_array, col + 1, row + 1);
705
706  NWW = N_get_array_2d_d_value(field->y_array, col - 1, row);
707  NEE = N_get_array_2d_d_value(field->y_array, col + 1, row);
708  NC = N_get_array_2d_d_value(field->y_array, col, row);
709  SC = N_get_array_2d_d_value(field->y_array, col, row + 1);
710  SWW = N_get_array_2d_d_value(field->y_array, col - 1, row + 1);
711  SEE = N_get_array_2d_d_value(field->y_array, col + 1, row + 1);
712
713  grad_x = N_create_gradient_neighbours_x(NWN, NEN, WC, EC, SWS, SES);
714  grad_y = N_create_gradient_neighbours_y(NWW, NEE, NC, SC, SWW, SEE);
715
716  G_debug(5,
718  "NWN %g NEN %g WC %g EC %g SWS %g SES %g",
719  NWN, NEN, WC, EC, SWS, SES);
720
721  G_debug(5,
723  "NWW %g NEE %g NC %g SC %g SWW %g SEE %g",
724  NWW, NEE, NC, SC, SWW, SEE);
725
726  /*if gradient is a NULL pointer, create a new one */
727  if (!gradient) {
730  }
731  else {
735  }
736
739
741 }
742
743 /*!
744  * \brief Allocate a N_gradient_neighbours_3d structure
745  *
746  * This structure contains all neighbour gradients in all directions of one cell
747  * in a 3d raster layer
748  *
749  * \return N_gradient_neighbours_3d *
750  *
751  * */
753 {
755
758
767
769 }
770
771 /*!
772  * \brief Free's a N_gradient_neighbours_3d structure
773  *
774  * \return void
775  *
776  * */
778 {
779
788
790  grad = NULL;
791
792  return;
793 }
794
795 /*!
796  * \brief Allocate and initialize a N_gradient_neighbours_3d structure
797  *
798  * The parameter N_gradient_neighbours x(tcb) and y(tcb) and z(tb) are copied
799  into the new allocated structure
800  * and can be deleted after the initializing
801  *
802  * \return N_gradient_neighbours_3d * -- if failure NULL is returned
803
804  *
805  * */
811 {
813  int fail = 0;
814
815  G_debug(5,
817
819
821  fail++;
823  fail++;
825  fail++;
827  fail++;
829  fail++;
831  fail++;
833  fail++;
835  fail++;
836
837  if (fail > 0) {
838  return NULL;
839  }
840
842 }
843
844 /*!
845  * \brief copy a N_gradient_neighbours_3d structure
846  *
847  * \param source - the source N_gradient_neighbours_3d struct
848  * \param target - the target N_gradient_neighbours_3d struct
849  * \return int - 1 success, 0 failure while copying
850  *
851  * */
854 {
855  int fail = 0;
856
858
859  if (!source || !target)
860  return 0;
861
862  if (!(N_copy_gradient_neighbours_x(source->xt, target->xt)))
863  fail++;
864  if (!(N_copy_gradient_neighbours_x(source->xc, target->xc)))
865  fail++;
866  if (!(N_copy_gradient_neighbours_x(source->xb, target->xb)))
867  fail++;
868  if (!(N_copy_gradient_neighbours_y(source->yt, target->yt)))
869  fail++;
870  if (!(N_copy_gradient_neighbours_y(source->yc, target->yc)))
871  fail++;
872  if (!(N_copy_gradient_neighbours_y(source->yb, target->yb)))
873  fail++;
874  if (!(N_copy_gradient_neighbours_z(source->zt, target->zt)))
875  fail++;
876  if (!(N_copy_gradient_neighbours_z(source->zb, target->zb)))
877  fail++;
878
879  if (fail > 0) {
880  return 0;
881  }
882
883  return 1;
884 }
885
886 /*!
887  * \brief Allocate a N_gradient_field_2d
888  *
889  * The field arrays are of type DCELL.
890  *
891  * \param rows - number of rows of the 2d array from which the gradient should
892  * be calculated \param cols - number of cols of the 2d array from which the
893  * gradient should be calculated \return N_gradient_field_2d *
894  *
895  * */
897 {
899
900  G_debug(5,
902
904
905  field->x_array = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
906  field->y_array = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
907
908  field->cols = cols;
909  field->rows = rows;
910
911  return field;
912 }
913
914 /*!
915  * \brief Free's a N_gradient_neighbours_2d structure
916  *
917  * \return void
918  *
919  * */
921 {
922
923  N_free_array_2d(field->x_array);
924  N_free_array_2d(field->y_array);
925
926  G_free(field);
927
928  field = NULL;
929
930  return;
931 }
932
933 /*!
934  * \brief Copy N_gradient_field_2d structure from source to target
935  *
936  * \param source - the source N_gradient_field_2d struct
937  * \param target - the target N_gradient_field_2d struct
938  * \return int - 1 success, 0 failure while copying
939  *
940  * */
943 {
945
946  if (!source || !target)
947  return 0;
948
949  N_copy_array_2d(source->x_array, target->x_array);
950  N_copy_array_2d(source->y_array, target->y_array);
951
952  return 1;
953 }
954
955 /*! \brief Print gradient field information to stdout
956  *
957  * \param field N_gradient_2d_field *
958  * \return void
959  *
960  * */
962 {
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");
977
978  return;
979 }
980
981 /*!
982  * \brief Allocate a N_gradient_field_3d
983  *
984  * The field arrays are always of type DCELL_TYPE.
985  *
986  * \param cols - number of cols of the 3d array from which the gradient should
987  * be calculated \param rows - number of rows of the 3d array from which the
988  * gradient should be calculated \param depths - number of depths of the 3d
989  * array from which the gradient should be calculated \return
990  * N_gradient_field_3d *
991  *
992  * */
993 N_gradient_field_3d *N_alloc_gradient_field_3d(int cols, int rows, int depths)
994 {
996
997  G_debug(5,
999
1001
1002  field->x_array = N_alloc_array_3d(cols, rows, depths, 1, DCELL_TYPE);
1003  field->y_array = N_alloc_array_3d(cols, rows, depths, 1, DCELL_TYPE);
1004  field->z_array = N_alloc_array_3d(cols, rows, depths, 1, DCELL_TYPE);
1005
1006  field->cols = cols;
1007  field->rows = rows;
1008  field->depths = depths;
1009
1010  return field;
1011 }
1012
1013 /*!
1014  * \brief Free's a N_gradient_neighbours_3d structure
1015  *
1016  * \return void
1017  *
1018  * */
1020 {
1021
1022  N_free_array_3d(field->x_array);
1023  N_free_array_3d(field->y_array);
1024  N_free_array_3d(field->z_array);
1025
1026  G_free(field);
1027
1028  field = NULL;
1029
1030  return;
1031 }
1032
1033 /*!
1034  * \brief Copy N_gradient_field_3d structure from source to target
1035  *
1036  * \param source - the source N_gradient_field_3d struct
1037  * \param target - the target N_gradient_field_3d struct
1038  * \return int - 1 success, 0 failure while copying
1039  *
1040  * */
1043 {
1045
1046  if (!source || !target)
1047  return 0;
1048
1049  N_copy_array_3d(source->x_array, target->x_array);
1050  N_copy_array_3d(source->y_array, target->y_array);
1051  N_copy_array_3d(source->z_array, target->z_array);
1052
1053  return 1;
1054 }
1055
1056 /*! \brief Print gradient field information to stdout
1057  *
1058  * \param field N_gradient_3d_field *
1059  * \return void
1060  *
1061  * */
1063 {
1064
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");
1083
1084  return;
1085 }
#define NULL
Definition: ccmath.h:32
void G_free(void *)
Free allocated memory.
Definition: gis/alloc.c:150
#define G_calloc(m, n)
Definition: defs/gis.h:95
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.
Definition: n_arrays.c:1170
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
Definition: n_arrays.c:774
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.
Definition: n_arrays.c:380
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.
Definition: n_arrays.c:719
void N_print_array_2d_info(N_array_2d *data)
This function writes the data info of the array data to stdout.
Definition: n_arrays.c:603
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
Definition: n_arrays.c:75
void N_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d structure.
Definition: n_arrays.c:132
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.
Definition: n_arrays.c:979
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.
Definition: n_arrays_calc.c:43
copy a N_gradient_neighbours_2d structure
Allocate a N_gradient_neighbours_y structure.
Allocate a N_gradient_neighbours_3d structure.
copy a N_gradient_3d structure
Allocate a N_gradient_2d structure.
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
Allocate a N_gradient_neighbours_2d structure.
Free's a N_gradient_neighbours_3d structure.
Allocate and initialize a N_gradient_neighbours_2d structure.
Copy N_gradient_field_3d structure from source to target.
copy a N_gradient_neighbours_x structure
Free's a N_gradient_neighbours_2d structure.
Print gradient field information to stdout.
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.
Print gradient field information to stdout.
Free's a N_gradient_neighbours_z structure.
copy a N_gradient_neighbours_z structure
copy a N_gradient_neighbours_3d structure
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
Allocate a N_gradient_3d structure.
Return a N_gradient_2d structure calculated from the input gradient field at position [row][col].
Free's a N_gradient_2d structure.
copy a N_gradient_neighbours_y structure
Allocate a N_gradient_neighbours_z structure.
copy a N_gradient_2d structure
Free's a N_gradient_3d structure.
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)
Free's a N_gradient_neighbours_2d structure.
Allocate and initialize a N_gradient_neighbours_3d structure.
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.
Copy N_gradient_field_2d structure from source to target.
Free's a N_gradient_neighbours_3d structure.
#define DCELL_TYPE
Definition: raster.h:13
Gradient between the cells in X and Y direction.
Definition: N_pde.h:457
double EC
Definition: N_pde.h:459
double SC
Definition: N_pde.h:459
double WC
Definition: N_pde.h:459
double NC
Definition: N_pde.h:459
Gradient between the cells in X, Y and Z direction.
Definition: N_pde.h:464
double WC
Definition: N_pde.h:466
double NC
Definition: N_pde.h:466
double EC
Definition: N_pde.h:466
double SC
Definition: N_pde.h:466
double BC
Definition: N_pde.h:466
double TC
Definition: N_pde.h:466
N_array_2d * y_array
Definition: N_pde.h:562
N_array_2d * x_array
Definition: N_pde.h:561
N_array_3d * y_array
Definition: N_pde.h:573
N_array_3d * x_array
Definition: N_pde.h:572
N_array_3d * z_array
Definition: N_pde.h:574
Gradient between the cell neighbours in X and Y direction.
Definition: N_pde.h:535
Definition: N_pde.h:538
Definition: N_pde.h:537
Gradient between the cell neighbours in X, Y and Z direction.
Definition: N_pde.h:543
Definition: N_pde.h:551
Definition: N_pde.h:554
Definition: N_pde.h:549
Definition: N_pde.h:553
Definition: N_pde.h:550