Debian Codegraph @

external/glpk/glphbm.c

raw symbols SCIP
1 /* glphbm.c */cxx . . $ `<file>/external/glpk/glphbm.c`/
2
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
5 *
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <[email protected]>.
10 *
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
24
25 #define _GLPSTD_ERRNOcxx . . $ `external/glpk/glphbm.c:25:9`!
26 #define _GLPSTD_STDIOcxx . . $ `external/glpk/glphbm.c:26:9`!
27 #include "glphbm.h"cxx . . $ `<file>/external/glpk/glphbm.h`/
28 #include "glpenv.h"cxx . . $ `<file>/external/glpk/glpenv.h`/
29
30 /***********************************************************************
31 * NAME
32 *
33 * hbm_read_mat - read sparse matrix in Harwell-Boeing format
34 *
35 * SYNOPSIS
36 *
37 * #include "glphbm.h"
38 * HBM *hbm_read_mat(const char *fname);
39 *
40 * DESCRIPTION
41 *
42 * The routine hbm_read_mat reads a sparse matrix in the Harwell-Boeing
43 * format from a text file whose name is the character string fname.
44 *
45 * Detailed description of the Harwell-Boeing format recognised by this
46 * routine is given in the following report:
47 *
48 * I.S.Duff, R.G.Grimes, J.G.Lewis. User's Guide for the Harwell-Boeing
49 * Sparse Matrix Collection (Release I), TR/PA/92/86, October 1992.
50 *
51 * RETURNS
52 *
53 * If no error occured, the routine hbm_read_mat returns a pointer to
54 * a data structure containing the matrix. In case of error the routine
55 * prints an appropriate error message and returns NULL. */
56
57 struct dsacxx . . $ dsa#
58 { /* working area used by routine hbm_read_mat */
59 const char *fnamecxx . . $ dsa#fname.;
60 /* name of input text file */
61 FILEcxx . . $ FILE# *fpcxx . . $ dsa#fp.;
62 /* stream assigned to input text file */
63 int seqncxx . . $ dsa#seqn.;
64 /* card sequential number */
65 char cardcxx . . $ dsa#card.[80+1];
66 /* card image buffer */
67 int fmt_pcxx . . $ dsa#fmt_p.;
68 /* scale factor */
69 int fmt_kcxx . . $ dsa#fmt_k.;
70 /* iterator */
71 int fmt_fcxx . . $ dsa#fmt_f.;
72 /* format code */
73 int fmt_wcxx . . $ dsa#fmt_w.;
74 /* field width */
75 int fmt_dcxx . . $ dsa#fmt_d.;
76 /* number of decimal places after point */
77 };
78
79 /***********************************************************************
80 * read_card - read next data card
81 *
82 * This routine reads the next 80-column card from the input text file
83 * and stores its image into the character string card. If the card was
84 * read successfully, the routine returns zero, otherwise non-zero. */
85
86 static int read_cardcxx . . $ read_card(bb135ed1a6c3747c).(struct dsacxx . . $ dsa# *dsa)
87 { int k, c;
88 dsa->seqncxx . . $ dsa#seqn.++;
89 memsetcxx . . $ memset(d1de1e4fb215f1c6).(dsa->cardcxx . . $ dsa#card., ' ', 80), dsa->cardcxx . . $ dsa#card.[80] = '\0';
90 k = 0;
91 for (;;)
92 { c = fgetccxx . . $ fgetc(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.);
93 if (ferrorcxx . . $ ferror(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.))
94 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: read error - %s\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.,
95 strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
96 return 1;
97 }
98 if (feofcxx . . $ feof(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.))
99 { if (k == 0)
100 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: unexpected EOF\n", dsa->fnamecxx . . $ dsa#fname.,
101 dsa->seqncxx . . $ dsa#seqn.);
102 else
103 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: missing final LF\n", dsa->fnamecxx . . $ dsa#fname.,
104 dsa->seqncxx . . $ dsa#seqn.);
105 return 1;
106 }
107 if (c == '\r') continue;
108 if (c == '\n') break;
109 if (iscntrlcxx . . $ `<external>/17904084882347303253/ctype.h:191:10`!(c))
110 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: invalid control character 0x%02X\n",
111 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., c);
112 return 1;
113 }
114 if (k == 80)
115 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: card image too long\n", dsa->fnamecxx . . $ dsa#fname.,
116 dsa->seqncxx . . $ dsa#seqn.);
117 return 1;
118 }
119 dsa->cardcxx . . $ dsa#card.[k++] = (char)c;
120 }
121 return 0;
122 }
123
124 /***********************************************************************
125 * scan_int - scan integer value from the current card
126 *
127 * This routine scans an integer value from the current card, where fld
128 * is the name of the field, pos is the position of the field, width is
129 * the width of the field, val points to a location to which the scanned
130 * value should be stored. If the value was scanned successfully, the
131 * routine returns zero, otherwise non-zero. */
132
133 static int scan_intcxx . . $ scan_int(f010c8995d556b3d).(struct dsacxx . . $ dsa# *dsa, char *fld, int pos, int width,
134 int *val)
135 { char str[80+1];
136 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(1 <= width && width <= 80);
137 memcpycxx . . $ memcpy(cc817cb175f282d).(str, dsa->cardcxx . . $ dsa#card. + pos, width), str[width] = '\0';
138 if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(strspxcxx . . $ `external/glpk/glplib.h:89:9`!(str), val))
139 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: field `%s' contains invalid value `%s'\n",
140 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., fld, str);
141 return 1;
142 }
143 return 0;
144 }
145
146 /***********************************************************************
147 * parse_fmt - parse Fortran format specification
148 *
149 * This routine parses the Fortran format specification represented as
150 * character string which fmt points to and stores format elements into
151 * appropriate static locations. Should note that not all valid Fortran
152 * format specifications may be recognised. If the format specification
153 * was recognised, the routine returns zero, otherwise non-zero. */
154
155 static int parse_fmtcxx . . $ parse_fmt(bbef030a4aa67541).(struct dsacxx . . $ dsa# *dsa, char *fmt)
156 { int k, s, val;
157 char str[80+1];
158 /* first character should be left parenthesis */
159 if (fmt[0] != '(')
160 fail: { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("hbm_read_mat: format `%s' not recognised\n", fmt);
161 return 1;
162 }
163 k = 1;
164 /* optional scale factor */
165 dsa->fmt_pcxx . . $ dsa#fmt_p. = 0;
166 if (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k]))
167 { s = 0;
168 while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k]))
169 { if (s == 80) goto fail;
170 str[s++] = fmt[k++];
171 }
172 str[s] = '\0';
173 if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(str, &val)) goto fail;
174 if (touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!((unsigned char)fmt[k]) != 'P') goto iter;
175 dsa->fmt_pcxx . . $ dsa#fmt_p. = val, k++;
176 if (!(0 <= dsa->fmt_pcxx . . $ dsa#fmt_p. && dsa->fmt_pcxx . . $ dsa#fmt_p. <= 255)) goto fail;
177 /* optional comma may follow scale factor */
178 if (fmt[k] == ',') k++;
179 }
180 /* optional iterator */
181 dsa->fmt_kcxx . . $ dsa#fmt_k. = 1;
182 if (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k]))
183 { s = 0;
184 while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k]))
185 { if (s == 80) goto fail;
186 str[s++] = fmt[k++];
187 }
188 str[s] = '\0';
189 if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(str, &val)) goto fail;
190 iter: dsa->fmt_kcxx . . $ dsa#fmt_k. = val;
191 if (!(1 <= dsa->fmt_kcxx . . $ dsa#fmt_k. && dsa->fmt_kcxx . . $ dsa#fmt_k. <= 255)) goto fail;
192 }
193 /* format code */
194 dsa->fmt_fcxx . . $ dsa#fmt_f. = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!((unsigned char)fmt[k++]);
195 if (!(dsa->fmt_fcxx . . $ dsa#fmt_f. == 'D' || dsa->fmt_fcxx . . $ dsa#fmt_f. == 'E' ||
196 dsa->fmt_fcxx . . $ dsa#fmt_f. == 'F' || dsa->fmt_fcxx . . $ dsa#fmt_f. == 'G' ||
197 dsa->fmt_fcxx . . $ dsa#fmt_f. == 'I')) goto fail;
198 /* field width */
199 if (!isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k])) goto fail;
200 s = 0;
201 while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k]))
202 { if (s == 80) goto fail;
203 str[s++] = fmt[k++];
204 }
205 str[s] = '\0';
206 if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(str, &dsa->fmt_wcxx . . $ dsa#fmt_w.)) goto fail;
207 if (!(1 <= dsa->fmt_wcxx . . $ dsa#fmt_w. && dsa->fmt_wcxx . . $ dsa#fmt_w. <= 255)) goto fail;
208 /* optional number of decimal places after point */
209 dsa->fmt_dcxx . . $ dsa#fmt_d. = 0;
210 if (fmt[k] == '.')
211 { k++;
212 if (!isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k])) goto fail;
213 s = 0;
214 while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!((unsigned char)fmt[k]))
215 { if (s == 80) goto fail;
216 str[s++] = fmt[k++];
217 }
218 str[s] = '\0';
219 if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(str, &dsa->fmt_dcxx . . $ dsa#fmt_d.)) goto fail;
220 if (!(0 <= dsa->fmt_dcxx . . $ dsa#fmt_d. && dsa->fmt_dcxx . . $ dsa#fmt_d. <= 255)) goto fail;
221 }
222 /* last character should be right parenthesis */
223 if (!(fmt[k] == ')' && fmt[k+1] == '\0')) goto fail;
224 return 0;
225 }
226
227 /***********************************************************************
228 * read_int_array - read array of integer type
229 *
230 * This routine reads an integer array from the input text file, where
231 * name is array name, fmt is Fortran format specification that controls
232 * reading, n is number of array elements, val is array of integer type.
233 * If the array was read successful, the routine returns zero, otherwise
234 * non-zero. */
235
236 static int read_int_arraycxx . . $ read_int_array(d7e159c90e144c65).(struct dsacxx . . $ dsa# *dsa, char *name, char *fmt,
237 int n, int val[])
238 { int k, pos;
239 char str[80+1];
240 if (parse_fmtcxx . . $ parse_fmt(bbef030a4aa67541).(dsa, fmt)) return 1;
241 if (!(dsa->fmt_fcxx . . $ dsa#fmt_f. == 'I' && dsa->fmt_wcxx . . $ dsa#fmt_w. <= 80 &&
242 dsa->fmt_kcxx . . $ dsa#fmt_k. * dsa->fmt_wcxx . . $ dsa#fmt_w. <= 80))
243 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!(
244 "%s:%d: can't read array `%s' - invalid format `%s'\n",
245 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., name, fmt);
246 return 1;
247 }
248 for (k = 1, pos = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; k <= n; k++, pos++)
249 { if (pos >= dsa->fmt_kcxx . . $ dsa#fmt_k.)
250 { if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) return 1;
251 pos = 0;
252 }
253 memcpycxx . . $ memcpy(cc817cb175f282d).(str, dsa->cardcxx . . $ dsa#card. + dsa->fmt_wcxx . . $ dsa#fmt_w. * pos, dsa->fmt_wcxx . . $ dsa#fmt_w.);
254 str[dsa->fmt_wcxx . . $ dsa#fmt_w.] = '\0';
255 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(str);
256 if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(str, &val[k]))
257 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!(
258 "%s:%d: can't read array `%s' - invalid value `%s'\n",
259 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., name, str);
260 return 1;
261 }
262 }
263 return 0;
264 }
265
266 /***********************************************************************
267 * read_real_array - read array of real type
268 *
269 * This routine reads a real array from the input text file, where name
270 * is array name, fmt is Fortran format specification that controls
271 * reading, n is number of array elements, val is array of real type.
272 * If the array was read successful, the routine returns zero, otherwise
273 * non-zero. */
274
275 static int read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(struct dsacxx . . $ dsa# *dsa, char *name, char *fmt,
276 int n, double val[])
277 { int k, pos;
278 char str[80+1], *ptr;
279 if (parse_fmtcxx . . $ parse_fmt(bbef030a4aa67541).(dsa, fmt)) return 1;
280 if (!(dsa->fmt_fcxx . . $ dsa#fmt_f. != 'I' && dsa->fmt_wcxx . . $ dsa#fmt_w. <= 80 &&
281 dsa->fmt_kcxx . . $ dsa#fmt_k. * dsa->fmt_wcxx . . $ dsa#fmt_w. <= 80))
282 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!(
283 "%s:%d: can't read array `%s' - invalid format `%s'\n",
284 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., name, fmt);
285 return 1;
286 }
287 for (k = 1, pos = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; k <= n; k++, pos++)
288 { if (pos >= dsa->fmt_kcxx . . $ dsa#fmt_k.)
289 { if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) return 1;
290 pos = 0;
291 }
292 memcpycxx . . $ memcpy(cc817cb175f282d).(str, dsa->cardcxx . . $ dsa#card. + dsa->fmt_wcxx . . $ dsa#fmt_w. * pos, dsa->fmt_wcxx . . $ dsa#fmt_w.);
293 str[dsa->fmt_wcxx . . $ dsa#fmt_w.] = '\0';
294 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(str);
295 if (strchrcxx . . $ strchr(2050848944e00d54).(str, '.') == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(str, "0"))
296 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s(%d): can't read array `%s' - value `%s' has no "
297 "decimal point\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., name, str);
298 return 1;
299 }
300 /* sometimes lower case letters appear */
301 for (ptr = str; *ptr; ptr++)
302 *ptr = (char)touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!((unsigned char)*ptr);
303 ptr = strchrcxx . . $ strchr(2050848944e00d54).(str, 'D');
304 if (ptr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) *ptr = 'E';
305 /* value may appear with decimal exponent but without letters
306 E or D (for example, -123.456-012), so missing letter should
307 be inserted */
308 ptr = strchrcxx . . $ strchr(2050848944e00d54).(str+1, '+');
309 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ptr = strchrcxx . . $ strchr(2050848944e00d54).(str+1, '-');
310 if (ptr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && *(ptr-1) != 'E')
311 { xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(strlen(str) < 80);
312 memmovecxx . . $ memmove(cc817cb175f282d).(ptr+1, ptr, strlencxx . . $ strlen(751346f8406fd082).(ptr)+1);
313 *ptr = 'E';
314 }
315 if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(str, &val[k]))
316 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!(
317 "%s:%d: can't read array `%s' - invalid value `%s'\n",
318 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., name, str);
319 return 1;
320 }
321 }
322 return 0;
323 }
324
325 HBMcxx . . $ HBM# *hbm_read_matcxx . . $ `external/glpk/glphbm.h:117:9`!(const char *fname)
326 { struct dsacxx . . $ dsa# _dsa, *dsa = &_dsa;
327 HBMcxx . . $ HBM# *hbm = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
328 dsa->fnamecxx . . $ dsa#fname. = fname;
329 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("hbm_read_mat: reading matrix from `%s'...\n",
330 dsa->fnamecxx . . $ dsa#fname.);
331 dsa->fpcxx . . $ dsa#fp. = fopencxx . . $ fopen(82ec0787cd37e0a3).(dsa->fnamecxx . . $ dsa#fname., "r");
332 if (dsa->fpcxx . . $ dsa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
333 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("hbm_read_mat: unable to open `%s' - %s\n",
334 dsa->fnamecxx . . $ dsa#fname., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
335 goto fail;
336 }
337 dsa->seqncxx . . $ dsa#seqn. = 0;
338 hbm = xmalloccxx . . $ `external/glpk/glpenv.h:167:9`!(sizeof(HBMcxx . . $ HBM#));
339 memsetcxx . . $ memset(d1de1e4fb215f1c6).(hbm, 0, sizeof(HBMcxx . . $ HBM#));
340 /* read the first heading card */
341 if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) goto fail;
342 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->titlecxx . . $ HBM#title., dsa->cardcxx . . $ dsa#card., 72), hbm->titlecxx . . $ HBM#title.[72] = '\0';
343 strtrimcxx . . $ `external/glpk/glplib.h:93:9`!(hbm->titlecxx . . $ HBM#title.);
344 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s\n", hbm->titlecxx . . $ HBM#title.);
345 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->keycxx . . $ HBM#key., dsa->cardcxx . . $ dsa#card.+72, 8), hbm->keycxx . . $ HBM#key.[8] = '\0';
346 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(hbm->keycxx . . $ HBM#key.);
347 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("key = %s\n", hbm->keycxx . . $ HBM#key.);
348 /* read the second heading card */
349 if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) goto fail;
350 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "totcrd", 0, 14, &hbm->totcrdcxx . . $ HBM#totcrd.)) goto fail;
351 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "ptrcrd", 14, 14, &hbm->ptrcrdcxx . . $ HBM#ptrcrd.)) goto fail;
352 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "indcrd", 28, 14, &hbm->indcrdcxx . . $ HBM#indcrd.)) goto fail;
353 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "valcrd", 42, 14, &hbm->valcrdcxx . . $ HBM#valcrd.)) goto fail;
354 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "rhscrd", 56, 14, &hbm->rhscrdcxx . . $ HBM#rhscrd.)) goto fail;
355 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("totcrd = %d; ptrcrd = %d; indcrd = %d; valcrd = %d; rhsc"
356 "rd = %d\n", hbm->totcrdcxx . . $ HBM#totcrd., hbm->ptrcrdcxx . . $ HBM#ptrcrd., hbm->indcrdcxx . . $ HBM#indcrd.,
357 hbm->valcrdcxx . . $ HBM#valcrd., hbm->rhscrdcxx . . $ HBM#rhscrd.);
358 /* read the third heading card */
359 if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) goto fail;
360 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->mxtypecxx . . $ HBM#mxtype., dsa->cardcxx . . $ dsa#card., 3), hbm->mxtypecxx . . $ HBM#mxtype.[3] = '\0';
361 if (strchrcxx . . $ strchr(2050848944e00d54).("RCP", hbm->mxtypecxx . . $ HBM#mxtype.[0]) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ||
362 strchrcxx . . $ strchr(2050848944e00d54).("SUHZR", hbm->mxtypecxx . . $ HBM#mxtype.[1]) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ||
363 strchrcxx . . $ strchr(2050848944e00d54).("AE", hbm->mxtypecxx . . $ HBM#mxtype.[2]) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
364 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: matrix type `%s' not recognised\n",
365 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., hbm->mxtypecxx . . $ HBM#mxtype.);
366 goto fail;
367 }
368 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "nrow", 14, 14, &hbm->nrowcxx . . $ HBM#nrow.)) goto fail;
369 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "ncol", 28, 14, &hbm->ncolcxx . . $ HBM#ncol.)) goto fail;
370 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "nnzero", 42, 14, &hbm->nnzerocxx . . $ HBM#nnzero.)) goto fail;
371 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "neltvl", 56, 14, &hbm->neltvlcxx . . $ HBM#neltvl.)) goto fail;
372 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("mxtype = %s; nrow = %d; ncol = %d; nnzero = %d; neltvl ="
373 " %d\n", hbm->mxtypecxx . . $ HBM#mxtype., hbm->nrowcxx . . $ HBM#nrow., hbm->ncolcxx . . $ HBM#ncol., hbm->nnzerocxx . . $ HBM#nnzero.,
374 hbm->neltvlcxx . . $ HBM#neltvl.);
375 /* read the fourth heading card */
376 if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) goto fail;
377 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->ptrfmtcxx . . $ HBM#ptrfmt., dsa->cardcxx . . $ dsa#card., 16), hbm->ptrfmtcxx . . $ HBM#ptrfmt.[16] = '\0';
378 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(hbm->ptrfmtcxx . . $ HBM#ptrfmt.);
379 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->indfmtcxx . . $ HBM#indfmt., dsa->cardcxx . . $ dsa#card.+16, 16), hbm->indfmtcxx . . $ HBM#indfmt.[16] = '\0';
380 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(hbm->indfmtcxx . . $ HBM#indfmt.);
381 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->valfmtcxx . . $ HBM#valfmt., dsa->cardcxx . . $ dsa#card.+32, 20), hbm->valfmtcxx . . $ HBM#valfmt.[20] = '\0';
382 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(hbm->valfmtcxx . . $ HBM#valfmt.);
383 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->rhsfmtcxx . . $ HBM#rhsfmt., dsa->cardcxx . . $ dsa#card.+52, 20), hbm->rhsfmtcxx . . $ HBM#rhsfmt.[20] = '\0';
384 strspxcxx . . $ `external/glpk/glplib.h:89:9`!(hbm->rhsfmtcxx . . $ HBM#rhsfmt.);
385 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("ptrfmt = %s; indfmt = %s; valfmt = %s; rhsfmt = %s\n",
386 hbm->ptrfmtcxx . . $ HBM#ptrfmt., hbm->indfmtcxx . . $ HBM#indfmt., hbm->valfmtcxx . . $ HBM#valfmt., hbm->rhsfmtcxx . . $ HBM#rhsfmt.);
387 /* read the fifth heading card (optional) */
388 if (hbm->rhscrdcxx . . $ HBM#rhscrd. <= 0)
389 { strcpycxx . . $ strcpy(b7b3a83273496486).(hbm->rhstypcxx . . $ HBM#rhstyp., "???");
390 hbm->nrhscxx . . $ HBM#nrhs. = 0;
391 hbm->nrhsixcxx . . $ HBM#nrhsix. = 0;
392 }
393 else
394 { if (read_cardcxx . . $ read_card(bb135ed1a6c3747c).(dsa)) goto fail;
395 memcpycxx . . $ memcpy(cc817cb175f282d).(hbm->rhstypcxx . . $ HBM#rhstyp., dsa->cardcxx . . $ dsa#card., 3), hbm->rhstypcxx . . $ HBM#rhstyp.[3] = '\0';
396 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "nrhs", 14, 14, &hbm->nrhscxx . . $ HBM#nrhs.)) goto fail;
397 if (scan_intcxx . . $ scan_int(f010c8995d556b3d).(dsa, "nrhsix", 28, 14, &hbm->nrhsixcxx . . $ HBM#nrhsix.)) goto fail;
398 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("rhstyp = `%s'; nrhs = %d; nrhsix = %d\n",
399 hbm->rhstypcxx . . $ HBM#rhstyp., hbm->nrhscxx . . $ HBM#nrhs., hbm->nrhsixcxx . . $ HBM#nrhsix.);
400 }
401 /* read matrix structure */
402 hbm->colptrcxx . . $ HBM#colptr. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->ncolcxx . . $ HBM#ncol.+1, sizeof(int));
403 if (read_int_arraycxx . . $ read_int_array(d7e159c90e144c65).(dsa, "colptr", hbm->ptrfmtcxx . . $ HBM#ptrfmt., hbm->ncolcxx . . $ HBM#ncol.+1,
404 hbm->colptrcxx . . $ HBM#colptr.)) goto fail;
405 hbm->rowindcxx . . $ HBM#rowind. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nnzerocxx . . $ HBM#nnzero., sizeof(int));
406 if (read_int_arraycxx . . $ read_int_array(d7e159c90e144c65).(dsa, "rowind", hbm->indfmtcxx . . $ HBM#indfmt., hbm->nnzerocxx . . $ HBM#nnzero.,
407 hbm->rowindcxx . . $ HBM#rowind.)) goto fail;
408 /* read matrix values */
409 if (hbm->valcrdcxx . . $ HBM#valcrd. <= 0) goto done;
410 if (hbm->mxtypecxx . . $ HBM#mxtype.[2] == 'A')
411 { /* assembled matrix */
412 hbm->valuescxx . . $ HBM#values. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nnzerocxx . . $ HBM#nnzero., sizeof(double));
413 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "values", hbm->valfmtcxx . . $ HBM#valfmt., hbm->nnzerocxx . . $ HBM#nnzero.,
414 hbm->valuescxx . . $ HBM#values.)) goto fail;
415 }
416 else
417 { /* elemental (unassembled) matrix */
418 hbm->valuescxx . . $ HBM#values. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->neltvlcxx . . $ HBM#neltvl., sizeof(double));
419 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "values", hbm->valfmtcxx . . $ HBM#valfmt., hbm->neltvlcxx . . $ HBM#neltvl.,
420 hbm->valuescxx . . $ HBM#values.)) goto fail;
421 }
422 /* read right-hand sides */
423 if (hbm->nrhscxx . . $ HBM#nrhs. <= 0) goto done;
424 if (hbm->rhstypcxx . . $ HBM#rhstyp.[0] == 'F')
425 { /* dense format */
426 hbm->nrhsvlcxx . . $ HBM#nrhsvl. = hbm->nrowcxx . . $ HBM#nrow. * hbm->nrhscxx . . $ HBM#nrhs.;
427 hbm->rhsvalcxx . . $ HBM#rhsval. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nrhsvlcxx . . $ HBM#nrhsvl., sizeof(double));
428 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "rhsval", hbm->rhsfmtcxx . . $ HBM#rhsfmt., hbm->nrhsvlcxx . . $ HBM#nrhsvl.,
429 hbm->rhsvalcxx . . $ HBM#rhsval.)) goto fail;
430 }
431 else if (hbm->rhstypcxx . . $ HBM#rhstyp.[0] == 'M' && hbm->mxtypecxx . . $ HBM#mxtype.[2] == 'A')
432 { /* sparse format */
433 /* read pointers */
434 hbm->rhsptrcxx . . $ HBM#rhsptr. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nrhscxx . . $ HBM#nrhs.+1, sizeof(int));
435 if (read_int_arraycxx . . $ read_int_array(d7e159c90e144c65).(dsa, "rhsptr", hbm->ptrfmtcxx . . $ HBM#ptrfmt., hbm->nrhscxx . . $ HBM#nrhs.+1,
436 hbm->rhsptrcxx . . $ HBM#rhsptr.)) goto fail;
437 /* read sparsity pattern */
438 hbm->rhsindcxx . . $ HBM#rhsind. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nrhsixcxx . . $ HBM#nrhsix., sizeof(int));
439 if (read_int_arraycxx . . $ read_int_array(d7e159c90e144c65).(dsa, "rhsind", hbm->indfmtcxx . . $ HBM#indfmt., hbm->nrhsixcxx . . $ HBM#nrhsix.,
440 hbm->rhsindcxx . . $ HBM#rhsind.)) goto fail;
441 /* read values */
442 hbm->rhsvalcxx . . $ HBM#rhsval. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nrhsixcxx . . $ HBM#nrhsix., sizeof(double));
443 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "rhsval", hbm->rhsfmtcxx . . $ HBM#rhsfmt., hbm->nrhsixcxx . . $ HBM#nrhsix.,
444 hbm->rhsvalcxx . . $ HBM#rhsval.)) goto fail;
445 }
446 else if (hbm->rhstypcxx . . $ HBM#rhstyp.[0] == 'M' && hbm->mxtypecxx . . $ HBM#mxtype.[2] == 'E')
447 { /* elemental format */
448 hbm->rhsvalcxx . . $ HBM#rhsval. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nrhsvlcxx . . $ HBM#nrhsvl., sizeof(double));
449 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "rhsval", hbm->rhsfmtcxx . . $ HBM#rhsfmt., hbm->nrhsvlcxx . . $ HBM#nrhsvl.,
450 hbm->rhsvalcxx . . $ HBM#rhsval.)) goto fail;
451 }
452 else
453 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: right-hand side type `%c' not recognised\n",
454 dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., hbm->rhstypcxx . . $ HBM#rhstyp.[0]);
455 goto fail;
456 }
457 /* read starting guesses */
458 if (hbm->rhstypcxx . . $ HBM#rhstyp.[1] == 'G')
459 { hbm->nguesscxx . . $ HBM#nguess. = hbm->nrowcxx . . $ HBM#nrow. * hbm->nrhscxx . . $ HBM#nrhs.;
460 hbm->sguesscxx . . $ HBM#sguess. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nguesscxx . . $ HBM#nguess., sizeof(double));
461 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "sguess", hbm->rhsfmtcxx . . $ HBM#rhsfmt., hbm->nguesscxx . . $ HBM#nguess.,
462 hbm->sguesscxx . . $ HBM#sguess.)) goto fail;
463 }
464 /* read solution vectors */
465 if (hbm->rhstypcxx . . $ HBM#rhstyp.[2] == 'X')
466 { hbm->nexactcxx . . $ HBM#nexact. = hbm->nrowcxx . . $ HBM#nrow. * hbm->nrhscxx . . $ HBM#nrhs.;
467 hbm->xexactcxx . . $ HBM#xexact. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+hbm->nexactcxx . . $ HBM#nexact., sizeof(double));
468 if (read_real_arraycxx . . $ read_real_array(53e07bf148eaa164).(dsa, "xexact", hbm->rhsfmtcxx . . $ HBM#rhsfmt., hbm->nexactcxx . . $ HBM#nexact.,
469 hbm->xexactcxx . . $ HBM#xexact.)) goto fail;
470 }
471 done: /* reading has been completed */
472 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("hbm_read_mat: %d cards were read\n", dsa->seqncxx . . $ dsa#seqn.);
473 fclosecxx . . $ fclose(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.);
474 return hbm;
475 fail: /* something wrong in Danish kingdom */
476 if (hbm != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
477 { if (hbm->colptrcxx . . $ HBM#colptr. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->colptrcxx . . $ HBM#colptr.);
478 if (hbm->rowindcxx . . $ HBM#rowind. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rowindcxx . . $ HBM#rowind.);
479 if (hbm->rhsptrcxx . . $ HBM#rhsptr. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rhsptrcxx . . $ HBM#rhsptr.);
480 if (hbm->rhsindcxx . . $ HBM#rhsind. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rhsindcxx . . $ HBM#rhsind.);
481 if (hbm->valuescxx . . $ HBM#values. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->valuescxx . . $ HBM#values.);
482 if (hbm->rhsvalcxx . . $ HBM#rhsval. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rhsvalcxx . . $ HBM#rhsval.);
483 if (hbm->sguesscxx . . $ HBM#sguess. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->sguesscxx . . $ HBM#sguess.);
484 if (hbm->xexactcxx . . $ HBM#xexact. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->xexactcxx . . $ HBM#xexact.);
485 xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm);
486 }
487 if (dsa->fpcxx . . $ dsa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) fclosecxx . . $ fclose(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.);
488 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
489 }
490
491 /***********************************************************************
492 * NAME
493 *
494 * hbm_free_mat - free sparse matrix in Harwell-Boeing format
495 *
496 * SYNOPSIS
497 *
498 * #include "glphbm.h"
499 * void hbm_free_mat(HBM *hbm);
500 *
501 * DESCRIPTION
502 *
503 * The hbm_free_mat routine frees all the memory allocated to the data
504 * structure containing a sparse matrix in the Harwell-Boeing format. */
505
506 void hbm_free_matcxx . . $ `external/glpk/glphbm.h:121:9`!(HBMcxx . . $ HBM# *hbm)
507 { if (hbm->colptrcxx . . $ HBM#colptr. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->colptrcxx . . $ HBM#colptr.);
508 if (hbm->rowindcxx . . $ HBM#rowind. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rowindcxx . . $ HBM#rowind.);
509 if (hbm->rhsptrcxx . . $ HBM#rhsptr. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rhsptrcxx . . $ HBM#rhsptr.);
510 if (hbm->rhsindcxx . . $ HBM#rhsind. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rhsindcxx . . $ HBM#rhsind.);
511 if (hbm->valuescxx . . $ HBM#values. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->valuescxx . . $ HBM#values.);
512 if (hbm->rhsvalcxx . . $ HBM#rhsval. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->rhsvalcxx . . $ HBM#rhsval.);
513 if (hbm->sguesscxx . . $ HBM#sguess. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->sguesscxx . . $ HBM#sguess.);
514 if (hbm->xexactcxx . . $ HBM#xexact. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm->xexactcxx . . $ HBM#xexact.);
515 xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(hbm);
516 return;
517 }
518
519 /* eof */