Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77732926
write_series.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
Fri, Aug 16, 03:01
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Aug 18, 03:01 (2 d)
Engine
blob
Format
Raw Data
Handle
19914296
Attached To
R7571 SP4E-TB-TL-FR
write_series.cc
View Options
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include "write_series.hh"
// Constructor
WriteSeries::WriteSeries(Series& series, unsigned int maxiter, std::string separator) : DumperSeries(series) {
this->maxiter = maxiter;
this->separator = separator;
}
// Compute and write serie on file
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 << "File " << filename.c_str() << " has been created." << 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