Added MACS source
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / combination / gsl_combination.h
1 /* combination/gsl_combination.h
2  * based on permutation/gsl_permutation.h by Brian Gough
3  * 
4  * Copyright (C) 2001 Szymon Jaroszewicz
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or (at
9  * your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __GSL_COMBINATION_H__
22 #define __GSL_COMBINATION_H__
23
24 #include <stdlib.h>
25 #include <gsl/gsl_errno.h>
26 #include <gsl/gsl_types.h>
27 #include <gsl/gsl_check_range.h>
28
29 #undef __BEGIN_DECLS
30 #undef __END_DECLS
31 #ifdef __cplusplus
32 # define __BEGIN_DECLS extern "C" {
33 # define __END_DECLS }
34 #else
35 # define __BEGIN_DECLS /* empty */
36 # define __END_DECLS /* empty */
37 #endif
38
39 __BEGIN_DECLS
40
41 struct gsl_combination_struct
42 {
43   size_t n;
44   size_t k;
45   size_t *data;
46 };
47
48 typedef struct gsl_combination_struct gsl_combination;
49
50 gsl_combination *gsl_combination_alloc (const size_t n, const size_t k);
51 gsl_combination *gsl_combination_calloc (const size_t n, const size_t k);
52 void gsl_combination_init_first (gsl_combination * c);
53 void gsl_combination_init_last (gsl_combination * c);
54 void gsl_combination_free (gsl_combination * c);
55 int gsl_combination_memcpy (gsl_combination * dest, const gsl_combination * src); 
56
57 int gsl_combination_fread (FILE * stream, gsl_combination * c);
58 int gsl_combination_fwrite (FILE * stream, const gsl_combination * c);
59 int gsl_combination_fscanf (FILE * stream, gsl_combination * c);
60 int gsl_combination_fprintf (FILE * stream, const gsl_combination * c, const char *format);
61
62 size_t gsl_combination_n (const gsl_combination * c);
63 size_t gsl_combination_k (const gsl_combination * c);
64 size_t * gsl_combination_data (const gsl_combination * c);
65
66 size_t gsl_combination_get (const gsl_combination * c, const size_t i);
67
68 int gsl_combination_valid (gsl_combination * c);
69 int gsl_combination_next (gsl_combination * c);
70 int gsl_combination_prev (gsl_combination * c);
71
72 #ifdef HAVE_INLINE
73
74 extern inline
75 size_t
76 gsl_combination_get (const gsl_combination * c, const size_t i)
77 {
78 #if GSL_RANGE_CHECK
79   if (i >= c->k)
80     {
81       GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0);
82     }
83 #endif
84   return c->data[i];
85 }
86
87 #endif /* HAVE_INLINE */
88
89 __END_DECLS
90
91 #endif /* __GSL_COMBINATION_H__ */