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

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

Parent Directory Parent Directory | Revision Log Revision Log


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


1 ksteube 1312
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 uqaeller 6939 * Copyright (c) 2003-2020 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 uqaeller 6939 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14     * Development from 2019 by School of Earth and Environmental Sciences
15     **
16 jfenwick 3981 *****************************************************************************/
17 dhawcroft 631
18 ksteube 1811
19 dhawcroft 631 /*
20 jgs 82 * 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 caltinay 5182 #include <fstream>
30 jgs 82
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 caltinay 5182 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 jgs 82
43 caltinay 5182 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 jgs 82
47    
48 caltinay 3642 /********************* MM_typecode query functions ***************************/
49 jgs 82
50 caltinay 5182 #define mm_is_matrix(typecode) ((typecode)[0]=='M')
51 jgs 82
52 caltinay 5182 #define mm_is_sparse(typecode) ((typecode)[1]=='C')
53 jgs 82 #define mm_is_coordinate(typecode)((typecode)[1]=='C')
54 caltinay 5182 #define mm_is_dense(typecode) ((typecode)[1]=='A')
55     #define mm_is_array(typecode) ((typecode)[1]=='A')
56 jgs 82
57 caltinay 5182 #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 jgs 82 #define mm_is_integer(typecode) ((typecode)[2]=='I')
61    
62     #define mm_is_symmetric(typecode)((typecode)[3]=='S')
63 caltinay 5182 #define mm_is_general(typecode) ((typecode)[3]=='G')
64     #define mm_is_skew(typecode) ((typecode)[3]=='K')
65 jgs 82 #define mm_is_hermitian(typecode)((typecode)[3]=='H')
66    
67 caltinay 5182 int mm_is_valid(MM_typecode matcode); /* too complex for a macro */
68 jgs 82
69    
70 caltinay 3642 /********************* MM_typecode modify functions ***************************/
71 jgs 82
72 caltinay 5182 #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 jgs 82
78     #define mm_set_complex(typecode)((*typecode)[2]='C')
79 caltinay 5182 #define mm_set_real(typecode) ((*typecode)[2]='R')
80 jgs 82 #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 caltinay 5182 #define mm_set_skew(typecode) ((*typecode)[3]='K')
87 jgs 82 #define mm_set_hermitian(typecode)((*typecode)[3]='H')
88    
89     #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \
90 caltinay 5182 (*typecode)[2]=' ',(*typecode)[3]='G')
91 jgs 82
92     #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
93    
94    
95     /********************* Matrix Market error codes ***************************/
96    
97    
98 caltinay 5182 #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 jgs 82
106    
107     /******************** Matrix Market internal definitions ********************
108    
109     MM_matrix_typecode: 4-character sequence
110    
111 caltinay 5182 object sparse/ data storage
112     dense type scheme
113 jgs 82
114 caltinay 5182 string position: [0] [1] [2] [3]
115 jgs 82
116 caltinay 5182 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 jgs 82
121 caltinay 5182 ****************************************************************************/
122 jgs 82
123 caltinay 5182 #define MM_MTX_STR "matrix"
124     #define MM_ARRAY_STR "array"
125     #define MM_DENSE_STR "array"
126 jgs 82 #define MM_COORDINATE_STR "coordinate"
127 caltinay 5182 #define MM_SPARSE_STR "coordinate"
128     #define MM_COMPLEX_STR "complex"
129     #define MM_REAL_STR "real"
130     #define MM_INT_STR "integer"
131 jgs 82 #define MM_GENERAL_STR "general"
132 caltinay 5182 #define MM_SYMM_STR "symmetric"
133     #define MM_HERM_STR "hermitian"
134     #define MM_SKEW_STR "skew-symmetric"
135 jgs 82 #define MM_PATTERN_STR "pattern"
136    
137    
138     /* high level routines */
139    
140 caltinay 5182 int mm_write_mtx_crd(char* fname, int M, int N, int nz, int* i, int* j,
141     double* val, MM_typecode matcode);
142 jgs 82
143 caltinay 5182 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 jgs 82
146 caltinay 5182 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 jgs 82 #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