16 std::string genStringWithTime(
const std::string& str);
30 template<
size_t dim,
typename float_t>
31 void logParams(
const Eigen::Matrix<float_t,dim,1> &vec, std::ofstream &ofs);
40 template<
size_t dim,
typename float_t>
41 void logParams(
const Eigen::Matrix<float_t,dim,1> &vec,
const std::string &outfile);
50 template<
size_t size,
typename float_t>
51 void logParams(
const std::array<float_t, size> &arr,
const std::string &outfile);
60 template<
size_t nc,
typename float_t>
61 std::vector<Eigen::Matrix<float_t,nc,1> > readInData(
const std::string& fileLoc);
64 template<
size_t dim,
typename float_t>
65 void logParams(
const Eigen::Matrix<float_t,dim,1> &vec, std::ofstream &ofs)
71 for(
size_t i = 0; i < dim; ++i){
75 ofs <<
"," << vec(i,0);
82 std::cerr <<
"tried to write to a closed ofstream! " <<
"\n";
87 template<
size_t dim,
typename float_t>
88 void logParams(
const Eigen::Matrix<float_t,dim,1> &vec,
const std::string &outfile)
92 std::ofstream f(outfile, std::ios::app);
98 for(
size_t i = 0; i < dim; ++i){
102 f <<
"," << vec(i,0);
110 std::cerr <<
"logParams() failed to open file at: " << outfile <<
"\n";
115 template<
size_t size,
typename float_t>
116 void logParams(
const std::array<float_t, size> &arr,
const std::string &outfile)
123 std::ofstream f(outfile, std::ios::app);
129 for(
size_t i = 0; i < size; ++i){
138 std::cerr <<
"logParams() failed to open file at: " << outfile <<
"\n";
148 template<
size_t nc,
typename float_t>
149 std::vector<Eigen::Matrix<float_t,nc,1> > readInData(
const std::string& fileLoc)
152 std::vector<Eigen::Matrix<float_t,nc,1> > data;
156 std::ifstream ifs(fileLoc);
157 std::string one_number;
159 std::cerr <<
"readInData() failed to read data from: " << fileLoc <<
"\n";
163 while ( std::getline(ifs, line) ){
165 std::vector<float_t> data_row;
168 std::istringstream buff(line);
171 while(std::getline(buff, one_number,
',')){
172 data_row.push_back(std::stod(one_number));
175 }
catch (
const std::invalid_argument& ia){
176 std::cerr <<
"Invalid Argument: " << ia.what() <<
"\n";
181 Eigen::Map<Eigen::Matrix<float_t,nc,1> > drw(&data_row[0], nc);