Template Class FloatMatrixFormatter
Defined in File formatters.hpp
Inheritance Relationships
Derived Type
public Eigen::MatrixFormatter< Derived, Scalar, typename ecl::enable_if< ecl::is_float< Scalar > >::type >
(Template Class MatrixFormatter< Derived, Scalar, typename ecl::enable_if< ecl::is_float< Scalar > >::type >)
Class Documentation
-
template<typename Derived>
class FloatMatrixFormatter Formatter for Eigen matrix type.
I want make it formatting any types of eigen
- Todo:
specialise the formatting; now it just support the float type only.
- Template Parameters:
Derived – : MatrixBase’s type which specify the matrix as vector, matrix with any storage type
Subclassed by Eigen::MatrixFormatter< Derived, Scalar, typename ecl::enable_if< ecl::is_float< Scalar > >::type >
Public Functions
-
inline FloatMatrixFormatter(const int &w = -1, const unsigned int &p = 2)
Default constructor.
Initialises the format tags for width, and precision.
- Parameters:
w – : width (default - no width constraints)
p – : the number of decimal places of precision (default - 4)
-
inline virtual ~FloatMatrixFormatter()
-
inline FloatMatrixFormatter<Derived> &precision(const unsigned int &p)
Sets the precision format parameter.
Sets the precision format parameter.
- Parameters:
p – : the number of decimal places of precision.
- Returns:
FloatMatrixFormatter& : this formatter readied for use with a stream.
-
inline FloatMatrixFormatter<Derived> &width(const int &w)
Sets the width format parameter.
Sets the width format parameter.
- Parameters:
w – : the width to use for inserted floats (-1 is no width constraint).
- Returns:
FloatMatrixFormatter& : this formatter readied for use with a stream.
-
inline unsigned int precision()
Returns the current precision setting.
- Returns:
unsigned int : the precision value.
-
inline int width()
Returns the current width setting.
- Returns:
int : the witdh value (-1 for no width constraint).
-
inline FloatMatrixFormatter<Derived> &operator()(const Derived &matrix)
Format a matrix with permanently stored precision/width.
This function directly formats the specified input value with the stored settings.
Vector2d v; v << 1.0, 2.0; Format<Vector2d> format; cout << format(v) << endl;
- Parameters:
matrix – : the matrix to be formatted (gets temporarily stored as a pointer).
- Returns:
FloatMatrixFormatter& : this formatter readied for use with a stream.
-
inline FloatMatrixFormatter<Derived> &operator()(const Derived &matrix, const int &w, const unsigned int &p)
Format a matrix with temporarily specified precision/width.
This function directly formats the specified input value and temporary settings.
Vector2d v; v << 1.0, 2.0; Format<Vector2d> format; cout << format(v,3,-1) << endl; // precision of 3 and no width constraint
- Parameters:
matrix – : the matrix to be formatted (gets temporarily stored as a pointer).
w – : the width to use for inserted floats (-1 is no width constraint).
p – : the number of decimal places of precision.
- Returns:
FloatMatrixFormatter& : this formatter readied for use with a stream.
Friends
-
template<typename OutputStream, typename Derived_>
friend OutputStream &operator<<(OutputStream &ostream, FloatMatrixFormatter<Derived_> &formatter) Stream the formatter.
Insertion operator for sending the formatter to an output stream.
- Parameters:
ostream – : the output stream.
formatter – : the formatter to be inserted.
- Template Parameters:
OutputStream – : the type of the output stream to be inserted into.
Derived – : matrix type.
- Throws:
StandardException – : throws if the formatter has un-specified _matrix [debug mode only]
- Returns:
OutputStream : continue streaming with the updated output stream.