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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (hide annotations)
Mon Jul 20 06:20:06 2009 UTC (10 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 4790 byte(s)
Updating copyright notices
1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
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 dhawcroft 631
14 ksteube 1811
15 dhawcroft 631 /*
16 jgs 82 * Matrix Market I/O library for ANSI C
17     *
18     * See http://math.nist.gov/MatrixMarket for details.
19     *
20     */
21    
22     #ifndef MM_IO_H
23     #define MM_IO_H
24    
25 woo409 757 #include <stdio.h>
26 jgs 82
27     #define MM_MAX_LINE_LENGTH 1025
28     #define MatrixMarketBanner "%%MatrixMarket"
29     #define MM_MAX_TOKEN_LENGTH 64
30    
31     typedef char MM_typecode[4];
32    
33     char *mm_typecode_to_str(MM_typecode matcode);
34    
35     int mm_read_banner(FILE *f, MM_typecode *matcode);
36     int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz);
37     int mm_read_mtx_array_size(FILE *f, int *M, int *N);
38    
39     int mm_write_banner(FILE *f, MM_typecode matcode);
40     int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz);
41     int mm_write_mtx_array_size(FILE *f, int M, int N);
42    
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 artak 2107 #define mm_is_real(typecode) ((typecode)[2]=='R')
55 jgs 82 #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    
136 woo409 757 int mm_write_mtx_crd(char fname[], int M, int N, int nz, int i[], int j[],
137 jgs 82 double val[], MM_typecode matcode);
138 woo409 757 int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int i[], int j[],
139 jgs 82 double val[], MM_typecode matcode);
140 woo409 757 int mm_read_mtx_crd_entry(FILE *f, int *i, int *j, double *real, double *img,
141 jgs 82 MM_typecode matcode);
142    
143     int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_,
144     double **val_, int **I_, int **J_);
145    
146     #endif
147    
148     /*
149     * $Log$
150     * Revision 1.1 2004/10/26 06:53:59 jgs
151     * Initial revision
152     *
153     * Revision 1.1 2004/07/02 00:48:35 gross
154     * matrix market io function added
155     *
156     *
157     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26