26 lines
623 B
C++
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();
|
|
}
|