Commit 9f7b9346 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

added vector printing function

parent a9520fb6
......@@ -186,3 +186,21 @@ double calc_var(const vector<vector<int>> &vec) {
sqrs_ += pow(value, 2);
return sqrs_ / vec.size() / vec[0].size() - pow(calc_mean(vec), 2);
}
string vec2str(vector<int> vec) {
string str;
for (unsigned long i = 0; i < vec.size(); i++) {
if (i != vec.size() - 1) str += to_string(vec[i]) + " ";
else str += to_string(vec[i]);
}
return str;
}
string vec2str(vector<double> vec) {
string str;
for (unsigned long i = 0; i < vec.size(); i++) {
if (i != vec.size() - 1) str += to_string(vec[i]) + " ";
else str += to_string(vec[i]);
}
return str;
}
......@@ -40,4 +40,8 @@ double calc_var(const vector<int> &vec);
double calc_var(const vector<vector<int>> &vec);
string vec2str(vector<int> vec);
string vec2str(vector<double> vec);
#endif //MLMC_UTILITIES_HPP
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment