Stores a set of parameters controlling the way matrices are printed.
List of available parameters:
- precision number of digits for floating point values, or one of the special constants
StreamPrecision
and FullPrecision
. The default is the special value StreamPrecision
which means to use the stream's own precision setting, as set for instance using cout.precision(3)
. The other special value FullPrecision
means that the number of digits will be computed to match the full precision of each floating-point type.
- flags an OR-ed combination of flags, the default value is 0, the only currently available flag is
DontAlignCols
which allows to disable the alignment of columns, resulting in faster code.
- coeffSeparator string printed between two coefficients of the same row
- rowSeparator string printed between two rows
- rowPrefix string printed at the beginning of each row
- rowSuffix string printed at the end of each row
- matPrefix string printed at the beginning of the matrix
- matSuffix string printed at the end of the matrix
Example:
std::string sep = "\n----------------------------------------\n";
Matrix3d m1;
m1 << 1.111111, 2, 3.33333, 4, 5, 6, 7, 8.888888, 9;
IOFormat CommaInitFmt(StreamPrecision, DontAlignCols, ", ", ", ", "", "", " << ", ";");
IOFormat CleanFmt(4, 0, ", ", "\n", "[", "]");
IOFormat OctaveFmt(StreamPrecision, 0, ", ", ";\n", "", "", "[", "]");
IOFormat HeavyFmt(FullPrecision, 0, ", ", ";\n", "[", "]", "[", "]");
std::cout << m1 << sep;
std::cout << m1.format(CommaInitFmt) << sep;
std::cout << m1.format(CleanFmt) << sep;
std::cout << m1.format(OctaveFmt) << sep;
std::cout << m1.format(HeavyFmt) << sep;
Output:
- See also:
- DenseBase::format(), class WithFormat
Definition at line 63 of file IO.h.