Txeo v0.1
A Developer-Friendly TensorFlow C++ Wrapper
|
A class to read file data to matrix and to write file data to a matrix. More...
#include <MatrixIO.h>
Public Member Functions | |
MatrixIO (const std::filesystem::path &path, char separator=',') | |
Constructs MatrixIO object. | |
template<typename T > | |
txeo::Matrix< T > | read_text_file (bool has_header=false) const |
Returns a matrix with elements read from a text file. | |
template<typename T > | |
void | write_text_file (const txeo::Matrix< T > &matrix) const |
Writes a matrix to a text file. | |
template<typename T > requires (std::is_floating_point_v<T>) | |
void | write_text_file (const txeo::Matrix< T > &matrix, size_t precision) const |
Writes a floating-point matrix with specified precision to a text file. | |
Static Public Member Functions | |
template<typename T > | |
static txeo::Matrix< T > | read_textfile (const std::filesystem::path &path, char separator=',', bool has_header=false) |
Returns a matrix with elements read from a text file. | |
template<typename T > | |
static void | write_textfile (const txeo::Matrix< T > &matrix, const std::filesystem::path &path, char separator=',') |
Writes a matrix to a text file. | |
template<typename T > requires (std::is_floating_point_v<T>) | |
static void | write_textfile (const txeo::Matrix< T > &matrix, size_t precision, const std::filesystem::path &path, char separator=',') |
Writes a floating-point matrix with specified precision to a text file. | |
A class to read file data to matrix and to write file data to a matrix.
Definition at line 17 of file MatrixIO.h.
|
inlineexplicit |
Constructs MatrixIO object.
path | Path to the file |
separator | Character delimiting each element in a row |
Definition at line 25 of file MatrixIO.h.
txeo::Matrix< T > txeo::MatrixIO::read_text_file | ( | bool | has_header = false | ) | const |
Returns a matrix with elements read from a text file.
T | Data type of the matrix elements |
has_header | Whether the first line contains column headers |
MatrixIOError |
|
inlinestatic |
Returns a matrix with elements read from a text file.
T | Data type of matrix elements |
path | File path to read from |
separator | Column separator character |
has_header | Whether to skip first line as header |
Definition at line 103 of file MatrixIO.h.
void txeo::MatrixIO::write_text_file | ( | const txeo::Matrix< T > & | matrix | ) | const |
Writes a matrix to a text file.
T | Data type of the matrix elements |
matrix | Matrix to write to file |
MatrixIOError |
void txeo::MatrixIO::write_text_file | ( | const txeo::Matrix< T > & | matrix, |
size_t | precision | ||
) | const |
Writes a floating-point matrix with specified precision to a text file.
T | Floating-point type (float/double) |
matrix | Matrix to write |
precision | Number of decimal places to write |
MatrixIOError |
|
inlinestatic |
Writes a matrix to a text file.
T | Data type of matrix elements |
matrix | Matrix to write |
path | Output file path |
separator | Column separator |
Definition at line 125 of file MatrixIO.h.
|
inlinestatic |
Writes a floating-point matrix with specified precision to a text file.
T | Floating-point type (float/double) |
matrix | Matrix to write |
precision | Decimal places to display |
path | Output file path |
separator | Column delimiter |
Definition at line 149 of file MatrixIO.h.