MTX Files#

namespace mocca

Enable (1) or disable (0, default) the support for the Parallel HDF5 library. Requires a MPI library (e.g., OpenMPI, MPICH, etc.).

namespace io#

Functions

template<typename T>
void read_sparse_mtx(const std::string &path, CSRMatrix<T> &mat)#
template<typename T>
CSRMatrix<T> read_sparse_mtx(const std::string &path)#

Reads and parses a MTX file (https://networkrepository.com/mtx-matrix-market-format.html) in the coordinate format, storing the contents in a CSRMatrix.

Complexity: Linear with the file size.

Parameters:
  • path[in] path to the file

  • mat[out] output CSRMatrix (optional)

Returns:

a CSRMatrix with the contents of the file if the mat is not specified.

template<typename T>
void read_dense_mtx(std::string path, Matrix<T> &mat)#
template<typename T>
Matrix<T> read_dense_mtx(std::string path)#

Reads and parses a MTX file (https://networkrepository.com/mtx-matrix-market-format.html) in the array format, storing the contents in a Matrix.

Complexity: Linear with the file size.

Parameters:
  • path[in] path to the file

  • mat[out] output Matrix (optional)

Returns:

a Matrix with the contents of the file if the mat is not specified.

template<typename T>
void write_mtx(CSRMatrix<T> &mat, std::string path, MTXOptions options = MTXOptions())#

Writes the content of a CSRMatrix to a file following the MTX format (https://networkrepository.com/mtx-matrix-market-format.html).

Complexity: Linear in mat.size().

Parameters:
  • mat[in] CSRMatrix to use as data source

  • path[in] path to the file

  • options[in] matrix information. See MTXOptions for all the options.

template<typename T>
void write_mtx(TripletArray<T> &array, index_t nrows, index_t ncols, std::string path, MTXOptions options = MTXOptions())#

Writes the content of an TripletArray to a file following the MTX format (https://networkrepository.com/mtx-matrix-market-format.html).

Complexity: Linear in array.size().

Parameters:
  • array[in] array to use as data source

  • path[in] path to the file

  • nrows[in] number of rows of the sparse matrix

  • ncols[in] number of columns of the sparse matrix

  • options[in] matrix information. See MTXOptions for all the options.

template<typename T>
void write_mtx(Matrix<T> &mat, std::string path, MTXOptions options = MTXOptions())#

Writes the content of a Matrix to a file following the MTX format (https://networkrepository.com/mtx-matrix-market-format.html).

Complexity: Linear in mat.size().

Parameters:
  • mat[in] Matrix to use as data source

  • path[in] path to the file

  • options[in] matrix information. See MTXOptions for all the options.

struct MTXOptions#
#include <mtx.h>

Options for writing MTX files.

Public Members

MatrixStructure mat_struct = kGeneric#

Indicate the structure of the matrix (e.g., if is symmetric or triangular)

bool is_binary = false#

Indicate if the matrix is binary (i.e., only contains 0s and 1s) or not.