CSS product code  0.1
C++ library to estimate distance of CSS codes. Some particular construction of CSS codes are implemented.
mmio.h
Go to the documentation of this file.
1 /*
2 * Matrix Market I/O library for ANSI C
3 *
4 * See http://math.nist.gov/MatrixMarket for details.
5 *
6 *
7 */
8 
9 #ifndef MM_IO_H
10 #define MM_IO_H
11 
12 
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include <ctype.h>
17 
18 
19 #define MM_MAX_LINE_LENGTH 1025
20 #define MatrixMarketBanner "%%MatrixMarket"
21 #define MM_MAX_TOKEN_LENGTH 64
22 
23 typedef char MM_typecode[4];
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 char *mm_typecode_to_str(MM_typecode matcode);
30 
31 int mm_read_banner(FILE *f, MM_typecode *matcode);
32 int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz);
33 int mm_read_mtx_array_size(FILE *f, int *M, int *N);
34 
35 int mm_write_banner(FILE *f, MM_typecode matcode);
36 int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz);
37 int mm_write_mtx_array_size(FILE *f, int M, int N);
38 
39 
40 #ifdef __cplusplus
41  }
42 #endif
43 
44 /********************* MM_typecode query fucntions ***************************/
45 
46 #define mm_is_matrix(typecode) ((typecode)[0]=='M')
47 
48 #define mm_is_sparse(typecode) ((typecode)[1]=='C')
49 #define mm_is_coordinate(typecode)((typecode)[1]=='C')
50 #define mm_is_dense(typecode) ((typecode)[1]=='A')
51 #define mm_is_array(typecode) ((typecode)[1]=='A')
52 
53 #define mm_is_complex(typecode) ((typecode)[2]=='C')
54 #define mm_is_real(typecode) ((typecode)[2]=='R')
55 #define mm_is_pattern(typecode) ((typecode)[2]=='P')
56 #define mm_is_integer(typecode) ((typecode)[2]=='I')
57 
58 #define mm_is_symmetric(typecode)((typecode)[3]=='S')
59 #define mm_is_general(typecode) ((typecode)[3]=='G')
60 #define mm_is_skew(typecode) ((typecode)[3]=='K')
61 #define mm_is_hermitian(typecode)((typecode)[3]=='H')
62 
63 int mm_is_valid(MM_typecode matcode); /* too complex for a macro */
64 
65 
66 /********************* MM_typecode modify fucntions ***************************/
67 
68 #define mm_set_matrix(typecode) ((*typecode)[0]='M')
69 #define mm_set_coordinate(typecode) ((*typecode)[1]='C')
70 #define mm_set_array(typecode) ((*typecode)[1]='A')
71 #define mm_set_dense(typecode) mm_set_array(typecode)
72 #define mm_set_sparse(typecode) mm_set_coordinate(typecode)
73 
74 #define mm_set_complex(typecode)((*typecode)[2]='C')
75 #define mm_set_real(typecode) ((*typecode)[2]='R')
76 #define mm_set_pattern(typecode)((*typecode)[2]='P')
77 #define mm_set_integer(typecode)((*typecode)[2]='I')
78 
79 
80 #define mm_set_symmetric(typecode)((*typecode)[3]='S')
81 #define mm_set_general(typecode)((*typecode)[3]='G')
82 #define mm_set_skew(typecode) ((*typecode)[3]='K')
83 #define mm_set_hermitian(typecode)((*typecode)[3]='H')
84 
85 #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \
86  (*typecode)[2]=' ',(*typecode)[3]='G')
87 
88 #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
89 
90 
91 /********************* Matrix Market error codes ***************************/
92 
93 
94 #define MM_COULD_NOT_READ_FILE 11
95 #define MM_PREMATURE_EOF 12
96 #define MM_NOT_MTX 13
97 #define MM_NO_HEADER 14
98 #define MM_UNSUPPORTED_TYPE 15
99 #define MM_LINE_TOO_LONG 16
100 #define MM_COULD_NOT_WRITE_FILE 17
101 
102 
103 /******************** Matrix Market internal definitions ********************
104 
105  MM_matrix_typecode: 4-character sequence
106 
107  ojbect sparse/ data storage
108  dense type scheme
109 
110  string position: [0] [1] [2] [3]
111 
112  Matrix typecode: M(atrix) C(oord) R(eal) G(eneral)
113  A(array) C(omplex) H(ermitian)
114  P(attern) S(ymmetric)
115  I(nteger) K(kew)
116 
117  ***********************************************************************/
118 
119 #define MM_MTX_STR "matrix"
120 #define MM_ARRAY_STR "array"
121 #define MM_DENSE_STR "array"
122 #define MM_COORDINATE_STR "coordinate"
123 #define MM_SPARSE_STR "coordinate"
124 #define MM_COMPLEX_STR "complex"
125 #define MM_REAL_STR "real"
126 #define MM_INT_STR "integer"
127 #define MM_GENERAL_STR "general"
128 #define MM_SYMM_STR "symmetric"
129 #define MM_HERM_STR "hermitian"
130 #define MM_SKEW_STR "skew-symmetric"
131 #define MM_PATTERN_STR "pattern"
132 
133 
134 /* high level routines */
135 #ifdef __cplusplus
136 extern "C" {
137 #endif
138 
139 
140 int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[],
141  double val[], MM_typecode matcode);
142 int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[],
143  double val[], MM_typecode matcode);
144 int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img,
145  MM_typecode matcode);
146 
147  //int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, double **val_, int **I_, int **J_);
148 
149 #ifdef __cplusplus
150  }
151 #endif
152 
153 
154 #endif
mm_read_mtx_crd_size
int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz)
Definition: mmio.c:187
mm_write_mtx_array_size
int mm_write_mtx_array_size(FILE *f, int M, int N)
Definition: mmio.c:247
mm_typecode_to_str
char * mm_typecode_to_str(MM_typecode matcode)
Definition: mmio.c:453
mm_read_mtx_crd_data
int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode)
Definition: mmio.c:263
mm_read_mtx_crd_entry
int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img, MM_typecode matcode)
Definition: mmio.c:296
mm_read_banner
int mm_read_banner(FILE *f, MM_typecode *matcode)
Definition: mmio.c:94
mm_write_banner
int mm_write_banner(FILE *f, MM_typecode matcode)
Definition: mmio.c:384
mm_read_mtx_array_size
int mm_read_mtx_array_size(FILE *f, int *M, int *N)
Definition: mmio.c:218
MM_typecode
char MM_typecode[4]
Definition: mmio.h:23
mm_write_mtx_crd
int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode)
Definition: mmio.c:397
mm_is_valid
int mm_is_valid(MM_typecode matcode)
Definition: mmio.c:84
mm_write_mtx_crd_size
int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz)
Definition: mmio.c:179