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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (19 months, 1 week ago) by jfenwick
File MIME type: text/plain
File size: 5342 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 ksteube 1312
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 6651 * Copyright (c) 2003-2018 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 dhawcroft 631
17 ksteube 1811
18 dhawcroft 631 /*
19 jgs 82 * Matrix Market I/O library for ANSI C
20     *
21     * See http://math.nist.gov/MatrixMarket for details.
22     *
23     */
24    
25     #ifndef MM_IO_H
26     #define MM_IO_H
27    
28 caltinay 5182 #include <fstream>
29 jgs 82
30     #define MM_MAX_LINE_LENGTH 1025
31     #define MatrixMarketBanner "%%MatrixMarket"
32     #define MM_MAX_TOKEN_LENGTH 64
33    
34     typedef char MM_typecode[4];
35    
36     char *mm_typecode_to_str(MM_typecode matcode);
37    
38 caltinay 5182 int mm_read_banner(std::istream& f, MM_typecode *matcode);
39     int mm_read_mtx_crd_size(std::istream& f, int *M, int *N, int *nz);
40     int mm_read_mtx_array_size(std::istream& f, int *M, int *N);
41 jgs 82
42 caltinay 5182 int mm_write_banner(std::ostream& f, MM_typecode matcode);
43     int mm_write_mtx_crd_size(std::ostream& f, int M, int N, int nz);
44     int mm_write_mtx_array_size(std::ostream& f, int M, int N);
45 jgs 82
46    
47 caltinay 3642 /********************* MM_typecode query functions ***************************/
48 jgs 82
49 caltinay 5182 #define mm_is_matrix(typecode) ((typecode)[0]=='M')
50 jgs 82
51 caltinay 5182 #define mm_is_sparse(typecode) ((typecode)[1]=='C')
52 jgs 82 #define mm_is_coordinate(typecode)((typecode)[1]=='C')
53 caltinay 5182 #define mm_is_dense(typecode) ((typecode)[1]=='A')
54     #define mm_is_array(typecode) ((typecode)[1]=='A')
55 jgs 82
56 caltinay 5182 #define mm_is_complex(typecode) ((typecode)[2]=='C')
57     #define mm_is_real(typecode) ((typecode)[2]=='R')
58     #define mm_is_pattern(typecode) ((typecode)[2]=='P')
59 jgs 82 #define mm_is_integer(typecode) ((typecode)[2]=='I')
60    
61     #define mm_is_symmetric(typecode)((typecode)[3]=='S')
62 caltinay 5182 #define mm_is_general(typecode) ((typecode)[3]=='G')
63     #define mm_is_skew(typecode) ((typecode)[3]=='K')
64 jgs 82 #define mm_is_hermitian(typecode)((typecode)[3]=='H')
65    
66 caltinay 5182 int mm_is_valid(MM_typecode matcode); /* too complex for a macro */
67 jgs 82
68    
69 caltinay 3642 /********************* MM_typecode modify functions ***************************/
70 jgs 82
71 caltinay 5182 #define mm_set_matrix(typecode) ((*typecode)[0]='M')
72     #define mm_set_coordinate(typecode) ((*typecode)[1]='C')
73     #define mm_set_array(typecode) ((*typecode)[1]='A')
74     #define mm_set_dense(typecode) mm_set_array(typecode)
75     #define mm_set_sparse(typecode) mm_set_coordinate(typecode)
76 jgs 82
77     #define mm_set_complex(typecode)((*typecode)[2]='C')
78 caltinay 5182 #define mm_set_real(typecode) ((*typecode)[2]='R')
79 jgs 82 #define mm_set_pattern(typecode)((*typecode)[2]='P')
80     #define mm_set_integer(typecode)((*typecode)[2]='I')
81    
82    
83     #define mm_set_symmetric(typecode)((*typecode)[3]='S')
84     #define mm_set_general(typecode)((*typecode)[3]='G')
85 caltinay 5182 #define mm_set_skew(typecode) ((*typecode)[3]='K')
86 jgs 82 #define mm_set_hermitian(typecode)((*typecode)[3]='H')
87    
88     #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \
89 caltinay 5182 (*typecode)[2]=' ',(*typecode)[3]='G')
90 jgs 82
91     #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
92    
93    
94     /********************* Matrix Market error codes ***************************/
95    
96    
97 caltinay 5182 #define MM_COULD_NOT_READ_FILE 11
98     #define MM_PREMATURE_EOF 12
99     #define MM_NOT_MTX 13
100     #define MM_NO_HEADER 14
101     #define MM_UNSUPPORTED_TYPE 15
102     #define MM_LINE_TOO_LONG 16
103     #define MM_COULD_NOT_WRITE_FILE 17
104 jgs 82
105    
106     /******************** Matrix Market internal definitions ********************
107    
108     MM_matrix_typecode: 4-character sequence
109    
110 caltinay 5182 object sparse/ data storage
111     dense type scheme
112 jgs 82
113 caltinay 5182 string position: [0] [1] [2] [3]
114 jgs 82
115 caltinay 5182 Matrix typecode: M(atrix) C(oord) R(eal) G(eneral)
116     A(array) C(omplex) H(ermitian)
117     P(attern) S(ymmetric)
118     I(nteger) sKew
119 jgs 82
120 caltinay 5182 ****************************************************************************/
121 jgs 82
122 caltinay 5182 #define MM_MTX_STR "matrix"
123     #define MM_ARRAY_STR "array"
124     #define MM_DENSE_STR "array"
125 jgs 82 #define MM_COORDINATE_STR "coordinate"
126 caltinay 5182 #define MM_SPARSE_STR "coordinate"
127     #define MM_COMPLEX_STR "complex"
128     #define MM_REAL_STR "real"
129     #define MM_INT_STR "integer"
130 jgs 82 #define MM_GENERAL_STR "general"
131 caltinay 5182 #define MM_SYMM_STR "symmetric"
132     #define MM_HERM_STR "hermitian"
133     #define MM_SKEW_STR "skew-symmetric"
134 jgs 82 #define MM_PATTERN_STR "pattern"
135    
136    
137     /* high level routines */
138    
139 caltinay 5182 int mm_write_mtx_crd(char* fname, int M, int N, int nz, int* i, int* j,
140     double* val, MM_typecode matcode);
141 jgs 82
142 caltinay 5182 int mm_read_mtx_crd_data(std::istream& f, int M, int N, int nz, int* i, int* j,
143     double* val, MM_typecode matcode);
144 jgs 82
145 caltinay 5182 int mm_read_mtx_crd_entry(std::istream& f, int* i, int* j, double* real,
146     double* img, MM_typecode matcode);
147    
148     int mm_read_unsymmetric_sparse(const char* fname, int* M, int* N, int* nz,
149     double** val, int** I, int** J);
150    
151 jgs 82 #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