EpetraExt_mmio.h

Go to the documentation of this file.
00001 /* 
00002 *   Matrix Market I/O library for ANSI C
00003 *
00004 *   See http://math.nist.gov/MatrixMarket for details.
00005 *
00006 *
00007 */
00008 
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 
00012 #ifndef MM_IO_H
00013 #define MM_IO_H
00014 
00015 #define MM_MAX_LINE_LENGTH 1025
00016 #define MatrixMarketBanner "%%MatrixMarket"
00017 #define MM_MAX_TOKEN_LENGTH 64
00018 
00019 typedef char MM_typecode[4];
00020 
00021 namespace EpetraExt {
00022 
00023   void mm_typecode_to_str(MM_typecode matcode, char * buffer);
00024 
00025 int mm_read_banner(FILE *f, MM_typecode *matcode);
00026 int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz);
00027 int mm_read_mtx_array_size(FILE *f, int *M, int *N);
00028 
00029 int mm_write_banner(FILE *f, MM_typecode matcode);
00030 int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz);
00031 int mm_write_mtx_array_size(FILE *f, int M, int N);
00032 
00033 
00034 /********************* MM_typecode query fucntions ***************************/
00035 
00036 #define mm_is_matrix(typecode)  ((typecode)[0]=='M')
00037 
00038 #define mm_is_sparse(typecode)  ((typecode)[1]=='C')
00039 #define mm_is_coordinate(typecode)((typecode)[1]=='C')
00040 #define mm_is_dense(typecode) ((typecode)[1]=='A')
00041 #define mm_is_array(typecode) ((typecode)[1]=='A')
00042 
00043 #define mm_is_complex(typecode) ((typecode)[2]=='C')
00044 #define mm_is_real(typecode)    ((typecode)[2]=='R')
00045 #define mm_is_pattern(typecode) ((typecode)[2]=='P')
00046 #define mm_is_integer(typecode) ((typecode)[2]=='I')
00047 
00048 #define mm_is_symmetric(typecode)((typecode)[3]=='S')
00049 #define mm_is_general(typecode) ((typecode)[3]=='G')
00050 #define mm_is_skew(typecode)  ((typecode)[3]=='K')
00051 #define mm_is_hermitian(typecode)((typecode)[3]=='H')
00052 
00053 int mm_is_valid(MM_typecode matcode);   /* too complex for a macro */
00054 
00055 
00056 /********************* MM_typecode modify fucntions ***************************/
00057 
00058 #define mm_set_matrix(typecode) ((*typecode)[0]='M')
00059 #define mm_set_coordinate(typecode) ((*typecode)[1]='C')
00060 #define mm_set_array(typecode)  ((*typecode)[1]='A')
00061 #define mm_set_dense(typecode)  mm_set_array(typecode)
00062 #define mm_set_sparse(typecode) mm_set_coordinate(typecode)
00063 
00064 #define mm_set_complex(typecode)((*typecode)[2]='C')
00065 #define mm_set_real(typecode) ((*typecode)[2]='R')
00066 #define mm_set_pattern(typecode)((*typecode)[2]='P')
00067 #define mm_set_integer(typecode)((*typecode)[2]='I')
00068 
00069 
00070 #define mm_set_symmetric(typecode)((*typecode)[3]='S')
00071 #define mm_set_general(typecode)((*typecode)[3]='G')
00072 #define mm_set_skew(typecode) ((*typecode)[3]='K')
00073 #define mm_set_hermitian(typecode)((*typecode)[3]='H')
00074 
00075 #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \
00076                   (*typecode)[2]=' ',(*typecode)[3]='G')
00077 
00078 #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
00079 
00080 
00081 /********************* Matrix Market error codes ***************************/
00082 
00083 
00084 #define MM_COULD_NOT_READ_FILE  11
00085 #define MM_PREMATURE_EOF    12
00086 #define MM_NOT_MTX        13
00087 #define MM_NO_HEADER      14
00088 #define MM_UNSUPPORTED_TYPE   15
00089 #define MM_LINE_TOO_LONG    16
00090 #define MM_COULD_NOT_WRITE_FILE 17
00091 
00092 
00093 /******************** Matrix Market internal definitions ********************
00094 
00095    MM_matrix_typecode: 4-character sequence
00096 
00097             ojbect    sparse/     data        storage 
00098                   dense       type        scheme
00099 
00100    string position:  [0]        [1]     [2]         [3]
00101 
00102    Matrix typecode:  M(atrix)  C(oord)    R(eal)    G(eneral)
00103                     A(array)  C(omplex)   H(ermitian)
00104                       P(attern)   S(ymmetric)
00105                         I(nteger) K(kew)
00106 
00107  ***********************************************************************/
00108 
00109 #define MM_MTX_STR    "matrix"
00110 #define MM_ARRAY_STR  "array"
00111 #define MM_DENSE_STR  "array"
00112 #define MM_COORDINATE_STR "coordinate" 
00113 #define MM_SPARSE_STR "coordinate"
00114 #define MM_COMPLEX_STR  "complex"
00115 #define MM_REAL_STR   "real"
00116 #define MM_INT_STR    "integer"
00117 #define MM_GENERAL_STR  "general"
00118 #define MM_SYMM_STR   "symmetric"
00119 #define MM_HERM_STR   "hermitian"
00120 #define MM_SKEW_STR   "skew-symmetric"
00121 #define MM_PATTERN_STR  "pattern"
00122 
00123 
00124 /*  high level routines */
00125 
00126 int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[],
00127      double val[], MM_typecode matcode);
00128 int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[],
00129     double val[], MM_typecode matcode);
00130 int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img,
00131       MM_typecode matcode);
00132 
00133 int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_,
00134                 double **val_, int **I_, int **J_);
00135 
00136 
00137 } // namespace EpetraExt
00138 
00139 #endif

Generated on Wed May 12 21:24:46 2010 for EpetraExt by  doxygen 1.4.7