18 double **val_,
int **I_,
int **J_)
27 if ((f = fopen(fname,
"r")) == NULL)
33 printf(
"mm_read_unsymetric: Could not process Matrix Market banner ");
34 printf(
" in file [%s]\n", fname);
43 fprintf(stderr,
"Sorry, this application does not support ");
44 fprintf(stderr,
"Market Market type: [%s]\n",
53 fprintf(stderr,
"read_unsymmetric_sparse(): could not parse matrix size.\n");
63 I = (
int *) malloc(nz *
sizeof(
int));
64 J = (
int *) malloc(nz *
sizeof(
int));
65 val = (
double *) malloc(nz *
sizeof(
double));
77 fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i]);
112 if (sscanf(line,
"%s %s %s %s %s", banner, mtx, crd, data_type,
113 storage_scheme) != 5)
116 for (p=mtx; *p!=
'\0'; *p=tolower(*p),p++);
117 for (p=crd; *p!=
'\0'; *p=tolower(*p),p++);
118 for (p=data_type; *p!=
'\0'; *p=tolower(*p),p++);
119 for (p=storage_scheme; *p!=
'\0'; *p=tolower(*p),p++);
183 if (fprintf(f,
"%d %d %d\n", M, N, nz) != 3)
202 }
while (line[0] ==
'%');
205 if (sscanf(line,
"%d %d %d", M, N, nz) == 3)
211 num_items_read = fscanf(f,
"%d %d %d", M, N, nz);
214 while (num_items_read != 3);
232 }
while (line[0] ==
'%');
235 if (sscanf(line,
"%d %d", M, N) == 2)
241 num_items_read = fscanf(f,
"%d %d", M, N);
244 while (num_items_read != 2);
251 if (fprintf(f,
"%d %d\n", M, N) != 2)
272 if (fscanf(f,
"%d %d %lg %lg", &I[i], &J[i], &val[2*i], &val[2*i+1])
279 if (fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i])
288 if (fscanf(f,
"%d %d", &I[i], &J[i])
303 if (fscanf(f,
"%d %d %lg %lg", I, J, real, imag)
308 if (fscanf(f,
"%d %d %lg\n", I, J, real)
339 if (strcmp(fname,
"stdin") == 0) f=stdin;
341 if ((f = fopen(fname,
"r")) == NULL)
356 *I = (
int *) malloc(*nz *
sizeof(
int));
357 *J = (
int *) malloc(*nz *
sizeof(
int));
362 *val = (
double *) malloc(*nz * 2 *
sizeof(
double));
365 if (ret_code != 0)
return ret_code;
369 *val = (
double *) malloc(*nz *
sizeof(
double));
372 if (ret_code != 0)
return ret_code;
379 if (ret_code != 0)
return ret_code;
382 if (f != stdin) fclose(f);
405 if (strcmp(fname,
"stdout") == 0)
408 if ((f = fopen(fname,
"w")) == NULL)
416 fprintf(f,
"%d %d %d\n", M, N, nz);
421 fprintf(f,
"%d %d\n", I[i], J[i]);
425 fprintf(f,
"%d %d %20.16g\n", I[i], J[i], val[i]);
429 fprintf(f,
"%d %d %20.16g %20.16g\n", I[i], J[i], val[2*i],
433 if (f != stdout) fclose(f);
437 if (f !=stdout) fclose(f);
451 char *s2 = (
char *) malloc((len+1)*
sizeof(char));
452 return strcpy(s2, s);
458 const char *types[4];
508 sprintf(buffer,
"%s %s %s %s", types[0], types[1], types[2], types[3]);