diff options
-rw-r--r-- | Eigen/src/Core/NumTraits.h | 3 | ||||
-rw-r--r-- | doc/CustomizingEigen.dox | 42 |
2 files changed, 20 insertions, 25 deletions
diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h index a688df504..7a1a3a9b5 100644 --- a/Eigen/src/Core/NumTraits.h +++ b/Eigen/src/Core/NumTraits.h @@ -75,7 +75,8 @@ struct default_digits10_impl<T,false,true> // Integer * \li An enum value \a IsSigned. It is equal to \c 1 if \a T is a signed type and to 0 if \a T is unsigned. * \li An enum value \a RequireInitialization. It is equal to \c 1 if the constructor of the numeric type \a T must * be called, and to 0 if it is safe not to call it. Default is 0 if \a T is an arithmetic type, and 1 otherwise. - * \li An epsilon() function which, unlike std::numeric_limits::epsilon(), returns a \a Real instead of a \a T. + * \li An epsilon() function which, unlike <a href="http://en.cppreference.com/w/cpp/types/numeric_limits/epsilon">std::numeric_limits::epsilon()</a>, + * it returns a \a Real instead of a \a T. * \li A dummy_precision() function returning a weak epsilon value. It is mainly used as a default * value by the fuzzy comparison operators. * \li highest() and lowest() functions returning the highest and lowest possible values respectively. diff --git a/doc/CustomizingEigen.dox b/doc/CustomizingEigen.dox index 607f86658..1b15c69a4 100644 --- a/doc/CustomizingEigen.dox +++ b/doc/CustomizingEigen.dox @@ -165,8 +165,7 @@ This other example adds support for the \c mpq_class type from <a href="https:// #include <boost/operators.hpp> namespace Eigen { - template<class> struct NumTraits; - template<> struct NumTraits<mpq_class> + template<> struct NumTraits<mpq_class> : GenericNumTraits<mpq_class> { typedef mpq_class Real; typedef mpq_class NonInteger; @@ -174,6 +173,7 @@ namespace Eigen { static inline Real epsilon() { return 0; } static inline Real dummy_precision() { return 0; } + static inline Real digits10() { return 0; } enum { IsInteger = 0, @@ -187,31 +187,25 @@ namespace Eigen { }; namespace internal { - template<> - struct significant_decimals_impl<mpq_class> - { - // Infinite precision when printing - static inline int run() { return 0; } - }; template<> struct scalar_score_coeff_op<mpq_class> { struct result_type : boost::totally_ordered1<result_type> { - std::size_t len; - result_type(int i = 0) : len(i) {} // Eigen uses Score(0) and Score() - result_type(mpq_class const& q) : - len(mpz_size(q.get_num_mpz_t())+ - mpz_size(q.get_den_mpz_t())-1) {} - friend bool operator<(result_type x, result_type y) { - // 0 is the worst possible pivot - if (x.len == 0) return y.len > 0; - if (y.len == 0) return false; - // Prefer a pivot with a small representation - return x.len > y.len; - } - friend bool operator==(result_type x, result_type y) { - // Only used to test if the score is 0 - return x.len == y.len; - } + std::size_t len; + result_type(int i = 0) : len(i) {} // Eigen uses Score(0) and Score() + result_type(mpq_class const& q) : + len(mpz_size(q.get_num_mpz_t())+ + mpz_size(q.get_den_mpz_t())-1) {} + friend bool operator<(result_type x, result_type y) { + // 0 is the worst possible pivot + if (x.len == 0) return y.len > 0; + if (y.len == 0) return false; + // Prefer a pivot with a small representation + return x.len > y.len; + } + friend bool operator==(result_type x, result_type y) { + // Only used to test if the score is 0 + return x.len == y.len; + } }; result_type operator()(mpq_class const& x) const { return x; } }; |