I have a large vector.
The ways that I use multiply the run-time of the program hugely. The first is write all values to a string as they are calculated using
Maybe I have missed something, but what is wrong with:
std::ofstream f("somefile.txt"); for(vector::const_iterator i = v.begin(); i != v.end(); ++i) { f << *i << '\n'; }
That avoids having to do potentially quadratic string concatenation, which I assume is what's killing your run-time.