Project-2/src/utils.cpp
2023-09-20 16:41:47 +02:00

26 lines
623 B
C++

/** @file utils.cpp
* @brief Implementation of the utils
*
* @author Cory Alexander Balaton (coryab)
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
* @bug No known bugs
*/
#include "utils.hpp"
std::string scientific_format(double d, int width, int prec)
{
std::stringstream ss;
ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
return ss.str();
}
std::string scientific_format(const std::vector<double>& v, int width, int prec)
{
std::stringstream ss;
for(double elem : v) {
ss << scientific_format(elem, width, prec);
}
return ss.str();
}