Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F73605773
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
Tue, Jul 23, 02:24
Size
1 KB
Mime Type
text/x-c
Expires
Thu, Jul 25, 02:24 (2 d)
Engine
blob
Format
Raw Data
Handle
19233727
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(std::ostream & os) {
// 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