This repository has been archived on 2018-12-13. You can view files and clone it, but cannot push or open issues or pull requests.
2018-04-08 15:21:54 +00:00
|
|
|
//
|
|
|
|
// arma-flow/reader.hpp
|
|
|
|
//
|
|
|
|
// @author CismonX
|
|
|
|
//
|
|
|
|
|
2018-04-05 11:01:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <armadillo>
|
|
|
|
|
|
|
|
namespace flow
|
|
|
|
{
|
2018-04-08 15:21:54 +00:00
|
|
|
/// Provides read utilities.
|
|
|
|
class reader
|
2018-04-05 11:01:10 +00:00
|
|
|
{
|
|
|
|
/// The loaded matrix.
|
2018-05-29 14:57:08 +00:00
|
|
|
arma::mat mat_;
|
2018-04-05 11:01:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read matrix from an istream.
|
|
|
|
*
|
|
|
|
* @param istream The istream to be read.
|
|
|
|
* @return Whether read is successful.
|
|
|
|
*/
|
|
|
|
bool do_read(std::istream& istream)
|
|
|
|
{
|
|
|
|
mat_.clear();
|
|
|
|
return mat_.load(istream, arma::csv_ascii);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Read matrix from a CSV file. The first line will be ignored.
|
|
|
|
*
|
|
|
|
* @param path Path to file.
|
|
|
|
* @param remove_first_line Whether to remove the first line of CSV file.
|
|
|
|
* @return Whether the file is successfully read.
|
|
|
|
*/
|
|
|
|
bool from_csv_file(const std::string& path, bool remove_first_line);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get loaded matrix.
|
|
|
|
*/
|
2018-05-29 14:57:08 +00:00
|
|
|
const arma::mat& get_mat() const;
|
2018-04-05 11:01:10 +00:00
|
|
|
};
|
|
|
|
}
|