2 * based on permutation/file.c 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.
23 #include <gsl/gsl_errno.h>
24 #include <gsl/gsl_combination.h>
26 #define IN_FORMAT "%lu"
29 gsl_combination_fread (FILE * stream, gsl_combination * c)
33 size_t * data = c->data ;
35 size_t items = fread (data, sizeof (size_t), k, stream);
39 GSL_ERROR ("fread failed", GSL_EFAILED);
46 gsl_combination_fwrite (FILE * stream, const gsl_combination * c)
50 size_t * data = c->data ;
52 size_t items = fwrite (data, sizeof (size_t), k, stream);
56 GSL_ERROR ("fwrite failed", GSL_EFAILED);
63 gsl_combination_fprintf (FILE * stream, const gsl_combination * c, const char *format)
67 size_t * data = c->data ;
71 for (i = 0; i < k; i++)
73 int status = fprintf (stream, format, data[i]);
77 GSL_ERROR ("fprintf failed", GSL_EFAILED);
85 gsl_combination_fscanf (FILE * stream, gsl_combination * c)
89 size_t * data = c->data ;
93 for (i = 0; i < k; i++)
97 /* FIXME: what if size_t != unsigned long ???
99 want read in size_t but have to read in unsigned long to avoid
100 error from compiler */
102 int status = fscanf (stream, IN_FORMAT, &j);
106 GSL_ERROR ("fscanf failed", GSL_EFAILED);