42 #define MM_MAX_LINE_LENGTH 1025
43 #define MatrixMarketBanner "%%MatrixMarket"
44 #define MM_MAX_TOKEN_LENGTH 64
46 typedef char MM_typecode[4];
48 char *mm_typecode_to_str(MM_typecode matcode);
50 int mm_read_banner(FILE *f, MM_typecode *matcode);
51 int mm_read_mtx_crd_size(FILE *f,
int *M,
int *N,
int *nz);
52 int mm_read_mtx_array_size(FILE *f,
int *M,
int *N);
54 int mm_write_banner(FILE *f, MM_typecode matcode);
55 int mm_write_mtx_crd_size(FILE *f,
int M,
int N,
int nz);
56 int mm_write_mtx_array_size(FILE *f,
int M,
int N);
61 #define mm_is_matrix(typecode) ((typecode)[0]=='M')
63 #define mm_is_sparse(typecode) ((typecode)[1]=='C')
64 #define mm_is_coordinate(typecode)((typecode)[1]=='C')
65 #define mm_is_dense(typecode) ((typecode)[1]=='A')
66 #define mm_is_array(typecode) ((typecode)[1]=='A')
68 #define mm_is_complex(typecode) ((typecode)[2]=='C')
69 #define mm_is_real(typecode) ((typecode)[2]=='R')
70 #define mm_is_pattern(typecode) ((typecode)[2]=='P')
71 #define mm_is_integer(typecode) ((typecode)[2]=='I')
73 #define mm_is_symmetric(typecode)((typecode)[3]=='S')
74 #define mm_is_general(typecode) ((typecode)[3]=='G')
75 #define mm_is_skew(typecode) ((typecode)[3]=='K')
76 #define mm_is_hermitian(typecode)((typecode)[3]=='H')
78 int mm_is_valid(MM_typecode matcode);
83 #define mm_set_matrix(typecode) ((*typecode)[0]='M')
84 #define mm_set_coordinate(typecode) ((*typecode)[1]='C')
85 #define mm_set_array(typecode) ((*typecode)[1]='A')
86 #define mm_set_dense(typecode) mm_set_array(typecode)
87 #define mm_set_sparse(typecode) mm_set_coordinate(typecode)
89 #define mm_set_complex(typecode)((*typecode)[2]='C')
90 #define mm_set_real(typecode) ((*typecode)[2]='R')
91 #define mm_set_pattern(typecode)((*typecode)[2]='P')
92 #define mm_set_integer(typecode)((*typecode)[2]='I')
95 #define mm_set_symmetric(typecode)((*typecode)[3]='S')
96 #define mm_set_general(typecode)((*typecode)[3]='G')
97 #define mm_set_skew(typecode) ((*typecode)[3]='K')
98 #define mm_set_hermitian(typecode)((*typecode)[3]='H')
100 #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \
101 (*typecode)[2]=' ',(*typecode)[3]='G')
103 #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
109 #define MM_COULD_NOT_READ_FILE 11
110 #define MM_PREMATURE_EOF 12
111 #define MM_NOT_MTX 13
112 #define MM_NO_HEADER 14
113 #define MM_UNSUPPORTED_TYPE 15
114 #define MM_LINE_TOO_LONG 16
115 #define MM_COULD_NOT_WRITE_FILE 17
134 extern const char *MM_MTX_STR;
135 extern const char *MM_ARRAY_STR;
136 extern const char *MM_DENSE_STR;
137 extern const char *MM_COORDINATE_STR;
138 extern const char *MM_SPARSE_STR;
139 extern const char *MM_COMPLEX_STR;
140 extern const char *MM_REAL_STR;
141 extern const char *MM_INT_STR;
142 extern const char *MM_GENERAL_STR;
143 extern const char *MM_SYMM_STR;
144 extern const char *MM_HERM_STR;
145 extern const char *MM_SKEW_STR;
146 extern const char *MM_PATTERN_STR;
151 int mm_write_mtx_crd(
char fname[],
int M,
int N,
int nz,
int I[],
int J[],
152 double val[], MM_typecode matcode);
153 int mm_read_mtx_crd_data(FILE *f,
int M,
int N,
int nz,
int I[],
int J[],
154 double val[], MM_typecode matcode);
155 int mm_read_mtx_crd_entry(FILE *f,
int *I,
int *J,
double *real,
double *img,
156 MM_typecode matcode);
158 int mm_read_unsymmetric_sparse(
const char *fname,
int *M_,
int *N_,
int *nz_,
159 double **val_,
int **I_,
int **J_);