gsl_histogram.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* histogram/gsl_histogram.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_HISTOGRAM_H__
  20. #define __GSL_HISTOGRAM_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 n ;
  35. double * range ;
  36. double * bin ;
  37. } gsl_histogram ;
  38. typedef struct {
  39. size_t n ;
  40. double * range ;
  41. double * sum ;
  42. } gsl_histogram_pdf ;
  43. gsl_histogram * gsl_histogram_alloc (size_t n);
  44. gsl_histogram * gsl_histogram_calloc (size_t n);
  45. gsl_histogram * gsl_histogram_calloc_uniform (const size_t n, const double xmin, const double xmax);
  46. void gsl_histogram_free (gsl_histogram * h);
  47. int gsl_histogram_increment (gsl_histogram * h, double x);
  48. int gsl_histogram_accumulate (gsl_histogram * h, double x, double weight);
  49. int gsl_histogram_find (const gsl_histogram * h,
  50. const double x, size_t * i);
  51. double gsl_histogram_get (const gsl_histogram * h, size_t i);
  52. int gsl_histogram_get_range (const gsl_histogram * h, size_t i,
  53. double * lower, double * upper);
  54. double gsl_histogram_max (const gsl_histogram * h);
  55. double gsl_histogram_min (const gsl_histogram * h);
  56. size_t gsl_histogram_bins (const gsl_histogram * h);
  57. void gsl_histogram_reset (gsl_histogram * h);
  58. gsl_histogram * gsl_histogram_calloc_range(size_t n, double * range);
  59. int
  60. gsl_histogram_set_ranges (gsl_histogram * h, const double range[], size_t size);
  61. int
  62. gsl_histogram_set_ranges_uniform (gsl_histogram * h, double xmin, double xmax);
  63. int
  64. gsl_histogram_memcpy(gsl_histogram * dest, const gsl_histogram * source);
  65. gsl_histogram *
  66. gsl_histogram_clone(const gsl_histogram * source);
  67. double gsl_histogram_max_val (const gsl_histogram * h);
  68. size_t gsl_histogram_max_bin (const gsl_histogram * h);
  69. double gsl_histogram_min_val (const gsl_histogram * h);
  70. size_t gsl_histogram_min_bin (const gsl_histogram * h);
  71. int
  72. gsl_histogram_equal_bins_p(const gsl_histogram *h1, const gsl_histogram *h2);
  73. int
  74. gsl_histogram_add(gsl_histogram *h1, const gsl_histogram *h2);
  75. int
  76. gsl_histogram_sub(gsl_histogram *h1, const gsl_histogram *h2);
  77. int
  78. gsl_histogram_mul(gsl_histogram *h1, const gsl_histogram *h2);
  79. int
  80. gsl_histogram_div(gsl_histogram *h1, const gsl_histogram *h2);
  81. int
  82. gsl_histogram_scale(gsl_histogram *h, double scale);
  83. int
  84. gsl_histogram_shift (gsl_histogram * h, double shift);
  85. double gsl_histogram_sigma (const gsl_histogram * h);
  86. double gsl_histogram_mean (const gsl_histogram * h);
  87. double gsl_histogram_sum (const gsl_histogram * h);
  88. int gsl_histogram_fwrite (FILE * stream, const gsl_histogram * h) ;
  89. int gsl_histogram_fread (FILE * stream, gsl_histogram * h);
  90. int gsl_histogram_fprintf (FILE * stream, const gsl_histogram * h,
  91. const char * range_format, const char * bin_format);
  92. int gsl_histogram_fscanf (FILE * stream, gsl_histogram * h);
  93. gsl_histogram_pdf * gsl_histogram_pdf_alloc (const size_t n);
  94. int gsl_histogram_pdf_init (gsl_histogram_pdf * p, const gsl_histogram * h);
  95. void gsl_histogram_pdf_free (gsl_histogram_pdf * p);
  96. double gsl_histogram_pdf_sample (const gsl_histogram_pdf * p, double r);
  97. __END_DECLS
  98. #endif /* __GSL_HISTOGRAM_H__ */