17 double **val_,
int **I_,
int **J_)
26 if ((f = fopen(fname,
"r")) == NULL)
30 printf(
"mm_read_unsymetric: Could not process Matrix Market banner ");
31 printf(
" in file [%s]\n", fname);
38 fprintf(stderr,
"Sorry, this application does not support ");
39 fprintf(stderr,
"Market Market type: [%s]\n",
48 fprintf(stderr,
"read_unsymmetric_sparse(): could not parse matrix size.\n");
58 I = (
int *) malloc(nz *
sizeof(
int));
59 J = (
int *) malloc(nz *
sizeof(
int));
60 val = (
double *) malloc(nz *
sizeof(
double));
70 for (i=0; i<nz; i++) {
71 if (3 != fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i])) {
72 printf(
"warning: fscanf may not be successfully done\n");
107 if (sscanf(line,
"%s %s %s %s %s", banner, mtx, crd, data_type,
108 storage_scheme) != 5)
111 for (p=mtx; *p!=
'\0'; *p=tolower(*p),p++);
112 for (p=crd; *p!=
'\0'; *p=tolower(*p),p++);
113 for (p=data_type; *p!=
'\0'; *p=tolower(*p),p++);
114 for (p=storage_scheme; *p!=
'\0'; *p=tolower(*p),p++);
178 if (fprintf(f,
"%d %d %d\n", M, N, nz) != 3)
197 }
while (line[0] ==
'%');
200 if (sscanf(line,
"%d %d %d", M, N, nz) == 3)
206 num_items_read = fscanf(f,
"%d %d %d", M, N, nz);
209 while (num_items_read != 3);
227 }
while (line[0] ==
'%');
230 if (sscanf(line,
"%d %d", M, N) == 2)
236 num_items_read = fscanf(f,
"%d %d", M, N);
239 while (num_items_read != 2);
246 if (fprintf(f,
"%d %d\n", M, N) != 2)
267 if (fscanf(f,
"%d %d %lg %lg", &I[i], &J[i], &val[2*i], &val[2*i+1])
274 if (fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i])
283 if (fscanf(f,
"%d %d", &I[i], &J[i])
298 if (fscanf(f,
"%d %d %lg %lg", I, J, real, imag)
303 if (fscanf(f,
"%d %d %lg\n", I, J, real)
334 if (strcmp(fname,
"stdin") == 0) f=stdin;
336 if ((f = fopen(fname,
"r")) == NULL)
351 *I = (
int *) malloc(*nz *
sizeof(
int));
352 *J = (
int *) malloc(*nz *
sizeof(
int));
357 *val = (
double *) malloc(*nz * 2 *
sizeof(
double));
360 if (ret_code != 0)
return ret_code;
364 *val = (
double *) malloc(*nz *
sizeof(
double));
367 if (ret_code != 0)
return ret_code;
374 if (ret_code != 0)
return ret_code;
377 if (f != stdin) fclose(f);
400 if (strcmp(fname,
"stdout") == 0)
403 if ((f = fopen(fname,
"w")) == NULL)
411 fprintf(f,
"%d %d %d\n", M, N, nz);
416 fprintf(f,
"%d %d\n", I[i], J[i]);
420 fprintf(f,
"%d %d %20.16g\n", I[i], J[i], val[i]);
424 fprintf(f,
"%d %d %20.16g %20.16g\n", I[i], J[i], val[2*i],
428 if (f != stdout) fclose(f);
432 if (f !=stdout) fclose(f);
446 char *s2 = (
char *) malloc((len+1)*
sizeof(char));
447 return strcpy(s2, s);
503 sprintf(buffer,
"%s %s %s %s", types[0], types[1], types[2], types[3]);
#define mm_is_pattern(typecode)
#define MM_MAX_LINE_LENGTH
#define mm_clear_typecode(typecode)
#define mm_set_real(typecode)
#define mm_set_pattern(typecode)
#define MM_UNSUPPORTED_TYPE
#define mm_set_complex(typecode)
#define mm_set_matrix(typecode)
int mm_write_banner(FILE *f, MM_typecode matcode)
#define mm_set_dense(typecode)
#define mm_is_dense(typecode)
#define mm_is_skew(typecode)
int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz)
#define MatrixMarketBanner
#define mm_set_hermitian(typecode)
char * mm_strdup(const char *s)
#define MM_MAX_TOKEN_LENGTH
#define mm_set_skew(typecode)
int mm_read_banner(FILE *f, MM_typecode *matcode)
#define mm_set_general(typecode)
#define mm_is_general(typecode)
#define mm_is_real(typecode)
int mm_read_mtx_array_size(FILE *f, int *M, int *N)
#define mm_is_sparse(typecode)
#define mm_is_hermitian(typecode)
#define MM_COULD_NOT_READ_FILE
int mm_is_valid(MM_typecode matcode)
int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode)
int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, double **val_, int **I_, int **J_)
char * mm_typecode_to_str(MM_typecode matcode)
int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode)
#define mm_is_integer(typecode)
int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz)
int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *imag, MM_typecode matcode)
#define mm_is_matrix(typecode)
#define mm_set_symmetric(typecode)
int mm_read_mtx_crd(char *fname, int *M, int *N, int *nz, int **I, int **J, double **val, MM_typecode *matcode)
#define MM_COULD_NOT_WRITE_FILE
#define mm_is_complex(typecode)
int mm_write_mtx_array_size(FILE *f, int M, int N)
#define mm_is_symmetric(typecode)
#define mm_set_sparse(typecode)
#define mm_set_integer(typecode)