Parse a matrix from a Matrix Market file.
More...
#include <Parser.hpp>
template<class Input_>
class eminem::Parser< Input_ >
Parse a matrix from a Matrix Market file.
- Template Parameters
-
◆ Parser()
◆ get_banner()
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()
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()
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()
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()
Scan the preamble from the Matrix Market file, including the banner and the size line. This should only be called once.
◆ scan_integer()
template<class Input_ >
template<typename Type_ = int, class Store_ >
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
-
store | Function with the signature void(Index row, Index 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<class Input_ >
template<typename Type_ = double, class Store_ >
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
-
store | Function with the signature void(Index row, Index 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 function 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<class Input_ >
template<typename Type_ = double, class Store_ >
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
-
store | Function with the signature void(Index row, Index 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 function 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<class Input_ >
template<typename Type_ = double, class Store_ >
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
-
store | Function with the signature void(Index row, Index 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 function 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<class Input_ >
template<typename Type_ = bool, class Store_ >
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
-
store | Function with the signature void(Index row, Index 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 function 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: