Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
#ifndef __UTILS__
#define __UTILS__
#include <armadillo>
#include <iomanip>
#include <sstream>
#include <string>
#include <sys/stat.h>
#include <vector>
#ifdef DBG
#define DEBUG(msg) \
std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl
#else
#define DEBUG(msg)
#endif
#define __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__)
namespace details {
inline std::string methodName(const std::string &pretty_function)
{
size_t colons = pretty_function.find("::");
size_t begin = pretty_function.substr(0, colons).rfind(" ") + 1;
size_t end = pretty_function.rfind("(") - begin;
return pretty_function.substr(begin, end) + "()";
}
} // namespace details
namespace utils {
std::string scientific_format(double d, int width = 20, int prec = 10);
std::string scientific_format(const std::vector<double> &v, int width = 20,
int prec = 10);
bool mkpath(std::string path, int mode = 0777);
std::string dirname(const std::string &path);
} // namespace utils
#endif
details::methodName
std::string methodName(const std::string &pretty_function)
Takes in the PRETTY_FUNCTION string and removes the return type.
Definition: utils.hpp:58
utils::mkpath
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:32
utils::scientific_format
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:16
utils::dirname
std::string dirname(const std::string &path)
Get the directory name of the path.
Definition: utils.cpp:58