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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (4 weeks, 1 day ago) by uqaeller
File MIME type: text/plain
File size: 5418 byte(s)
Updated the copyright header.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26