Add NumTraits::digits10() function based on numeric_limits::digits10 and make use of it for printing matrices.

This commit is contained in:
Gael Guennebaud
2016-07-25 11:13:01 +02:00
parent 5f03584752
commit 8fffc81606
2 changed files with 50 additions and 23 deletions

View File

@@ -125,31 +125,17 @@ DenseBase<Derived>::format(const IOFormat& fmt) const
namespace internal {
template<typename Scalar, bool IsInteger>
struct significant_decimals_default_impl
{
typedef typename NumTraits<Scalar>::Real RealScalar;
static inline int run()
{
using std::ceil;
using std::log10;
return cast<RealScalar,int>(ceil(-log10(NumTraits<RealScalar>::epsilon())));
}
};
template<typename Scalar>
struct significant_decimals_default_impl<Scalar, true>
{
static inline int run()
{
return 0;
}
};
// NOTE: This helper is kept for backward compatibility with previous code specializing
// this internal::significant_decimals_impl structure. In the future we should directly
// call digits10() which has been introduced in July 2016 in 3.3.
template<typename Scalar>
struct significant_decimals_impl
: significant_decimals_default_impl<Scalar, NumTraits<Scalar>::IsInteger>
{};
{
static inline int run()
{
return NumTraits<Scalar>::digits10();
}
};
/** \internal
* print the matrix \a _m to the output stream \a s using the output format \a fmt */