61 #include "Teuchos_Assert.hpp"
64 using namespace EpetraExt;
67 double **val_,
int **I_,
int **J_)
76 if ((f = fopen(fname,
"r")) == NULL)
82 printf(
"mm_read_unsymetric: Could not process Matrix Market banner ");
83 printf(
" in file [%s]\n", fname);
94 fprintf(stderr,
"Sorry, this application does not support ");
95 fprintf(stderr,
"Market Market type: [%s]\n",buffer);
103 fprintf(stderr,
"read_unsymmetric_sparse(): could not parse matrix size.\n");
119 val =
new double[nz];
131 TEUCHOS_ASSERT(fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i]) != EOF);
166 if (sscanf(line,
"%s %s %s %s %s", banner, mtx, crd, data_type,
167 storage_scheme) != 5)
170 for (p=mtx; *p!=
'\0'; *p=tolower(*p),p++);
171 for (p=crd; *p!=
'\0'; *p=tolower(*p),p++);
172 for (p=data_type; *p!=
'\0'; *p=tolower(*p),p++);
173 for (p=storage_scheme; *p!=
'\0'; *p=tolower(*p),p++);
237 fprintf(f,
"%lld %lld %lld\n", M, N, nz);
254 }
while (line[0] ==
'%');
257 if (sscanf(line,
"%d %d %d", M, N, nz) == 3)
263 num_items_read = fscanf(f,
"%d %d %d", M, N, nz);
266 while (num_items_read != 3);
284 }
while (line[0] ==
'%');
287 if (sscanf(line,
"%lld %lld %lld", M, N, nz) == 3)
293 num_items_read = fscanf(f,
"%lld %lld %lld", M, N, nz);
296 while (num_items_read != 3);
313 }
while (line[0] ==
'%');
316 if (sscanf(line,
"%d %d", M, N) == 2)
322 num_items_read = fscanf(f,
"%d %d", M, N);
325 while (num_items_read != 2);
332 fprintf(f,
"%lld %lld\n", M, N);
351 if (fscanf(f,
"%d %d %lg %lg", &I[i], &J[i], &val[2*i], &val[2*i+1])
358 if (fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i])
367 if (fscanf(f,
"%d %d", &I[i], &J[i])
382 if (fscanf(f,
"%d %d %lg %lg", I, J, real, imag)
387 if (fscanf(f,
"%d %d %lg\n", I, J, real)
408 if (fscanf(f,
"%lld %lld %lg %lg", I, J, real, imag)
413 if (fscanf(f,
"%lld %lld %lg\n", I, J, real)
443 if (strcmp(fname,
"stdin") == 0) f=stdin;
445 if ((f = fopen(fname,
"r")) == NULL)
471 *val =
new double[2*(*nz)];
474 if (ret_code != 0)
return ret_code;
479 *val =
new double[*nz];
482 if (ret_code != 0)
return ret_code;
489 if (ret_code != 0)
return ret_code;
492 if (f != stdin) fclose(f);
516 if (strcmp(fname,
"stdout") == 0)
519 if ((f = fopen(fname,
"w")) == NULL)
526 fprintf(f,
"%s\n", buffer);
529 fprintf(f,
"%d %d %d\n", M, N, nz);
534 fprintf(f,
"%d %d\n", I[i], J[i]);
538 fprintf(f,
"%d %d %20.16g\n", I[i], J[i], val[i]);
542 fprintf(f,
"%d %d %20.16g %20.16g\n", I[i], J[i], val[2*i],
546 if (f != stdout) fclose(f);
550 if (f !=stdout) fclose(f);
617 sprintf(buffer,
"%s %s %s %s", type0, type1, type2, type3);
#define mm_is_complex(typecode)
int mm_read_mtx_crd_data(FILE *f, int, int, int nz, int I[], int J[], double val[], MM_typecode matcode)
int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz)
int mm_read_mtx_array_size(FILE *f, int *M, int *N)
#define mm_set_real(typecode)
int mm_is_valid(MM_typecode matcode)
#define MatrixMarketBanner
#define mm_set_hermitian(typecode)
#define MM_COULD_NOT_WRITE_FILE
#define mm_set_dense(typecode)
#define mm_set_matrix(typecode)
#define mm_is_sparse(typecode)
int mm_write_banner(FILE *f, MM_typecode matcode)
#define mm_set_integer(typecode)
#define MM_MAX_LINE_LENGTH
#define mm_is_pattern(typecode)
#define mm_is_dense(typecode)
#define mm_set_general(typecode)
#define mm_is_skew(typecode)
#define mm_is_symmetric(typecode)
void mm_typecode_to_str(MM_typecode matcode, char *buffer)
int mm_read_banner(FILE *f, MM_typecode *matcode)
int mm_write_mtx_crd_size(FILE *f, long long M, long long N, long long nz)
#define MM_UNSUPPORTED_TYPE
int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode)
#define mm_is_hermitian(typecode)
#define mm_is_real(typecode)
#define mm_set_skew(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_set_complex(typecode)
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_is_general(typecode)
#define mm_set_symmetric(typecode)
#define mm_is_integer(typecode)
int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, double **val_, int **I_, int **J_)
#define mm_set_pattern(typecode)
#define mm_clear_typecode(typecode)
#define MM_COULD_NOT_READ_FILE
#define mm_set_sparse(typecode)
int mm_write_mtx_array_size(FILE *f, long long M, long long N)
#define MM_MAX_TOKEN_LENGTH