eminem
Parse Matrix Market files in C++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
eminem::Parser< parallel_, Pointer_ > Class Template Reference

Parse a matrix from a Matrix Market file. More...

#include <Parser.hpp>

Inheritance diagram for eminem::Parser< parallel_, Pointer_ >:
Inheritance graph
[legend]

Public Member Functions

 Parser (Pointer_ r)
 
const MatrixDetailsget_banner () const
 
size_t get_nrows () const
 
size_t get_ncols () const
 
size_t get_nlines () const
 
void scan_preamble ()
 
template<typename Type_ = int, class Store_ >
bool scan_integer (Store_ &&store)
 
template<typename Type_ = double, class Store_ >
bool scan_real (Store_ &&store)
 
template<typename Type_ = double, class Store_ >
bool scan_double (Store_ &&store)
 
template<typename Type_ = double, class Store_ >
bool scan_complex (Store_ &&store)
 
template<typename Type_ = bool, class Store_ >
bool scan_pattern (Store_ &&store)
 

Detailed Description

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
class eminem::Parser< parallel_, Pointer_ >

Parse a matrix from a Matrix Market file.

Template Parameters
parallel_Whether to parallelize the byte reading and parsing. If true, a separate thread is used to read the bytes from the input source.
Pointer_A (possibly smart) pointer to a byteme::Reader instance.

Constructor & Destructor Documentation

◆ Parser()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
eminem::Parser< parallel_, Pointer_ >::Parser ( Pointer_  r)
inline
Parameters
rPointer to an unused Reader instance from the byteme library.

Member Function Documentation

◆ get_banner()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
const MatrixDetails & eminem::Parser< parallel_, Pointer_ >::get_banner ( ) const
inline

Retrieve the Matrix Market banner, containing information about the data format and type. This should only be called after scan_preamble().

Returns
Details about the matrix in this file.

◆ get_nrows()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
size_t eminem::Parser< parallel_, Pointer_ >::get_nrows ( ) const
inline

Get the number of rows in the matrix. This should only be called after scan_preamble(). If the object type is Object::VECTOR, the number of rows is equal to the length of the vector.

Returns
Number of rows.

◆ get_ncols()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
size_t eminem::Parser< parallel_, Pointer_ >::get_ncols ( ) const
inline

Get the number of columns in the matrix. This should only be called after scan_preamble(). If the object type is Object::VECTOR, the number of columns is set to 1.

Returns
Number of columns.

◆ get_nlines()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
size_t eminem::Parser< parallel_, Pointer_ >::get_nlines ( ) const
inline

Get the number of non-zero lines in the coordinate format. This should only be called after scan_preamble(). If the object type is Object::ARRAY, the number of lines is defined as the product of the number of rows and columns.

Returns
Number of non-zero lines.

◆ scan_preamble()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
void eminem::Parser< parallel_, Pointer_ >::scan_preamble ( )
inline

Scan the preamble from the Matrix Market file, including the banner and the size line. This should only be called once.

◆ scan_integer()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
template<typename Type_ = int, class Store_ >
bool eminem::Parser< parallel_, Pointer_ >::scan_integer ( Store_ &&  store)
inline

Scan the file for integer lines, assuming that the field in the banner is Field::INTEGER.

Template Parameters
Type_Type to represent the integer.
Store_Function to process each line.
Parameters
storeFunction with the signature void(size_t row, size_t column, Type_ value), which is passed the corresponding values at each line. Both row and column will be 1-based indices; for Object::VECTOR, column will be set to 1. Alternatively, this may return bool, where a false indicates that the scanning should terminate early and a true indicates that the scanning should continue.
Returns
Whether the scanning terminated early, based on store returning false.

◆ scan_real()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
template<typename Type_ = double, class Store_ >
bool eminem::Parser< parallel_, Pointer_ >::scan_real ( Store_ &&  store)
inline

Scan the file for real lines, assuming that the field in the banner is Field::REAL.

Template Parameters
Type_Type to represent the real value.
Store_Function to process each line.
Parameters
storeFunction with the signature void(size_t row, size_t column, Type_ value), which is passed the corresponding values at each line. Both row and column will be 1-based indices; for Object::VECTOR, column will be set to 1. Alternatively, this may return bool, where a false indicates that the scanning should terminate early and a true indicates that the scanning should continue.
Returns
Whether the scanning terminated early, based on store returning false.

◆ scan_double()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
template<typename Type_ = double, class Store_ >
bool eminem::Parser< parallel_, Pointer_ >::scan_double ( Store_ &&  store)
inline

Scan the file for double-precision lines, assuming that the field in the banner is Field::DOUBLE. This is just an alias for scan_real().

Template Parameters
Type_Type to represent the double-precision value.
Store_Function to process each line.
Parameters
storeFunction with the signature void(size_t row, size_t column, Type_ value), which is passed the corresponding values at each line. Both row and column will be 1-based indices; for Object::VECTOR, column will be set to 1. Alternatively, this may return bool, where a false indicates that the scanning should terminate early and a true indicates that the scanning should continue.
Returns
Whether the scanning terminated early, based on store returning false.

◆ scan_complex()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
template<typename Type_ = double, class Store_ >
bool eminem::Parser< parallel_, Pointer_ >::scan_complex ( Store_ &&  store)
inline

Scan the file for complex lines, assuming that the field in the banner is Field::COMPLEX.

Template Parameters
Type_Type to represent the real and imaginary parts of the complex value.
Store_Function to process each line.
Parameters
storeFunction with the signature void(size_t row, size_t column, std::complex<Type_> value), which is passed the corresponding values at each line. Both row and column will be 1-based indices; for Object::VECTOR, column will be set to 1. Alternatively, this may return bool, where a false indicates that the scanning should terminate early and a true indicates that the scanning should continue.
Returns
Whether the scanning terminated early, based on store returning false.

◆ scan_pattern()

template<bool parallel_ = false, class Pointer_ = byteme::Reader*>
template<typename Type_ = bool, class Store_ >
bool eminem::Parser< parallel_, Pointer_ >::scan_pattern ( Store_ &&  store)
inline

Scan the file for pattern lines, assuming that the field in the banner is Field::PATTERN. This function only works when the format field is set to Format::COORDINATE.

Template Parameters
Type_Type to represent the presence of a non-zero entry.
Store_Function to process each line.
Parameters
storeFunction with the signature void(size_t row, size_t column, Type_ value), which is passed the corresponding values at each line. Both row and column will be 1-based indices; for Object::VECTOR, column will be set to 1. value will always be true and can be ignored; it is only required here for consistency with the other methods. Alternatively, this may return bool, where a false indicates that the scanning should terminate early and a true indicates that the scanning should continue.
Returns
Whether the scanning terminated early, based on store returning false.

The documentation for this class was generated from the following file: