mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-13 08:18:06 +08:00
move the computation of the number of significant digits to a templated helper struct, that can be specialized to custom types if needed. Should address this request:
http://forum.kde.org/viewtopic.php?f=74&t=86914
This commit is contained in:
parent
e6300efb5c
commit
8f99ae5ea4
@ -126,6 +126,16 @@ DenseBase<Derived>::format(const IOFormat& fmt) const
|
|||||||
return WithFormat<Derived>(derived(), fmt);
|
return WithFormat<Derived>(derived(), fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Scalar>
|
||||||
|
struct ei_significant_decimals_impl
|
||||||
|
{
|
||||||
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
static inline int run()
|
||||||
|
{
|
||||||
|
return (int) std::ceil(-ei_log(NumTraits<RealScalar>::epsilon())/ei_log(RealScalar(10)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* print the matrix \a _m to the output stream \a s using the output format \a fmt */
|
* print the matrix \a _m to the output stream \a s using the output format \a fmt */
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
@ -145,9 +155,7 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm
|
|||||||
{
|
{
|
||||||
if (NumTraits<Scalar>::HasFloatingPoint)
|
if (NumTraits<Scalar>::HasFloatingPoint)
|
||||||
{
|
{
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
explicit_precision = ei_significant_decimals_impl<Scalar>::run();
|
||||||
RealScalar explicit_precision_fp = std::ceil(-ei_log(NumTraits<Scalar>::epsilon())/ei_log(10.0));
|
|
||||||
explicit_precision = static_cast<std::streamsize>(explicit_precision_fp);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user