| 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 |
|
| 20 |
#ifndef __GSL_HISTOGRAM_H__ |
| 21 |
#define __GSL_HISTOGRAM_H__ |
| 22 |
|
| 23 |
#include <stdlib.h> |
| 24 |
#include <stdio.h> |
| 25 |
|
| 26 |
#undef __BEGIN_DECLS |
| 27 |
#undef __END_DECLS |
| 28 |
#ifdef __cplusplus |
| 29 |
# define __BEGIN_DECLS extern "C" { |
| 30 |
# define __END_DECLS } |
| 31 |
#else |
| 32 |
# define __BEGIN_DECLS /* empty */ |
| 33 |
# define __END_DECLS /* empty */ |
| 34 |
#endif |
| 35 |
|
| 36 |
__BEGIN_DECLS |
| 37 |
|
| 38 |
typedef struct { |
| 39 |
size_t n ; |
| 40 |
double * range ; |
| 41 |
double * bin ; |
| 42 |
} gsl_histogram ; |
| 43 |
|
| 44 |
typedef struct { |
| 45 |
size_t n ; |
| 46 |
double * range ; |
| 47 |
double * sum ; |
| 48 |
} gsl_histogram_pdf ; |
| 49 |
|
| 50 |
gsl_histogram * gsl_histogram_alloc (size_t n); |
| 51 |
|
| 52 |
gsl_histogram * gsl_histogram_calloc (size_t n); |
| 53 |
gsl_histogram * gsl_histogram_calloc_uniform (const size_t n, const double xmin, const double xmax); |
| 54 |
void gsl_histogram_free (gsl_histogram * h); |
| 55 |
int gsl_histogram_increment (gsl_histogram * h, double x); |
| 56 |
int gsl_histogram_accumulate (gsl_histogram * h, double x, double weight); |
| 57 |
int gsl_histogram_find (const gsl_histogram * h, |
| 58 |
const double x, size_t * i); |
| 59 |
|
| 60 |
double gsl_histogram_get (const gsl_histogram * h, size_t i); |
| 61 |
int gsl_histogram_get_range (const gsl_histogram * h, size_t i, |
| 62 |
double * lower, double * upper); |
| 63 |
|
| 64 |
double gsl_histogram_max (const gsl_histogram * h); |
| 65 |
double gsl_histogram_min (const gsl_histogram * h); |
| 66 |
size_t gsl_histogram_bins (const gsl_histogram * h); |
| 67 |
|
| 68 |
void gsl_histogram_reset (gsl_histogram * h); |
| 69 |
|
| 70 |
gsl_histogram * gsl_histogram_calloc_range(size_t n, double * range); |
| 71 |
|
| 72 |
int |
| 73 |
gsl_histogram_set_ranges (gsl_histogram * h, const double range[], size_t size); |
| 74 |
int |
| 75 |
gsl_histogram_set_ranges_uniform (gsl_histogram * h, double xmin, double xmax); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
int |
| 80 |
gsl_histogram_memcpy(gsl_histogram * dest, const gsl_histogram * source); |
| 81 |
|
| 82 |
gsl_histogram * |
| 83 |
gsl_histogram_clone(const gsl_histogram * source); |
| 84 |
|
| 85 |
double gsl_histogram_max_val (const gsl_histogram * h); |
| 86 |
|
| 87 |
size_t gsl_histogram_max_bin (const gsl_histogram * h); |
| 88 |
|
| 89 |
double gsl_histogram_min_val (const gsl_histogram * h); |
| 90 |
|
| 91 |
size_t gsl_histogram_min_bin (const gsl_histogram * h); |
| 92 |
|
| 93 |
int |
| 94 |
gsl_histogram_equal_bins_p(const gsl_histogram *h1, const gsl_histogram *h2); |
| 95 |
|
| 96 |
int |
| 97 |
gsl_histogram_add(gsl_histogram *h1, const gsl_histogram *h2); |
| 98 |
|
| 99 |
int |
| 100 |
gsl_histogram_sub(gsl_histogram *h1, const gsl_histogram *h2); |
| 101 |
|
| 102 |
int |
| 103 |
gsl_histogram_mul(gsl_histogram *h1, const gsl_histogram *h2); |
| 104 |
|
| 105 |
int |
| 106 |
gsl_histogram_div(gsl_histogram *h1, const gsl_histogram *h2); |
| 107 |
|
| 108 |
int |
| 109 |
gsl_histogram_scale(gsl_histogram *h, double scale); |
| 110 |
|
| 111 |
int |
| 112 |
gsl_histogram_shift (gsl_histogram * h, double shift); |
| 113 |
|
| 114 |
|
| 115 |
double gsl_histogram_sigma (const gsl_histogram * h); |
| 116 |
|
| 117 |
double gsl_histogram_mean (const gsl_histogram * h); |
| 118 |
|
| 119 |
double gsl_histogram_sum (const gsl_histogram * h); |
| 120 |
|
| 121 |
int gsl_histogram_fwrite (FILE * stream, const gsl_histogram * h) ; |
| 122 |
int gsl_histogram_fread (FILE * stream, gsl_histogram * h); |
| 123 |
int gsl_histogram_fprintf (FILE * stream, const gsl_histogram * h, |
| 124 |
const char * range_format, const char * bin_format); |
| 125 |
int gsl_histogram_fscanf (FILE * stream, gsl_histogram * h); |
| 126 |
|
| 127 |
gsl_histogram_pdf * gsl_histogram_pdf_alloc (const size_t n); |
| 128 |
int gsl_histogram_pdf_init (gsl_histogram_pdf * p, const gsl_histogram * h); |
| 129 |
void gsl_histogram_pdf_free (gsl_histogram_pdf * p); |
| 130 |
double gsl_histogram_pdf_sample (const gsl_histogram_pdf * p, double r); |
| 131 |
|
| 132 |
__END_DECLS |
| 133 |
|
| 134 |
#endif /* __GSL_HISTOGRAM_H__ */ |