12 const char *base = name;
28 if (6 != fscanf(fmat,
"%s %s %s %s %s %s\n",path,MatNam,Fmt, ca, cb, cn_intv)) {
29 printf(
"warning: fscanf may not be successfully done\n");
34 memcpy(pio->
Fname,path,count*
sizeof(
char));
36 count = strlen(MatNam);
38 memcpy(pio->
MatNam,MatNam,count*
sizeof(
char));
40 if (strcmp(Fmt,
"HB")==0)
43 if (strcmp(Fmt,
"MM0")==0)
46 if (strcmp(Fmt,
"MM1")==0)
56 n_intv = atoi(cn_intv);
68 FILE *p = fopen(matfile,
"r");
71 printf(
"Unable to open mat file %s\n", matfile);
76 printf(
"Could not process Matrix Market banner.\n");
80 printf(
"Invalid Matrix Market file.\n");
85 printf(
"Only sparse real-valued/integer coordinate \
86 matrices are supported\n");
89 int nrow, ncol, nnz, nnz2, k, j;
93 printf(
"MM read size error !\n");
97 fprintf(stdout,
"This is not a square matrix!\n");
112 int* IR = (
int *)malloc(nnz2*
sizeof(
int));
113 int* JC = (
int *)malloc(nnz2*
sizeof(
int));
114 double* VAL = (
double *)malloc(nnz2*
sizeof(
double));
117 for (k=0; k<nnz; k++) {
118 if (fgets(line,
MAX_LINE, p) == NULL) {
return -1;};
119 for( p1 = line;
' ' == *p1; p1++ );
121 for( p2 = p1;
' ' != *p2; p2++ );
123 float tmp1 = atof(p1);
127 for( p1 = p2+1;
' ' == *p1; p1++ );
128 for( p2 = p1;
' ' != *p2; p2++ );
130 float tmp2 = atof(p1);
140 for (k=0; k<nnz; k++)
141 if (IR[k] != JC[k]) {
152 int offset = idxout - idxin;
154 for (i=0; i<nnz2; i++) {
176 for (i=0; i<argc; i++) {
177 if (argv[i][0] !=
'-') {
180 if (!strcmp(argname, argv[i]+1)) {
189 outint = (
int *) val;
190 *outint = atoi(argv[i+1]);
194 outdouble = (
double *) val;
195 *outdouble = atof(argv[i+1]);
199 outchar = (
char *) val;
200 sprintf(outchar,
"%s", argv[i+1]);
204 printf(
"unknown arg type\n");
int findarg(const char *argname, ARG_TYPE type, void *val, int argc, char **argv)
int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz)
int mm_read_banner(FILE *f, MM_typecode *matcode)
#define mm_is_real(typecode)
#define mm_is_coordinate(typecode)
#define mm_is_sparse(typecode)
This file contains function prototypes and constant definitions for EVSL.
int mm_is_valid(MM_typecode matcode)
char * mybasename(const char *name)
#define mm_is_integer(typecode)
int read_coo_MM(const char *matfile, int idxin, int idxout, cooMat *Acoo)
int get_matrix_info(FILE *fmat, io_t *pio)
sparse matrix format: the coordinate (COO) format, 0-based
#define mm_is_symmetric(typecode)