mmio.h File Reference
`#include <fstream>`

Go to the source code of this file.

## Macros

#define | MM_MAX_LINE_LENGTH 1025
#define | MatrixMarketBanner "%%MatrixMarket"
#define | MM_MAX_TOKEN_LENGTH 64
#define | mm_is_matrix(typecode) ((typecode)[0]=='M')
#define | mm_is_sparse(typecode) ((typecode)[1]=='C')
#define | mm_is_coordinate(typecode) ((typecode)[1]=='C')
#define | mm_is_dense(typecode) ((typecode)[1]=='A')
#define | mm_is_array(typecode) ((typecode)[1]=='A')
#define | mm_is_complex(typecode) ((typecode)[2]=='C')
#define | mm_is_real(typecode) ((typecode)[2]=='R')
#define | mm_is_pattern(typecode) ((typecode)[2]=='P')
#define | mm_is_integer(typecode) ((typecode)[2]=='I')
#define | mm_is_symmetric(typecode) ((typecode)[3]=='S')
#define | mm_is_general(typecode) ((typecode)[3]=='G')
#define | mm_is_skew(typecode) ((typecode)[3]=='K')
#define | mm_is_hermitian(typecode) ((typecode)[3]=='H')
#define | mm_set_matrix(typecode) ((*typecode)[0]='M')
#define | mm_set_coordinate(typecode) ((*typecode)[1]='C')
#define | mm_set_array(typecode) ((*typecode)[1]='A')
#define | mm_set_dense(typecode) mm_set_array(typecode)
#define | mm_set_sparse(typecode) mm_set_coordinate(typecode)
#define | mm_set_complex(typecode) ((*typecode)[2]='C')
#define | mm_set_real(typecode) ((*typecode)[2]='R')
#define | mm_set_pattern(typecode) ((*typecode)[2]='P')
#define | mm_set_integer(typecode) ((*typecode)[2]='I')
#define | mm_set_symmetric(typecode) ((*typecode)[3]='S')
#define | mm_set_general(typecode) ((*typecode)[3]='G')
#define | mm_set_skew(typecode) ((*typecode)[3]='K')
#define | mm_set_hermitian(typecode) ((*typecode)[3]='H')
#define | mm_clear_typecode(typecode)
#define | mm_initialize_typecode(typecode) mm_clear_typecode(typecode)
#define | MM_COULD_NOT_READ_FILE 11
#define | MM_PREMATURE_EOF 12
#define | MM_NOT_MTX 13
#define | MM_NO_HEADER 14
#define | MM_UNSUPPORTED_TYPE 15
#define | MM_LINE_TOO_LONG 16
#define | MM_COULD_NOT_WRITE_FILE 17
#define | MM_MTX_STR "matrix"
#define | MM_ARRAY_STR "array"
#define | MM_DENSE_STR "array"
#define | MM_COORDINATE_STR "coordinate"
#define | MM_SPARSE_STR "coordinate"
#define | MM_COMPLEX_STR "complex"
#define | MM_REAL_STR "real"
#define | MM_INT_STR "integer"
#define | MM_GENERAL_STR "general"
#define | MM_SYMM_STR "symmetric"
#define | MM_HERM_STR "hermitian"
#define | MM_SKEW_STR "skew-symmetric"
#define | MM_PATTERN_STR "pattern"

## Typedefs

typedef char | MM_typecode[4]

## Functions

char * | mm_typecode_to_str (MM_typecode matcode)
int | mm_read_banner (std::istream &f, MM_typecode *matcode)
int | mm_read_mtx_crd_size (std::istream &f, int *M, int *N, int *nz)
int | mm_read_mtx_array_size (std::istream &f, int *M, int *N)
int | mm_write_banner (std::ostream &f, MM_typecode matcode)
int | mm_write_mtx_crd_size (std::ostream &f, int M, int N, int nz)
int | mm_write_mtx_array_size (std::ostream &f, int M, int N)
int | mm_is_valid (MM_typecode matcode)
int | mm_write_mtx_crd (char *fname, int M, int N, int nz, int *i, int *j, double *val, MM_typecode matcode)
int | mm_read_mtx_crd_data (std::istream &f, int M, int N, int nz, int *i, int *j, double *val, MM_typecode matcode)
int | mm_read_mtx_crd_entry (std::istream &f, int *i, int *j, double *real, double *img, MM_typecode matcode)
int | mm_read_unsymmetric_sparse (const char *fname, int *M, int *N, int *nz, double **val, int **I, int **J)

## Macro Definition Documentation

## MatrixMarketBanner

#define MatrixMarketBanner "%%MatrixMarket"

Referenced by mm_read_banner(), mm_write_banner(), and mm_write_mtx_crd().

## MM_ARRAY_STR

#define MM_ARRAY_STR "array"

## mm_clear_typecode

#define mm_clear_typecode | ( |  | typecode | ) |

Value:
((*typecode)[0]=(*typecode)[1]= \
(*typecode)[2]=' ',(*typecode)[3]='G')

Referenced by mm_read_banner().

## MM_COMPLEX_STR

#define MM_COMPLEX_STR "complex"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_COORDINATE_STR

#define MM_COORDINATE_STR "coordinate"

## MM_COULD_NOT_READ_FILE

#define MM_COULD_NOT_READ_FILE 11

Referenced by mm_read_mtx_crd().

## MM_COULD_NOT_WRITE_FILE

#define MM_COULD_NOT_WRITE_FILE 17

Referenced by mm_write_banner(), mm_write_mtx_array_size(), mm_write_mtx_crd(), and mm_write_mtx_crd_size().

## MM_DENSE_STR

#define MM_DENSE_STR "array"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_GENERAL_STR

#define MM_GENERAL_STR "general"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_HERM_STR

#define MM_HERM_STR "hermitian"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## mm_initialize_typecode

#define mm_initialize_typecode | ( |  | typecode | ) | mm_clear_typecode(typecode)

Referenced by paso::SparseMatrix::saveMM().

## MM_INT_STR

#define MM_INT_STR "integer"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## mm_is_array

#define mm_is_array | ( |  | typecode | ) | ((typecode)[1]=='A')

Referenced by paso::RHS_loadMM_toCSR().

## mm_is_complex

#define mm_is_complex | ( |  | typecode | ) | ((typecode)[2]=='C')

Referenced by mm_read_mtx_crd(), mm_read_mtx_crd_data(), mm_read_mtx_crd_entry(), mm_typecode_to_str(), and mm_write_mtx_crd().

## mm_is_coordinate

#define mm_is_coordinate | ( |  | typecode | ) | ((typecode)[1]=='C')

## mm_is_dense

#define mm_is_dense | ( |  | typecode | ) | ((typecode)[1]=='A')

Referenced by mm_is_valid(), and mm_typecode_to_str().

## mm_is_general

#define mm_is_general | ( |  | typecode | ) | ((typecode)[3]=='G')

Referenced by paso::SystemMatrix::loadMM_toCSC(), paso::SparseMatrix::loadMM_toCSR(), paso::SystemMatrix::loadMM_toCSR(), mm_typecode_to_str(), and paso::RHS_loadMM_toCSR().

## mm_is_hermitian

#define mm_is_hermitian | ( |  | typecode | ) | ((typecode)[3]=='H')

Referenced by mm_is_valid(), and mm_typecode_to_str().

## mm_is_integer

#define mm_is_integer | ( |  | typecode | ) | ((typecode)[2]=='I')

Referenced by mm_typecode_to_str().

## mm_is_matrix

#define mm_is_matrix | ( |  | typecode | ) | ((typecode)[0]=='M')

Referenced by mm_is_valid(), mm_read_mtx_crd(), mm_read_unsymmetric_sparse(), and mm_typecode_to_str().

## mm_is_pattern

#define mm_is_pattern | ( |  | typecode | ) | ((typecode)[2]=='P')

Referenced by mm_is_valid(), mm_read_mtx_crd(), mm_read_mtx_crd_data(), mm_read_mtx_crd_entry(), mm_typecode_to_str(), and mm_write_mtx_crd().

## mm_is_real

#define mm_is_real | ( |  | typecode | ) | ((typecode)[2]=='R')

Referenced by paso::SystemMatrix::loadMM_toCSC(), paso::SparseMatrix::loadMM_toCSR(), paso::SystemMatrix::loadMM_toCSR(), mm_is_valid(), mm_read_mtx_crd(), mm_read_mtx_crd_data(), mm_read_mtx_crd_entry(), mm_read_unsymmetric_sparse(), mm_typecode_to_str(), mm_write_mtx_crd(), and paso::RHS_loadMM_toCSR().

## mm_is_skew

#define mm_is_skew | ( |  | typecode | ) | ((typecode)[3]=='K')

Referenced by mm_is_valid(), and mm_typecode_to_str().

## mm_is_sparse

#define mm_is_sparse | ( |  | typecode | ) | ((typecode)[1]=='C')

Referenced by paso::SystemMatrix::loadMM_toCSC(), paso::SparseMatrix::loadMM_toCSR(), paso::SystemMatrix::loadMM_toCSR(), mm_read_mtx_crd(), mm_read_unsymmetric_sparse(), and mm_typecode_to_str().

## mm_is_symmetric

#define mm_is_symmetric | ( |  | typecode | ) | ((typecode)[3]=='S')

Referenced by mm_typecode_to_str().

## MM_LINE_TOO_LONG

#define MM_LINE_TOO_LONG 16

## MM_MAX_LINE_LENGTH

#define MM_MAX_LINE_LENGTH 1025

Referenced by mm_read_banner(), mm_read_mtx_array_size(), mm_read_mtx_crd_size(), and mm_typecode_to_str().

## MM_MAX_TOKEN_LENGTH

#define MM_MAX_TOKEN_LENGTH 64

Referenced by mm_read_banner().

## MM_MTX_STR

#define MM_MTX_STR "matrix"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_NO_HEADER

#define MM_NO_HEADER 14

Referenced by mm_read_banner().

## MM_NOT_MTX

#define MM_NOT_MTX 13

## MM_PATTERN_STR

#define MM_PATTERN_STR "pattern"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_PREMATURE_EOF

#define MM_PREMATURE_EOF 12

Referenced by mm_read_banner(), mm_read_mtx_array_size(), mm_read_mtx_crd_data(), mm_read_mtx_crd_entry(), and mm_read_mtx_crd_size().

## MM_REAL_STR

#define MM_REAL_STR "real"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## mm_set_array

#define mm_set_array | ( |  | typecode | ) | ((*typecode)[1]='A')

## mm_set_complex

#define mm_set_complex | ( |  | typecode | ) | ((*typecode)[2]='C')

Referenced by mm_read_banner().

## mm_set_coordinate

#define mm_set_coordinate | ( |  | typecode | ) | ((*typecode)[1]='C')

Referenced by paso::SparseMatrix::saveMM().

## mm_set_dense

#define mm_set_dense | ( |  | typecode | ) | mm_set_array(typecode)

Referenced by mm_read_banner().

## mm_set_general

#define mm_set_general | ( |  | typecode | ) | ((*typecode)[3]='G')

Referenced by mm_read_banner().

## mm_set_hermitian

#define mm_set_hermitian | ( |  | typecode | ) | ((*typecode)[3]='H')

Referenced by mm_read_banner().

## mm_set_integer

#define mm_set_integer | ( |  | typecode | ) | ((*typecode)[2]='I')

Referenced by mm_read_banner().

## mm_set_matrix

#define mm_set_matrix | ( |  | typecode | ) | ((*typecode)[0]='M')

Referenced by mm_read_banner(), and paso::SparseMatrix::saveMM().

## mm_set_pattern

#define mm_set_pattern | ( |  | typecode | ) | ((*typecode)[2]='P')

Referenced by mm_read_banner().

## mm_set_real

#define mm_set_real | ( |  | typecode | ) | ((*typecode)[2]='R')

Referenced by mm_read_banner(), and paso::SparseMatrix::saveMM().

## mm_set_skew

#define mm_set_skew | ( |  | typecode | ) | ((*typecode)[3]='K')

Referenced by mm_read_banner().

## mm_set_sparse

#define mm_set_sparse | ( |  | typecode | ) | mm_set_coordinate(typecode)

Referenced by mm_read_banner().

## mm_set_symmetric

#define mm_set_symmetric | ( |  | typecode | ) | ((*typecode)[3]='S')

Referenced by mm_read_banner().

## MM_SKEW_STR

#define MM_SKEW_STR "skew-symmetric"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_SPARSE_STR

#define MM_SPARSE_STR "coordinate"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_SYMM_STR

#define MM_SYMM_STR "symmetric"

Referenced by mm_read_banner(), and mm_typecode_to_str().

## MM_UNSUPPORTED_TYPE

#define MM_UNSUPPORTED_TYPE 15

Referenced by mm_read_banner(), mm_read_mtx_crd(), mm_read_mtx_crd_data(), mm_read_mtx_crd_entry(), and mm_write_mtx_crd().

## Typedef Documentation

## MM_typecode

typedef char MM_typecode[4]

## Function Documentation

## mm_is_valid()

int mm_is_valid | ( | MM_typecode | matcode | ) |

References mm_is_dense, mm_is_hermitian, mm_is_matrix, mm_is_pattern, mm_is_real, and mm_is_skew.

Referenced by mm_read_mtx_crd().

## mm_read_banner()

int mm_read_banner | ( | std::istream & | f,
|  | MM_typecode * | matcode
| ) |  |

References MatrixMarketBanner, mm_clear_typecode, MM_COMPLEX_STR, MM_DENSE_STR, MM_GENERAL_STR, MM_HERM_STR, MM_INT_STR, MM_MAX_LINE_LENGTH, MM_MAX_TOKEN_LENGTH, MM_MTX_STR, MM_NO_HEADER, MM_PATTERN_STR, MM_PREMATURE_EOF, MM_REAL_STR, mm_set_complex, mm_set_dense, mm_set_general, mm_set_hermitian, mm_set_integer, mm_set_matrix, mm_set_pattern, mm_set_real, mm_set_skew, mm_set_sparse, mm_set_symmetric, MM_SKEW_STR, MM_SPARSE_STR, MM_SYMM_STR, and MM_UNSUPPORTED_TYPE.

Referenced by paso::SystemMatrix::loadMM_toCSC(), paso::SparseMatrix::loadMM_toCSR(), paso::SystemMatrix::loadMM_toCSR(), mm_read_mtx_crd(), mm_read_unsymmetric_sparse(), and paso::RHS_loadMM_toCSR().

## mm_read_mtx_array_size()

int mm_read_mtx_array_size | ( | std::istream & | f,
|  | int * | M,
|  | int * | N
| ) |  |

References MM_MAX_LINE_LENGTH, and MM_PREMATURE_EOF.

Referenced by paso::RHS_loadMM_toCSR().

## mm_read_mtx_crd_data()

int mm_read_mtx_crd_data | ( | std::istream & | f,
|  | int | M,
|  | int | N,
|  | int | nz,
|  | int * | i,
|  | int * | j,
|  | double * | val,
|  | MM_typecode | matcode
| ) |  |

References mm_is_complex, mm_is_pattern, mm_is_real, MM_PREMATURE_EOF, MM_UNSUPPORTED_TYPE, and paso::nz.

Referenced by mm_read_mtx_crd().

## mm_read_mtx_crd_entry()

int mm_read_mtx_crd_entry | ( | std::istream & | f,
|  | int * | i,
|  | int * | j,
|  | double * | real,
|  | double * | img,
|  | MM_typecode | matcode
| ) |  |

References mm_is_complex, mm_is_pattern, mm_is_real, MM_PREMATURE_EOF, and MM_UNSUPPORTED_TYPE.

## mm_read_mtx_crd_size()

int mm_read_mtx_crd_size | ( | std::istream & | f,
|  | int * | M,
|  | int * | N,
|  | int * | nz
| ) |  |

References MM_MAX_LINE_LENGTH, and MM_PREMATURE_EOF.

Referenced by paso::SystemMatrix::loadMM_toCSC(), paso::SparseMatrix::loadMM_toCSR(), paso::SystemMatrix::loadMM_toCSR(), mm_read_mtx_crd(), and mm_read_unsymmetric_sparse().

## mm_read_unsymmetric_sparse()

int mm_read_unsymmetric_sparse | ( | const char * | fname,
|  | int * | M,
|  | int * | N,
|  | int * | nz,
|  | double ** | val,
|  | int ** | I,
|  | int ** | J
| ) |  |

References paso::M, mm_is_matrix, mm_is_real, mm_is_sparse, mm_read_banner(), mm_read_mtx_crd_size(), mm_typecode_to_str(), paso::N, and paso::nz.

## mm_typecode_to_str()

char* mm_typecode_to_str | ( | MM_typecode | matcode | ) |

References MM_COMPLEX_STR, MM_DENSE_STR, MM_GENERAL_STR, MM_HERM_STR, MM_INT_STR, mm_is_complex, mm_is_dense, mm_is_general, mm_is_hermitian, mm_is_integer, mm_is_matrix, mm_is_pattern, mm_is_real, mm_is_skew, mm_is_sparse, mm_is_symmetric, MM_MAX_LINE_LENGTH, MM_MTX_STR, MM_PATTERN_STR, MM_REAL_STR, MM_SKEW_STR, MM_SPARSE_STR, and MM_SYMM_STR.

Referenced by mm_read_unsymmetric_sparse(), mm_write_banner(), and mm_write_mtx_crd().

## mm_write_banner()

int mm_write_banner | ( | std::ostream & | f,
|  | MM_typecode | matcode
| ) |  |

References MatrixMarketBanner, MM_COULD_NOT_WRITE_FILE, and mm_typecode_to_str().

Referenced by paso::SparseMatrix::saveMM().

## mm_write_mtx_array_size()

int mm_write_mtx_array_size | ( | std::ostream & | f,
|  | int | M,
|  | int | N
| ) |  |

References MM_COULD_NOT_WRITE_FILE.

## mm_write_mtx_crd()

int mm_write_mtx_crd | ( | char * | fname,
|  | int | M,
|  | int | N,
|  | int | nz,
|  | int * | i,
|  | int * | j,
|  | double * | val,
|  | MM_typecode | matcode
| ) |  |

References MatrixMarketBanner, MM_COULD_NOT_WRITE_FILE, mm_is_complex, mm_is_pattern, mm_is_real, mm_typecode_to_str(), MM_UNSUPPORTED_TYPE, and paso::nz.

## mm_write_mtx_crd_size()

int mm_write_mtx_crd_size | ( | std::ostream & | f,
|  | int | M,
|  | int | N,
|  | int | nz
| ) |  |

References MM_COULD_NOT_WRITE_FILE.

Referenced by paso::SparseMatrix::saveMM().