Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77665017
write.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 15, 18:45
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Aug 17, 18:45 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19905340
Attached To
R7571 SP4E-TB-TL-FR
write.cc
View Options
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include "write.hh"
WriteSeries::WriteSeries(Series& series, unsigned int maxiter, std::string separator) : DumperSeries(series) {
this->maxiter = maxiter;
this->separator = separator;
}
void WriteSeries::dump() {
// write sequential iterations to file
std::string sname = this->series.getName();
std::transform(sname.begin(), sname.end(), sname.begin(), ::tolower);
std::string ext;
if (this->separator == ",") {
ext = ".csv";
} else if (this->separator == " " || this->separator == "\t") {
ext = ".txt";
} else if (this->separator == "|") {
ext = ".psv";
}
std::string filename = sname + ext;
std::cout << filename << std::endl;
std::ofstream fout(filename.c_str());
fout << "iteration" << separator << "value" << std::endl;
for (unsigned int N = 1; N < this->maxiter + 1; ++N) {
fout << N << separator << this->series.compute(N) << std::endl;
}
fout.close();
}
Event Timeline
Log In to Comment