Debian Codegraph @

external/gsl/gsl_block__fprintf_source.c

raw symbols SCIP
1 /* block/fprintf_source.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
4 *
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.
9 *
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.
14 *
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.
18 */
19
20 #if !(USES_LONGDOUBLE && !HAVE_PRINTF_LONGDOUBLE)
21
22 int
23 FUNCTION (gsl_block, fprintf) (FILE * stream, const TYPE(gsl_block) * b, const char *format)
24 {
25 size_t n = b->size ;
26
27 ATOMIC * data = b->data ;
28
29 size_t i;
30
31 for (i = 0; i < n; i++)
32 {
33 int k;
34 int status;
35
36 for (k = 0; k < MULTIPLICITY; k++)
37 {
38 if (k > 0)
39 {
40 status = putc (' ', stream);
41
42 if (status == EOF)
43 {
44 GSL_ERROR ("putc failed", GSL_EFAILED);
45 }
46 }
47 status = fprintf (stream,
48 format,
49 data[MULTIPLICITY * i + k]);
50 if (status < 0)
51 {
52 GSL_ERROR ("fprintf failed", GSL_EFAILED);
53 }
54 }
55
56 status = putc ('\n', stream);
57
58 if (status == EOF)
59 {
60 GSL_ERROR ("putc failed", GSL_EFAILED);
61 }
62 }
63
64 return 0;
65 }
66
67 int
68 FUNCTION (gsl_block, fscanf) (FILE * stream, TYPE(gsl_block) * b)
69 {
70 size_t n = b->size ;
71
72 ATOMIC * data = b->data ;
73
74 size_t i;
75
76 for (i = 0; i < n; i++)
77 {
78 int k;
79 for (k = 0; k < MULTIPLICITY; k++)
80 {
81 ATOMIC_IO tmp ;
82
83 int status = fscanf (stream, IN_FORMAT, &tmp) ;
84
85 data [MULTIPLICITY * i + k] = tmp;
86
87
88 if (status != 1)
89 {
90 GSL_ERROR ("fscanf failed", GSL_EFAILED);
91 }
92 }
93 }
94
95 return GSL_SUCCESS;
96 }
97
98
99 int
100 FUNCTION (gsl_block, raw_fprintf) (FILE * stream,
101 const ATOMIC * data,
102 const size_t n,
103 const size_t stride,
104 const char *format)
105 {
106 size_t i;
107
108 for (i = 0; i < n; i++)
109 {
110 int k;
111 int status;
112
113 for (k = 0; k < MULTIPLICITY; k++)
114 {
115 if (k > 0)
116 {
117 status = putc (' ', stream);
118
119 if (status == EOF)
120 {
121 GSL_ERROR ("putc failed", GSL_EFAILED);
122 }
123 }
124 status = fprintf (stream,
125 format,
126 data[MULTIPLICITY * i * stride + k]);
127 if (status < 0)
128 {
129 GSL_ERROR ("fprintf failed", GSL_EFAILED);
130 }
131 }
132
133 status = putc ('\n', stream);
134
135 if (status == EOF)
136 {
137 GSL_ERROR ("putc failed", GSL_EFAILED);
138 }
139 }
140
141 return 0;
142 }
143
144 int
145 FUNCTION (gsl_block, raw_fscanf) (FILE * stream,
146 ATOMIC * data,
147 const size_t n,
148 const size_t stride)
149 {
150 size_t i;
151
152 for (i = 0; i < n; i++)
153 {
154 int k;
155 for (k = 0; k < MULTIPLICITY; k++)
156 {
157 ATOMIC_IO tmp;
158
159 int status = fscanf (stream, IN_FORMAT, &tmp) ;
160
161 data [MULTIPLICITY * i * stride + k] = tmp;
162
163 if (status != 1)
164 GSL_ERROR ("fscanf failed", GSL_EFAILED);
165 }
166 }
167
168 return GSL_SUCCESS;
169 }
170
171 #endif