1 /* block/fprintf_source.c
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, 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.
20 #if !(USES_LONGDOUBLE && !HAVE_PRINTF_LONGDOUBLE)
23 FUNCTION (gsl_block, fprintf) (FILE * stream, const TYPE(gsl_block) * b, const char *format)
27 ATOMIC * data = b->data ;
31 for (i = 0; i < n; i++)
36 for (k = 0; k < MULTIPLICITY; k++)
40 status = putc (' ', stream);
44 GSL_ERROR ("putc failed", GSL_EFAILED);
47 status = fprintf (stream,
49 data[MULTIPLICITY * i + k]);
52 GSL_ERROR ("fprintf failed", GSL_EFAILED);
56 status = putc ('\n', stream);
60 GSL_ERROR ("putc failed", GSL_EFAILED);
68 FUNCTION (gsl_block, fscanf) (FILE * stream, TYPE(gsl_block) * b)
72 ATOMIC * data = b->data ;
76 for (i = 0; i < n; i++)
79 for (k = 0; k < MULTIPLICITY; k++)
83 int status = fscanf (stream, IN_FORMAT, &tmp) ;
85 data [MULTIPLICITY * i + k] = tmp;
90 GSL_ERROR ("fscanf failed", GSL_EFAILED);
100 FUNCTION (gsl_block, raw_fprintf) (FILE * stream,
108 for (i = 0; i < n; i++)
113 for (k = 0; k < MULTIPLICITY; k++)
117 status = putc (' ', stream);
121 GSL_ERROR ("putc failed", GSL_EFAILED);
124 status = fprintf (stream,
126 data[MULTIPLICITY * i * stride + k]);
129 GSL_ERROR ("fprintf failed", GSL_EFAILED);
133 status = putc ('\n', stream);
137 GSL_ERROR ("putc failed", GSL_EFAILED);
145 FUNCTION (gsl_block, raw_fscanf) (FILE * stream,
152 for (i = 0; i < n; i++)
155 for (k = 0; k < MULTIPLICITY; k++)
159 int status = fscanf (stream, IN_FORMAT, &tmp) ;
161 data [MULTIPLICITY * i * stride + k] = tmp;
164 GSL_ERROR ("fscanf failed", GSL_EFAILED);