This bugzilla service is closed. All entries have been migrated to
Bug 787 - MPRealSupport and StableNorm
Summary: MPRealSupport and StableNorm
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2014-04-05 15:56 UTC by Freddie Witherden
Modified: 2019-12-04 13:12 UTC (History)
1 user (show)


Description Freddie Witherden 2014-04-05 15:56:26 UTC
The mpfr::mpreal type defines the std::numeric_limits<>::digits field to be a function as opposed to a constant.  This is an unfortunate -- albeit necessary -- violation of the C++ standard.

The stable norm kernel, however, is incompatible with this.  Specifically:

      it    = std::numeric_limits<RealScalar>::digits;                // number of base-beta digits in mantissa

It also appears as if the kernel itself is not set-up to handle types whose precisions can change at runtime (due to the use of a static initialized marker).

Therefore it may be worth defining a specialization of stable norm specifically for mpfr::mpreal that takes into account the quirks associated with the type.
Comment 1 Simon Praetorius 2017-03-27 10:33:59 UTC
Since the issue is not yet solved, I've submitted a PullRequest that adresses this problem.

Basic idea: Add a member to `NumTraits` for `digits()`. There is already a `digits10()` member, that is specialized for `mpfr::mpreal`, but not yet the digits member. 

The implementation is a straight forward copy of `digits10`, but w.r.t. basis 2. Then, a specialization of `NumTraits<mpfr::mpreal>` is added, that calls the corresponding `std::numeric_limits<mpfr::mpreal>::digits()` method.

In `StableNorm` the call for `std::numeric_limits<T>::digits` is replaced by `NumTraits<T>::digits()` that has a fall-back to the former one.
Comment 2 Nobody 2019-12-04 13:12:14 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.