I am working on a matrix library. At the moment I am trying to write a function that will display the given matrix in the console.
However I don't really have any good idea how to get started. I mean, which stream should I use (for example iostream or stringstream), how to make formatting in details?
The main requirements are:
1) Display the numbers in given precision in fixed format, but if the length of resulting output in fixed format is too big, than convert (only this matrix element) to scientific format. (therefore I hesitate if I should use stringstream, as it easily alllows to check the length of the resulting output)
2) There should exist easy way of redirecting the stream to file.
3) It should be possibly efficient, however this is not the main goal
And other thing: should I buffer the output and then print the whole thing, or better to cout element after element. Won't be using stringstream for formatting, and then using cout for printing too slow?
I really need some general directions (but code snippets are very welcome too).
Thanks in advance,
Misery
Edited by Misery, 26 December 2012 - 05:33 PM.






