1 /* combination/gsl_combination.h
2 * based on permutation/gsl_permutation.h by Brian Gough
4 * Copyright (C) 2001 Szymon Jaroszewicz
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.
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.
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.
21 #ifndef __GSL_COMBINATION_H__
22 #define __GSL_COMBINATION_H__
25 #include <gsl/gsl_errno.h>
26 #include <gsl/gsl_types.h>
27 #include <gsl/gsl_check_range.h>
32 # define __BEGIN_DECLS extern "C" {
33 # define __END_DECLS }
35 # define __BEGIN_DECLS /* empty */
36 # define __END_DECLS /* empty */
41 struct gsl_combination_struct
48 typedef struct gsl_combination_struct gsl_combination;
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);
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);
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);
66 size_t gsl_combination_get (const gsl_combination * c, const size_t i);
68 int gsl_combination_valid (gsl_combination * c);
69 int gsl_combination_next (gsl_combination * c);
70 int gsl_combination_prev (gsl_combination * c);
76 gsl_combination_get (const gsl_combination * c, const size_t i)
81 GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0);
87 #endif /* HAVE_INLINE */
91 #endif /* __GSL_COMBINATION_H__ */