GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
N_arrays_calc.c
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * MODULE: Grass PDE Numerical Library
5 * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
6 * soerengebbert <at> gmx <dot> de
7 *
8 * PURPOSE: Higher level array managment functions
9 * part of the gpde library
10 *
11 * COPYRIGHT: (C) 2000 by the GRASS Development Team
12 *
13 * This program is free software under the GNU General Public
14 * License (>=v2). Read the file COPYING that comes with GRASS
15 * for details.
16 *
17 *****************************************************************************/
18 
19 #include "grass/N_pde.h"
20 #include "grass/glocale.h"
21 #include <math.h>
22 
23 /* ******************** 2D ARRAY FUNCTIONS *********************** */
24 
43 void N_copy_array_2d(N_array_2d * source, N_array_2d * target)
44 {
45  int i;
46  int null = 0;
47 
48 #pragma omp single
49  {
50  if (source->cols_intern != target->cols_intern)
52  ("N_copy_array_2d: the arrays are not of equal size");
53 
54  if (source->rows_intern != target->rows_intern)
56  ("N_copy_array_2d: the arrays are not of equal size");
57 
58  G_debug(3,
59  "N_copy_array_2d: copy source array to target array size %i",
60  source->cols_intern * source->rows_intern);
61  }
62 
63 #pragma omp for
64  for (i = 0; i < source->cols_intern * source->rows_intern; i++) {
65  null = 0;
66  if (source->type == CELL_TYPE) {
67  if (G_is_c_null_value((void *)&source->cell_array[i]))
68  null = 1;
69 
70  if (target->type == CELL_TYPE) {
71  target->cell_array[i] = source->cell_array[i];
72  }
73  if (target->type == FCELL_TYPE) {
74  if (null)
75  G_set_f_null_value((void *)&(target->fcell_array[i]), 1);
76  else
77  target->fcell_array[i] = (FCELL) source->cell_array[i];
78  }
79  if (target->type == DCELL_TYPE) {
80  if (null)
81  G_set_d_null_value((void *)&(target->dcell_array[i]), 1);
82  else
83  target->dcell_array[i] = (DCELL) source->cell_array[i];
84  }
85 
86  }
87  if (source->type == FCELL_TYPE) {
88  if (G_is_f_null_value((void *)&source->fcell_array[i]))
89  null = 1;
90 
91  if (target->type == CELL_TYPE) {
92  if (null)
93  G_set_c_null_value((void *)&(target->cell_array[i]), 1);
94  else
95  target->cell_array[i] = (CELL) source->fcell_array[i];
96  }
97  if (target->type == FCELL_TYPE) {
98  target->fcell_array[i] = source->fcell_array[i];
99  }
100  if (target->type == DCELL_TYPE) {
101  if (null)
102  G_set_d_null_value((void *)&(target->dcell_array[i]), 1);
103  else
104  target->dcell_array[i] = (DCELL) source->fcell_array[i];
105  }
106  }
107  if (source->type == DCELL_TYPE) {
108  if (G_is_d_null_value((void *)&source->dcell_array[i]))
109  null = 1;
110 
111  if (target->type == CELL_TYPE) {
112  if (null)
113  G_set_c_null_value((void *)&(target->cell_array[i]), 1);
114  else
115  target->cell_array[i] = (CELL) source->dcell_array[i];
116  }
117  if (target->type == FCELL_TYPE) {
118  if (null)
119  G_set_f_null_value((void *)&(target->fcell_array[i]), 1);
120  else
121  target->fcell_array[i] = (FCELL) source->dcell_array[i];
122  }
123  if (target->type == DCELL_TYPE) {
124  target->dcell_array[i] = source->dcell_array[i];
125  }
126  }
127  }
128 
129  return;
130 }
131 
147 {
148  int i = 0;
149  double norm = 0.0, tmp = 0.0;
150  double v1 = 0.0, v2 = 0.0;
151 
152  if (a->cols_intern != b->cols_intern)
153  G_fatal_error("N_norm_array_2d: the arrays are not of equal size");
154 
155  if (a->rows_intern != b->rows_intern)
156  G_fatal_error("N_norm_array_2d: the arrays are not of equal size");
157 
158  G_debug(3, "N_norm_array_2d: norm of a and b size %i",
159  a->cols_intern * a->rows_intern);
160 
161  for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
162  v1 = 0.0;
163  v2 = 0.0;
164 
165  if (a->type == CELL_TYPE) {
166  if (!G_is_f_null_value((void *)&(a->cell_array[i])))
167  v1 = (double)a->cell_array[i];
168  }
169  if (a->type == FCELL_TYPE) {
170  if (!G_is_f_null_value((void *)&(a->fcell_array[i])))
171  v1 = (double)a->fcell_array[i];
172  }
173  if (a->type == DCELL_TYPE) {
174  if (!G_is_f_null_value((void *)&(a->dcell_array[i])))
175  v1 = (double)a->dcell_array[i];
176  }
177  if (b->type == CELL_TYPE) {
178  if (!G_is_f_null_value((void *)&(b->cell_array[i])))
179  v2 = (double)b->cell_array[i];
180  }
181  if (b->type == FCELL_TYPE) {
182  if (!G_is_f_null_value((void *)&(b->fcell_array[i])))
183  v2 = (double)b->fcell_array[i];
184  }
185  if (b->type == DCELL_TYPE) {
186  if (!G_is_f_null_value((void *)&(b->dcell_array[i])))
187  v2 = (double)b->dcell_array[i];
188  }
189 
190  if (type == N_MAXIMUM_NORM) {
191  tmp = fabs(v2 - v1);
192  if ((tmp > norm))
193  norm = tmp;
194  }
195  if (type == N_EUKLID_NORM) {
196  norm += fabs(v2 - v1);
197  }
198  }
199 
200  return norm;
201 }
202 
217 void N_calc_array_2d_stats(N_array_2d * a, double *min, double *max,
218  double *sum, int *nonull, int withoffset)
219 {
220  int i, j;
221  double val;
222 
223  *sum = 0.0;
224  *nonull = 0;
225 
226  if (withoffset == 1) {
227 
228  *min =
229  (double)N_get_array_2d_d_value(a, 0 - a->offset, 0 - a->offset);
230  *max =
231  (double)N_get_array_2d_d_value(a, 0 - a->offset, 0 - a->offset);
232 
233  for (j = 0 - a->offset; j < a->rows + a->offset; j++) {
234  for (i = 0 - a->offset; i < a->cols + a->offset; i++) {
235  if (!N_is_array_2d_value_null(a, i, j)) {
236  val = (double)N_get_array_2d_d_value(a, i, j);
237  if (*min > val)
238  *min = val;
239  if (*max < val)
240  *max = val;
241  *sum += val;
242  (*nonull)++;
243  }
244  }
245  }
246  }
247  else {
248 
249  *min = (double)N_get_array_2d_d_value(a, 0, 0);
250  *max = (double)N_get_array_2d_d_value(a, 0, 0);
251 
252 
253  for (j = 0; j < a->rows; j++) {
254  for (i = 0; i < a->cols; i++) {
255  if (!N_is_array_2d_value_null(a, i, j)) {
256  val = (double)N_get_array_2d_d_value(a, i, j);
257  if (*min > val)
258  *min = val;
259  if (*max < val)
260  *max = val;
261  *sum += val;
262  (*nonull)++;
263  }
264  }
265  }
266  }
267 
268  G_debug(3,
269  "N_calc_array_2d_stats: compute array stats, min %g, max %g, sum %g, nonull %i",
270  *min, *max, *sum, *nonull);
271  return;
272 }
273 
274 
307  N_array_2d * result, int type)
308 {
309  N_array_2d *c;
310  int i, j, setnull = 0;
311  double va = 0.0, vb = 0.0, vc = 0.0; /*variables used for calculation */
312 
313  /*Set the pointer */
314  c = result;
315 
316 #pragma omp single
317  {
318  /*Check the array sizes */
319  if (a->cols_intern != b->cols_intern)
321  ("N_math_array_2d: the arrays are not of equal size");
322  if (a->rows_intern != b->rows_intern)
324  ("N_math_array_2d: the arrays are not of equal size");
325  if (a->offset != b->offset)
327  ("N_math_array_2d: the arrays have different offsets");
328 
329  G_debug(3, "N_math_array_2d: mathematical calculations, size: %i",
330  a->cols_intern * a->rows_intern);
331 
332  /*if the result array is null, allocate a new one, use the
333  * largest data type of the input arrays*/
334  if (c == NULL) {
335  if (a->type == DCELL_TYPE || b->type == DCELL_TYPE) {
336  c = N_alloc_array_2d(a->cols, a->rows, a->offset, DCELL_TYPE);
337  G_debug(3,
338  "N_math_array_2d: array of type DCELL_TYPE created");
339  }
340  else if (a->type == FCELL_TYPE || b->type == FCELL_TYPE) {
341  c = N_alloc_array_2d(a->cols, a->rows, a->offset, FCELL_TYPE);
342  G_debug(3,
343  "N_math_array_2d: array of type FCELL_TYPE created");
344  }
345  else {
346  c = N_alloc_array_2d(a->cols, a->rows, a->offset, CELL_TYPE);
347  G_debug(3,
348  "N_math_array_2d: array of type CELL_TYPE created");
349  }
350  }
351  else {
352  /*Check the array sizes */
353  if (a->cols_intern != c->cols_intern)
355  ("N_math_array_2d: the arrays are not of equal size");
356  if (a->rows_intern != c->rows_intern)
358  ("N_math_array_2d: the arrays are not of equal size");
359  if (a->offset != c->offset)
361  ("N_math_array_2d: the arrays have different offsets");
362  }
363  }
364 
365 #pragma omp for private(va, vb, vc, setnull)
366  for (j = 0 - a->offset; j < a->rows + a->offset; j++) {
367  for (i = 0 - a->offset; i < a->cols + a->offset; i++) {
368  if (!N_is_array_2d_value_null(a, i, j) &&
369  !N_is_array_2d_value_null(b, i, j)) {
370  /*we always calulate internally with double values */
371  va = (double)N_get_array_2d_d_value(a, i, j);
372  vb = (double)N_get_array_2d_d_value(b, i, j);
373  vc = 0;
374  setnull = 0;
375 
376  switch (type) {
377  case N_ARRAY_SUM:
378  vc = va + vb;
379  break;
380  case N_ARRAY_DIF:
381  vc = va - vb;
382  break;
383  case N_ARRAY_MUL:
384  vc = va * vb;
385  break;
386  case N_ARRAY_DIV:
387  if (vb != 0)
388  vc = va / vb;
389  else
390  setnull = 1;
391  break;
392  }
393 
394  if (c->type == CELL_TYPE) {
395  if (setnull)
396  N_put_array_2d_value_null(c, i, j);
397  else
398  N_put_array_2d_c_value(c, i, j, (CELL) vc);
399  }
400  if (c->type == FCELL_TYPE) {
401  if (setnull)
402  N_put_array_2d_value_null(c, i, j);
403  else
404  N_put_array_2d_f_value(c, i, j, (FCELL) vc);
405  }
406  if (c->type == DCELL_TYPE) {
407  if (setnull)
408  N_put_array_2d_value_null(c, i, j);
409  else
410  N_put_array_2d_d_value(c, i, j, (DCELL) vc);
411  }
412 
413  }
414  else {
415  N_put_array_2d_value_null(c, i, j);
416  }
417  }
418  }
419 
420  return c;
421 }
422 
433 {
434  int i = 0, count = 0;
435 
436  G_debug(3, "N_convert_array_2d_null_to_zero: convert array of size %i",
437  a->cols_intern * a->rows_intern);
438 
439  if (a->type == CELL_TYPE)
440  for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
441  if (G_is_c_null_value((void *)&(a->cell_array[i]))) {
442  a->cell_array[i] = 0;
443  count++;
444  }
445  }
446 
447  if (a->type == FCELL_TYPE)
448  for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
449  if (G_is_f_null_value((void *)&(a->fcell_array[i]))) {
450  a->fcell_array[i] = 0.0;
451  count++;
452  }
453  }
454 
455 
456  if (a->type == DCELL_TYPE)
457  for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
458  if (G_is_d_null_value((void *)&(a->dcell_array[i]))) {
459  a->dcell_array[i] = 0.0;
460  count++;
461  }
462  }
463 
464 
465  if (a->type == CELL_TYPE)
466  G_debug(2,
467  "N_convert_array_2d_null_to_zero: %i values of type CELL_TYPE are converted",
468  count);
469  if (a->type == FCELL_TYPE)
470  G_debug(2,
471  "N_convert_array_2d_null_to_zero: %i valuess of type FCELL_TYPE are converted",
472  count);
473  if (a->type == DCELL_TYPE)
474  G_debug(2,
475  "N_convert_array_2d_null_to_zero: %i valuess of type DCELL_TYPE are converted",
476  count);
477 
478  return count;
479 }
480 
481 /* ******************** 3D ARRAY FUNCTIONS *********************** */
482 
498 void N_copy_array_3d(N_array_3d * source, N_array_3d * target)
499 {
500  int i;
501  int null;
502 
503  if (source->cols_intern != target->cols_intern)
504  G_fatal_error("N_copy_array_3d: the arrays are not of equal size");
505 
506  if (source->rows_intern != target->rows_intern)
507  G_fatal_error("N_copy_array_3d: the arrays are not of equal size");
508 
509  if (source->depths_intern != target->depths_intern)
510  G_fatal_error("N_copy_array_3d: the arrays are not of equal size");
511 
512 
513  G_debug(3, "N_copy_array_3d: copy source array to target array size %i",
514  source->cols_intern * source->rows_intern *
515  source->depths_intern);
516 
517  for (i = 0;
518  i <
519  source->cols_intern * source->rows_intern * source->depths_intern;
520  i++) {
521  null = 0;
522  if (source->type == FCELL_TYPE) {
524  ((void *)&(source->fcell_array[i]), FCELL_TYPE))
525  null = 1;
526 
527  if (target->type == FCELL_TYPE) {
528  target->fcell_array[i] = source->fcell_array[i];
529  }
530  if (target->type == DCELL_TYPE) {
531  if (null)
532  G3d_setNullValue((void *)&(target->dcell_array[i]), 1,
533  DCELL_TYPE);
534  else
535  target->dcell_array[i] = (double)source->fcell_array[i];
536  }
537 
538  }
539  if (source->type == DCELL_TYPE) {
541  ((void *)&(source->dcell_array[i]), DCELL_TYPE))
542  null = 1;
543 
544  if (target->type == FCELL_TYPE) {
545  if (null)
546  G3d_setNullValue((void *)&(target->fcell_array[i]), 1,
547  FCELL_TYPE);
548  else
549  target->fcell_array[i] = (float)source->dcell_array[i];
550  }
551  if (target->type == DCELL_TYPE) {
552  target->dcell_array[i] = source->dcell_array[i];
553  }
554  }
555  }
556 
557  return;
558 }
559 
560 
575 {
576  int i = 0;
577  double norm = 0.0, tmp = 0.0;
578  double v1 = 0.0, v2 = 0.0;
579 
580  if (a->cols_intern != b->cols_intern)
581  G_fatal_error("N_norm_array_3d: the arrays are not of equal size");
582 
583  if (a->rows_intern != b->rows_intern)
584  G_fatal_error("N_norm_array_3d: the arrays are not of equal size");
585 
586  if (a->depths_intern != b->depths_intern)
587  G_fatal_error("N_norm_array_3d: the arrays are not of equal size");
588 
589  G_debug(3, "N_norm_array_3d: norm of a and b size %i",
590  a->cols_intern * a->rows_intern * a->depths_intern);
591 
592  for (i = 0; i < a->cols_intern * a->rows_intern * a->depths_intern; i++) {
593  v1 = 0.0;
594  v2 = 0.0;
595 
596  if (a->type == FCELL_TYPE) {
597  if (!G3d_isNullValueNum((void *)&(a->fcell_array[i]), FCELL_TYPE))
598  v1 = (double)a->fcell_array[i];
599  }
600  if (a->type == DCELL_TYPE) {
601  if (!G3d_isNullValueNum((void *)&(a->dcell_array[i]), DCELL_TYPE))
602  v1 = (double)a->dcell_array[i];
603  }
604  if (b->type == FCELL_TYPE) {
605  if (!G3d_isNullValueNum((void *)&(b->fcell_array[i]), FCELL_TYPE))
606  v2 = (double)b->fcell_array[i];
607  }
608  if (b->type == DCELL_TYPE) {
609  if (!G3d_isNullValueNum((void *)&(b->dcell_array[i]), DCELL_TYPE))
610  v2 = (double)b->dcell_array[i];
611  }
612 
613  if (type == N_MAXIMUM_NORM) {
614  tmp = fabs(v2 - v1);
615  if ((tmp > norm))
616  norm = tmp;
617  }
618  if (type == N_EUKLID_NORM) {
619  norm += fabs(v2 - v1);
620  }
621  }
622 
623  return norm;
624 }
625 
640 void N_calc_array_3d_stats(N_array_3d * a, double *min, double *max,
641  double *sum, int *nonull, int withoffset)
642 {
643  int i, j, k;
644  double val;
645 
646  *sum = 0.0;
647  *nonull = 0;
648 
649  if (withoffset == 1) {
650 
651  *min =
652  (double)N_get_array_3d_d_value(a, 0 - a->offset, 0 - a->offset,
653  0 - a->offset);
654  *max =
655  (double)N_get_array_3d_d_value(a, 0 - a->offset, 0 - a->offset,
656  0 - a->offset);
657 
658  for (k = 0 - a->offset; k < a->depths + a->offset; k++) {
659  for (j = 0 - a->offset; j < a->rows + a->offset; j++) {
660  for (i = 0 - a->offset; i < a->cols + a->offset; i++) {
661  if (!N_is_array_3d_value_null(a, i, j, k)) {
662  val = (double)N_get_array_3d_d_value(a, i, j, k);
663  if (*min > val)
664  *min = val;
665  if (*max < val)
666  *max = val;
667  *sum += val;
668  (*nonull)++;
669  }
670  }
671  }
672  }
673  }
674  else {
675 
676  *min = (double)N_get_array_3d_d_value(a, 0, 0, 0);
677  *max = (double)N_get_array_3d_d_value(a, 0, 0, 0);
678 
679  for (k = 0; k < a->depths; k++) {
680  for (j = 0; j < a->rows; j++) {
681  for (i = 0; i < a->cols; i++) {
682  if (!N_is_array_3d_value_null(a, i, j, k)) {
683  val = (double)N_get_array_3d_d_value(a, i, j, k);
684  if (*min > val)
685  *min = val;
686  if (*max < val)
687  *max = val;
688  *sum += val;
689  (*nonull)++;
690  }
691  }
692  }
693  }
694  }
695 
696  G_debug(3,
697  "N_calc_array_3d_stats: compute array stats, min %g, max %g, sum %g, nonull %i",
698  *min, *max, *sum, *nonull);
699 
700  return;
701 }
702 
738  N_array_3d * result, int type)
739 {
740  N_array_3d *c;
741  int i, j, k, setnull = 0;
742  double va = 0.0, vb = 0.0, vc = 0.0; /*variables used for calculation */
743 
744  /*Set the pointer */
745  c = result;
746 
747  /*Check the array sizes */
748  if (a->cols_intern != b->cols_intern)
749  G_fatal_error("N_math_array_3d: the arrays are not of equal size");
750  if (a->rows_intern != b->rows_intern)
751  G_fatal_error("N_math_array_3d: the arrays are not of equal size");
752  if (a->depths_intern != b->depths_intern)
753  G_fatal_error("N_math_array_3d: the arrays are not of equal size");
754  if (a->offset != b->offset)
755  G_fatal_error("N_math_array_3d: the arrays have different offsets");
756 
757  G_debug(3, "N_math_array_3d: mathematical calculations, size: %i",
758  a->cols_intern * a->rows_intern * a->depths_intern);
759 
760  /*if the result array is null, allocate a new one, use the
761  * largest data type of the input arrays*/
762  if (c == NULL) {
763  if (a->type == DCELL_TYPE || b->type == DCELL_TYPE) {
764  c = N_alloc_array_3d(a->cols, a->rows, a->depths, a->offset,
765  DCELL_TYPE);
766  G_debug(3, "N_math_array_3d: array of type DCELL_TYPE created");
767  }
768  else {
769  c = N_alloc_array_3d(a->cols, a->rows, a->depths, a->offset,
770  FCELL_TYPE);
771  G_debug(3, "N_math_array_3d: array of type FCELL_TYPE created");
772  }
773  }
774  else {
775  /*Check the array sizes */
776  if (a->cols_intern != c->cols_intern)
778  ("N_math_array_3d: the arrays are not of equal size");
779  if (a->rows_intern != c->rows_intern)
781  ("N_math_array_3d: the arrays are not of equal size");
782  if (a->depths_intern != c->depths_intern)
784  ("N_math_array_3d: the arrays are not of equal size");
785  if (a->offset != c->offset)
787  ("N_math_array_3d: the arrays have different offsets");
788  }
789 
790  for (k = 0 - a->offset; k < a->depths + a->offset; k++) {
791  for (j = 0 - a->offset; j < a->rows + a->offset; j++) {
792  for (i = 0 - a->offset; i < a->cols + a->offset; i++) {
793  if (!N_is_array_3d_value_null(a, i, j, k) &&
794  !N_is_array_3d_value_null(a, i, j, k)) {
795  /*we always calulate internally with double values */
796  va = (double)N_get_array_3d_d_value(a, i, j, k);
797  vb = (double)N_get_array_3d_d_value(b, i, j, k);
798  vc = 0;
799  setnull = 0;
800 
801  switch (type) {
802  case N_ARRAY_SUM:
803  vc = va + vb;
804  break;
805  case N_ARRAY_DIF:
806  vc = va - vb;
807  break;
808  case N_ARRAY_MUL:
809  vc = va * vb;
810  break;
811  case N_ARRAY_DIV:
812  if (vb != 0)
813  vc = va / vb;
814  else
815  setnull = 1;
816  break;
817  }
818 
819  if (c->type == FCELL_TYPE) {
820  if (setnull)
821  N_put_array_3d_value_null(c, i, j, k);
822  else
823  N_put_array_3d_f_value(c, i, j, k, (float)vc);
824  }
825  if (c->type == DCELL_TYPE) {
826  if (setnull)
827  N_put_array_3d_value_null(c, i, j, k);
828  else
829  N_put_array_3d_d_value(c, i, j, k, vc);
830  }
831  }
832  else {
833  N_put_array_3d_value_null(c, i, j, k);
834  }
835  }
836  }
837  }
838 
839  return c;
840 }
841 
851 {
852  int i = 0, count = 0;
853 
854  G_debug(3, "N_convert_array_3d_null_to_zero: convert array of size %i",
855  a->cols_intern * a->rows_intern * a->depths_intern);
856 
857  if (a->type == FCELL_TYPE)
858  for (i = 0; i < a->cols_intern * a->rows_intern * a->depths_intern;
859  i++) {
860  if (G3d_isNullValueNum((void *)&(a->fcell_array[i]), FCELL_TYPE)) {
861  a->fcell_array[i] = 0.0;
862  count++;
863  }
864  }
865 
866  if (a->type == DCELL_TYPE)
867  for (i = 0; i < a->cols_intern * a->rows_intern * a->depths_intern;
868  i++) {
869  if (G3d_isNullValueNum((void *)&(a->dcell_array[i]), DCELL_TYPE)) {
870  a->dcell_array[i] = 0.0;
871  count++;
872  }
873  }
874 
875 
876  if (a->type == FCELL_TYPE)
877  G_debug(3,
878  "N_convert_array_3d_null_to_zero: %i values of type FCELL_TYPE are converted",
879  count);
880 
881  if (a->type == DCELL_TYPE)
882  G_debug(3,
883  "N_convert_array_3d_null_to_zero: %i values of type DCELL_TYPE are converted",
884  count);
885 
886  return count;
887 }
int G_is_c_null_value(const CELL *cellVal)
Returns 1 if cell is NULL, 0 otherwise. This will test if the value cell is the largest int...
Definition: null_val.c:244
#define N_MAXIMUM_NORM
Definition: N_pde.h:59
float b
Definition: named_colr.c:8
int depths_intern
Definition: N_pde.h:219
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...
Definition: N_arrays.c:878
int rows
Definition: N_pde.h:162
void G3d_setNullValue(void *c, int nofElts, int type)
Fills the vector pointed to by c with nofElts NULL-values of type.
Definition: g3dnull.c:32
#define min(x, y)
Definition: draw2.c:68
void G_set_d_null_value(DCELL *dcellVals, int numVals)
Definition: null_val.c:176
int depths
Definition: N_pde.h:218
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.
Definition: N_arrays.c:1073
int G3d_isNullValueNum(const void *n, int type)
Definition: g3dnull.c:9
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.
Definition: N_arrays.c:581
int count
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.
Definition: N_arrays.c:551
N_array_2d * N_math_array_2d(N_array_2d *a, N_array_2d *b, N_array_2d *result, int type)
Performe calculations with two input arrays, the result is written to a third array.
int cols
Definition: N_pde.h:162
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.
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:69
#define max(x, y)
Definition: draw2.c:69
int offset
Definition: N_pde.h:220
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:723
int offset
Definition: N_pde.h:164
CELL * cell_array
Definition: N_pde.h:165
double N_norm_array_3d(N_array_3d *a, N_array_3d *b, int type)
Calculate the norm of the two input arrays.
int cols_intern
Definition: N_pde.h:219
int N_convert_array_3d_null_to_zero(N_array_3d *a)
Convert all null values to zero values.
int G_is_d_null_value(const DCELL *dcellVal)
Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in G_is_f_null_value().
Definition: null_val.c:306
int G_is_f_null_value(const FCELL *fcellVal)
Returns 1 if fcell is NULL, 0 otherwise. This will test if the value fcell is a NaN. It isn&#39;t good enough to test for a particular NaN bit pattern since the machine code may change this bit pattern to a different NaN. The test will be.
Definition: null_val.c:281
int cols
Definition: N_pde.h:218
FCELL * fcell_array
Definition: N_pde.h:166
int N_convert_array_2d_null_to_zero(N_array_2d *a)
Convert all null values to zero values.
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.
Definition: N_arrays.c:455
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
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.
Definition: N_arrays.c:521
DCELL * dcell_array
Definition: N_pde.h:167
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.
Definition: N_arrays.c:1145
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.
float * fcell_array
Definition: N_pde.h:221
void G_set_f_null_value(FCELL *fcellVals, int numVals)
Definition: null_val.c:158
N_array_3d * N_math_array_3d(N_array_3d *a, N_array_3d *b, N_array_3d *result, int type)
Performe calculations with two input arrays, the result is written to a third array.
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 postion col, row is of type null, otherwise 0...
Definition: N_arrays.c:228
double * dcell_array
Definition: N_pde.h:222
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:987
int type
Definition: N_pde.h:161
return NULL
Definition: dbfopen.c:1394
tuple cols
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
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:375
int cols_intern
Definition: N_pde.h:163
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.
Definition: N_arrays.c:1172
void G_set_c_null_value(CELL *cellVals, int numVals)
Definition: null_val.c:142
double N_norm_array_2d(N_array_2d *a, N_array_2d *b, int type)
Calculate the norm of the two input arrays.
#define N_ARRAY_DIF
Definition: N_pde.h:63
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
#define N_EUKLID_NORM
Definition: N_pde.h:60
int type
Definition: N_pde.h:217
int rows_intern
Definition: N_pde.h:219
#define N_ARRAY_MUL
Definition: N_pde.h:64
int rows
Definition: N_pde.h:218
#define N_ARRAY_DIV
Definition: N_pde.h:65
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.
int rows_intern
Definition: N_pde.h:163
#define N_ARRAY_SUM
Definition: N_pde.h:62