gsl_histogram2d.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* histogram/gsl_histogram2d.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __GSL_HISTOGRAM2D_H__
  20. #define __GSL_HISTOGRAM2D_H__
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #undef __BEGIN_DECLS
  24. #undef __END_DECLS
  25. #ifdef __cplusplus
  26. # define __BEGIN_DECLS extern "C" {
  27. # define __END_DECLS }
  28. #else
  29. # define __BEGIN_DECLS /* empty */
  30. # define __END_DECLS /* empty */
  31. #endif
  32. __BEGIN_DECLS
  33. typedef struct {
  34. size_t nx, ny ;
  35. double * xrange ;
  36. double * yrange ;
  37. double * bin ;
  38. } gsl_histogram2d ;
  39. typedef struct {
  40. size_t nx, ny ;
  41. double * xrange ;
  42. double * yrange ;
  43. double * sum ;
  44. } gsl_histogram2d_pdf ;
  45. gsl_histogram2d * gsl_histogram2d_alloc (const size_t nx, const size_t ny);
  46. gsl_histogram2d * gsl_histogram2d_calloc (const size_t nx, const size_t ny);
  47. gsl_histogram2d * gsl_histogram2d_calloc_uniform (const size_t nx, const size_t ny,
  48. const double xmin, const double xmax,
  49. const double ymin, const double ymax);
  50. void gsl_histogram2d_free (gsl_histogram2d * h);
  51. int gsl_histogram2d_increment (gsl_histogram2d * h, double x, double y);
  52. int gsl_histogram2d_accumulate (gsl_histogram2d * h,
  53. double x, double y, double weight);
  54. int gsl_histogram2d_find (const gsl_histogram2d * h,
  55. const double x, const double y, size_t * i, size_t * j);
  56. double gsl_histogram2d_get (const gsl_histogram2d * h, const size_t i, const size_t j);
  57. int gsl_histogram2d_get_xrange (const gsl_histogram2d * h, const size_t i,
  58. double * xlower, double * xupper);
  59. int gsl_histogram2d_get_yrange (const gsl_histogram2d * h, const size_t j,
  60. double * ylower, double * yupper);
  61. double gsl_histogram2d_xmax (const gsl_histogram2d * h);
  62. double gsl_histogram2d_xmin (const gsl_histogram2d * h);
  63. size_t gsl_histogram2d_nx (const gsl_histogram2d * h);
  64. double gsl_histogram2d_ymax (const gsl_histogram2d * h);
  65. double gsl_histogram2d_ymin (const gsl_histogram2d * h);
  66. size_t gsl_histogram2d_ny (const gsl_histogram2d * h);
  67. void gsl_histogram2d_reset (gsl_histogram2d * h);
  68. gsl_histogram2d *
  69. gsl_histogram2d_calloc_range(size_t nx, size_t ny,
  70. double *xrange, double *yrange);
  71. int
  72. gsl_histogram2d_set_ranges_uniform (gsl_histogram2d * h,
  73. double xmin, double xmax,
  74. double ymin, double ymax);
  75. int
  76. gsl_histogram2d_set_ranges (gsl_histogram2d * h,
  77. const double xrange[], size_t xsize,
  78. const double yrange[], size_t ysize);
  79. int
  80. gsl_histogram2d_memcpy(gsl_histogram2d *dest, const gsl_histogram2d *source);
  81. gsl_histogram2d *
  82. gsl_histogram2d_clone(const gsl_histogram2d * source);
  83. double
  84. gsl_histogram2d_max_val(const gsl_histogram2d *h);
  85. void
  86. gsl_histogram2d_max_bin (const gsl_histogram2d *h, size_t *i, size_t *j);
  87. double
  88. gsl_histogram2d_min_val(const gsl_histogram2d *h);
  89. void
  90. gsl_histogram2d_min_bin (const gsl_histogram2d *h, size_t *i, size_t *j);
  91. double
  92. gsl_histogram2d_xmean (const gsl_histogram2d * h);
  93. double
  94. gsl_histogram2d_ymean (const gsl_histogram2d * h);
  95. double
  96. gsl_histogram2d_xsigma (const gsl_histogram2d * h);
  97. double
  98. gsl_histogram2d_ysigma (const gsl_histogram2d * h);
  99. double
  100. gsl_histogram2d_cov (const gsl_histogram2d * h);
  101. double
  102. gsl_histogram2d_sum (const gsl_histogram2d *h);
  103. int
  104. gsl_histogram2d_equal_bins_p(const gsl_histogram2d *h1,
  105. const gsl_histogram2d *h2) ;
  106. int
  107. gsl_histogram2d_add(gsl_histogram2d *h1, const gsl_histogram2d *h2);
  108. int
  109. gsl_histogram2d_sub(gsl_histogram2d *h1, const gsl_histogram2d *h2);
  110. int
  111. gsl_histogram2d_mul(gsl_histogram2d *h1, const gsl_histogram2d *h2);
  112. int
  113. gsl_histogram2d_div(gsl_histogram2d *h1, const gsl_histogram2d *h2);
  114. int
  115. gsl_histogram2d_scale(gsl_histogram2d *h, double scale);
  116. int
  117. gsl_histogram2d_shift(gsl_histogram2d *h, double shift);
  118. int gsl_histogram2d_fwrite (FILE * stream, const gsl_histogram2d * h) ;
  119. int gsl_histogram2d_fread (FILE * stream, gsl_histogram2d * h);
  120. int gsl_histogram2d_fprintf (FILE * stream, const gsl_histogram2d * h,
  121. const char * range_format,
  122. const char * bin_format);
  123. int gsl_histogram2d_fscanf (FILE * stream, gsl_histogram2d * h);
  124. gsl_histogram2d_pdf * gsl_histogram2d_pdf_alloc (const size_t nx, const size_t ny);
  125. int gsl_histogram2d_pdf_init (gsl_histogram2d_pdf * p, const gsl_histogram2d * h);
  126. void gsl_histogram2d_pdf_free (gsl_histogram2d_pdf * p);
  127. int gsl_histogram2d_pdf_sample (const gsl_histogram2d_pdf * p,
  128. double r1, double r2,
  129. double * x, double * y);
  130. __END_DECLS
  131. #endif /* __GSL_HISTOGRAM2D_H__ */