12 const char *base = name;
28 if (8 != fscanf(fmat,
"%s %s %s %s %s %s %s %s\n",path1, path2, MatNam1, MatNam2, Fmt, ca, cb, cn_intv) ) {
29 printf(
"warning: fscanf may not be successfully done\n");
32 count = strlen(path1);
34 memcpy(pio->
Fname1,path1,count*
sizeof(
char));
35 count = strlen(path2);
37 memcpy(pio->
Fname2,path2,count*
sizeof(
char));
39 count = strlen(MatNam1);
41 memcpy(pio->
MatNam1,MatNam1,count*
sizeof(
char));
42 count = strlen(MatNam2);
44 memcpy(pio->
MatNam2,MatNam2,count*
sizeof(
char));
46 if (strcmp(Fmt,
"HB")==0)
49 if (strcmp(Fmt,
"MM0")==0)
52 if (strcmp(Fmt,
"MM1")==0)
62 n_intv = atoi(cn_intv);
74 FILE *p = fopen(matfile,
"r");
77 printf(
"Unable to open mat file %s\n", matfile);
82 printf(
"Could not process Matrix Market banner.\n");
86 printf(
"Invalid Matrix Market file.\n");
91 printf(
"Only sparse real-valued/integer coordinate \
92 matrices are supported\n");
95 int nrow, ncol, nnz, nnz2, k, j;
99 printf(
"MM read size error !\n");
103 fprintf(stdout,
"This is not a square matrix!\n");
118 int* IR = (
int *)malloc(nnz2*
sizeof(
int));
119 int* JC = (
int *)malloc(nnz2*
sizeof(
int));
120 double* VAL = (
double *)malloc(nnz2*
sizeof(
double));
123 for (k=0; k<nnz; k++) {
124 if (fgets(line,
MAX_LINE, p) == NULL) {
return -1;};
125 for( p1 = line;
' ' == *p1; p1++ );
127 for( p2 = p1;
' ' != *p2; p2++ );
129 float tmp1 = atof(p1);
133 for( p1 = p2+1;
' ' == *p1; p1++ );
134 for( p2 = p1;
' ' != *p2; p2++ );
136 float tmp2 = atof(p1);
146 for (k=0; k<nnz; k++)
147 if (IR[k] != JC[k]) {
158 int offset = idxout - idxin;
160 for (i=0; i<nnz2; i++) {
182 for (i=0; i<argc; i++) {
183 if (argv[i][0] !=
'-') {
186 if (!strcmp(argname, argv[i]+1)) {
195 outint = (
int *) val;
196 *outint = atoi(argv[i+1]);
200 outdouble = (
double *) val;
201 *outdouble = atof(argv[i+1]);
205 outchar = (
char *) val;
206 sprintf(outchar,
"%s", argv[i+1]);
210 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)