3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
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.
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.
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.
22 #include <gsl/gsl_errno.h>
23 #include <gsl/gsl_permutation.h>
25 #define IN_FORMAT "%lu"
28 gsl_permutation_fread (FILE * stream, gsl_permutation * p)
32 size_t * data = p->data ;
34 size_t items = fread (data, sizeof (size_t), n, stream);
38 GSL_ERROR ("fread failed", GSL_EFAILED);
45 gsl_permutation_fwrite (FILE * stream, const gsl_permutation * p)
49 size_t * data = p->data ;
51 size_t items = fwrite (data, sizeof (size_t), n, stream);
55 GSL_ERROR ("fwrite failed", GSL_EFAILED);
62 gsl_permutation_fprintf (FILE * stream, const gsl_permutation * p, const char *format)
66 size_t * data = p->data ;
70 for (i = 0; i < n; i++)
72 int status = fprintf (stream, format, data[i]);
76 GSL_ERROR ("fprintf failed", GSL_EFAILED);
84 gsl_permutation_fscanf (FILE * stream, gsl_permutation * p)
88 size_t * data = p->data ;
92 for (i = 0; i < n; i++)
96 /* FIXME: what if size_t != unsigned long ???
98 want read in size_t but have to read in unsigned long to avoid
99 error from compiler */
101 int status = fscanf (stream, IN_FORMAT, &j);
105 GSL_ERROR ("fscanf failed", GSL_EFAILED);