Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/// \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
You can’t perform that action at this time.