/[escript]/trunk/paso/src/mmio.h
ViewVC logotype

Contents of /trunk/paso/src/mmio.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 633 - (show annotations)
Thu Mar 23 05:37:00 2006 UTC (13 years, 5 months ago) by dhawcroft
File MIME type: text/plain
File size: 5092 byte(s)


1 /* $Id$ */
2
3 /*
4 ********************************************************************************
5 * Copyright 2006 by ACcESS MNRF *
6 * *
7 * http://www.access.edu.au *
8 * Primary Business: Queensland, Australia *
9 * Licensed under the Open Software License version 3.0 *
10 * http://www.opensource.org/licenses/osl-3.0.php *
11 ********************************************************************************
12 */
13
14 /*
15 * Matrix Market I/O library for ANSI C
16 *
17 * See http://math.nist.gov/MatrixMarket for details.
18 *
19 */
20
21 #ifndef MM_IO_H
22 #define MM_IO_H
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #define MM_MAX_LINE_LENGTH 1025
29 #define MatrixMarketBanner "%%MatrixMarket"
30 #define MM_MAX_TOKEN_LENGTH 64
31
32 typedef char MM_typecode[4];
33
34 char *mm_typecode_to_str(MM_typecode matcode);
35
36 int mm_read_banner(FILE *f, MM_typecode *matcode);
37 int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz);
38 int mm_read_mtx_array_size(FILE *f, int *M, int *N);
39
40 int mm_write_banner(FILE *f, MM_typecode matcode);
41 int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz);
42 int mm_write_mtx_array_size(FILE *f, int M, int N);
43
44
45 /********************* MM_typecode query fucntions ***************************/
46
47 #define mm_is_matrix(typecode) ((typecode)[0]=='M')
48
49 #define mm_is_sparse(typecode) ((typecode)[1]=='C')
50 #define mm_is_coordinate(typecode)((typecode)[1]=='C')
51 #define mm_is_dense(typecode) ((typecode)[1]=='A')
52 #define mm_is_array(typecode) ((typecode)[1]=='A')
53
54 #define mm_is_complex(typecode) ((typecode)[2]=='C')
55 #define mm_is_real(typecode) ((typecode)[2]=='R')
56 #define mm_is_pattern(typecode) ((typecode)[2]=='P')
57 #define mm_is_integer(typecode) ((typecode)[2]=='I')
58
59 #define mm_is_symmetric(typecode)((typecode)[3]=='S')
60 #define mm_is_general(typecode) ((typecode)[3]=='G')
61 #define mm_is_skew(typecode) ((typecode)[3]=='K')
62 #define mm_is_hermitian(typecode)((typecode)[3]=='H')
63
64 int mm_is_valid(MM_typecode matcode); /* too complex for a macro */
65
66
67 /********************* MM_typecode modify fucntions ***************************/
68
69 #define mm_set_matrix(typecode) ((*typecode)[0]='M')
70 #define mm_set_coordinate(typecode) ((*typecode)[1]='C')
71 #define mm_set_array(typecode) ((*typecode)[1]='A')
72 #define mm_set_dense(typecode) mm_set_array(typecode)
73 #define mm_set_sparse(typecode) mm_set_coordinate(typecode)
74
75 #define mm_set_complex(typecode)((*typecode)[2]='C')
76 #define mm_set_real(typecode) ((*typecode)[2]='R')
77 #define mm_set_pattern(typecode)((*typecode)[2]='P')
78 #define mm_set_integer(typecode)((*typecode)[2]='I')
79
80
81 #define mm_set_symmetric(typecode)((*typecode)[3]='S')
82 #define mm_set_general(typecode)((*typecode)[3]='G')
83 #define mm_set_skew(typecode) ((*typecode)[3]='K')
84 #define mm_set_hermitian(typecode)((*typecode)[3]='H')
85
86 #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \
87 (*typecode)[2]=' ',(*typecode)[3]='G')
88
89 #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
90
91
92 /********************* Matrix Market error codes ***************************/
93
94
95 #define MM_COULD_NOT_READ_FILE 11
96 #define MM_PREMATURE_EOF 12
97 #define MM_NOT_MTX 13
98 #define MM_NO_HEADER 14
99 #define MM_UNSUPPORTED_TYPE 15
100 #define MM_LINE_TOO_LONG 16
101 #define MM_COULD_NOT_WRITE_FILE 17
102
103
104 /******************** Matrix Market internal definitions ********************
105
106 MM_matrix_typecode: 4-character sequence
107
108 ojbect sparse/ data storage
109 dense type scheme
110
111 string position: [0] [1] [2] [3]
112
113 Matrix typecode: M(atrix) C(oord) R(eal) G(eneral)
114 A(array) C(omplex) H(ermitian)
115 P(attern) S(ymmetric)
116 I(nteger) K(kew)
117
118 ***********************************************************************/
119
120 #define MM_MTX_STR "matrix"
121 #define MM_ARRAY_STR "array"
122 #define MM_DENSE_STR "array"
123 #define MM_COORDINATE_STR "coordinate"
124 #define MM_SPARSE_STR "coordinate"
125 #define MM_COMPLEX_STR "complex"
126 #define MM_REAL_STR "real"
127 #define MM_INT_STR "integer"
128 #define MM_GENERAL_STR "general"
129 #define MM_SYMM_STR "symmetric"
130 #define MM_HERM_STR "hermitian"
131 #define MM_SKEW_STR "skew-symmetric"
132 #define MM_PATTERN_STR "pattern"
133
134
135 /* high level routines */
136
137 int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[],
138 double val[], MM_typecode matcode);
139 int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[],
140 double val[], MM_typecode matcode);
141 int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img,
142 MM_typecode matcode);
143
144 int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_,
145 double **val_, int **I_, int **J_);
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif
152
153 /*
154 * $Log$
155 * Revision 1.1 2004/10/26 06:53:59 jgs
156 * Initial revision
157 *
158 * Revision 1.1 2004/07/02 00:48:35 gross
159 * matrix market io function added
160 *
161 *
162 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26