10 #include "purify/directories.h"
14 typename std::enable_if<std::is_scalar<T>::value, std::vector<T>>::type
read_data(
15 const std::string& filename) {
16 std::ifstream data_file(filename);
17 if (!data_file)
throw std::runtime_error(
"Test data is missing: " + filename);
21 for (std::string s; std::getline(data_file, s,
',');) {
22 data.push_back(std::stod(s));
28 typename std::enable_if<std::is_same<t_complex, T>::value, std::vector<T>>::type
read_data(
29 const std::string& filename) {
30 std::ifstream data_file(filename);
31 if (!data_file)
throw std::runtime_error(
"Test data is missing: " + filename);
32 std::string real =
"";
33 std::string imag =
"";
36 for (std::string real; std::getline(data_file, real,
',');) {
38 if (!std::getline(data_file, imag,
')'))
break;
39 data.push_back(T(std::stod(real), std::stod(imag)));
46 std::vector<t_complex>
read_data(
const std::vector<t_real>& input) {
47 std::vector<t_complex> output;
48 for (
auto a = input.begin(); a != input.end(); a++) output.push_back(t_complex(*a, 0.));
std::enable_if< std::is_scalar< T >::value, std::vector< T > >::type read_data(const std::string &filename)
read real values from data file