globals.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Calculates univariate statistics from the non-null cells
  3. *
  4. * Copyright (C) 2004-2010 by the GRASS Development Team
  5. * Author(s): Soeren Gebbert
  6. * Based on r.univar from Hamish Bowman, University of Otago, New Zealand
  7. * and Martin Landa
  8. * zonal loop by Markus Metz
  9. *
  10. * This program is free software under the GNU General Public
  11. * License (>=v2). Read the file COPYING that comes with GRASS
  12. * for details.
  13. *
  14. */
  15. #ifndef _GLOBALS_H_
  16. #define _GLOBALS_H_
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <math.h>
  20. #include <grass/gis.h>
  21. #include <grass/raster3d.h>
  22. #include <grass/raster.h>
  23. #include <grass/glocale.h>
  24. /*- Parameters and global variables -----------------------------------------*/
  25. typedef struct
  26. {
  27. double sum;
  28. double sumsq;
  29. double min;
  30. double max;
  31. unsigned int n_perc;
  32. double *perc;
  33. double sum_abs;
  34. unsigned long n;
  35. unsigned long size;
  36. DCELL *dcell_array;
  37. FCELL *fcell_array;
  38. CELL *cell_array;
  39. int map_type;
  40. void *nextp;
  41. size_t n_alloc;
  42. int first;
  43. } univar_stat;
  44. typedef struct
  45. {
  46. CELL min, max, n_zones;
  47. struct Categories cats;
  48. char *sep;
  49. } zone_type;
  50. /* command line options are the same for raster and raster3d maps */
  51. typedef struct
  52. {
  53. struct Option *inputfile, *zonefile, *percentile, *output_file, *separator;
  54. struct Flag *shell_style, *extended, *table, *use_rast_region;
  55. } param_type;
  56. extern param_type param;
  57. extern zone_type zone_info;
  58. /* fn prototypes */
  59. void heapsort_double(double *data, int n);
  60. void heapsort_float(float *data, int n);
  61. void heapsort_int(int *data, int n);
  62. int print_stats(univar_stat * stats);
  63. int print_stats_table(univar_stat * stats);
  64. univar_stat *create_univar_stat_struct(int map_type, int n_perc);
  65. void free_univar_stat_struct(univar_stat * stats);
  66. #endif