Penning Trap Simulation Simulate particle behavior inside a Penning Trap

Loading...
Searching...
No Matches
utils.cpp
Go to the documentation of this file.
1
12#include "utils.hpp"
13
14std::string scientific_format(double d, int width, int prec)
15{
16 std::stringstream ss;
17 ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
18 return ss.str();
19}
20
21std::string scientific_format(const std::vector<double>& v, int width, int prec)
22{
23 std::stringstream ss;
24 for(double elem : v) {
25 ss << scientific_format(elem, width, prec);
26 }
27 return ss.str();
28}
scientific_format
std::string scientific_format(double d, int width, int prec)
Turns a double into a string written in scientific format.
Definition: utils.cpp:14
utils.hpp
Function prototypes and macros that are useful.