Created
June 28, 2013 10:46
-
-
Save davidshepherd7/5883871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// \short Indexed output function to print a matrix to the stream outfile | |
/// as i,j,a(i,j) for a(i,j)!=0 only with a specified precision. | |
void sparse_indexed_output(std::ostream &outfile, | |
const unsigned &precision, | |
const bool& output_bottom_right_entry_regardless=false) const | |
{ | |
// Note: we might have to specify "output_bottom_right_entry_regardless" | |
// as well (can't be a default). C++ can silently convert between | |
// unsigned and bool, so having a default set for | |
// output_bottom_right_entry_regardless would give the same function | |
// signature as the normal sparse_indexed_output. | |
// Set precision and store the previous value | |
unsigned old_precision = outfile.precision(); | |
outfile.precision(precision); | |
// Output as normal | |
sparse_indexed_output(outfile, output_bottom_right_entry_regardless); | |
// Restore the old value | |
outfile.precision(old_precision); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment