Registered Member
|
Hi Eigen,
I use Eigen in combination with Boost.Multiprecision to solve polynomial systems over the complex numbers. Project Bertini located at https://github.com/bertiniteam/b2 . Ok, enough vague background. Here's my current issue. In Eigen's current dev branch, checked out as of 2016.06.13 (as well as one I checked out 2016.06.01), I cannot print certain matrices to output streams, when using Boost.Multiprecision wrappers around MPFR, with expression templates turned ON. Importantly, this issue is NOT present in the 3.3-beta1 currently available from the Eigen website. I believe the clang error message is the most useful piece of evidence to post, so here it is:
So some commit between 3.3-beta1 and June 1 2016 broke the ceil function, it appears. In particular, since Boost.Multiprecision with expression templates on returns another expression from its ceil, Eigen fails to compile against certain code. I was not sure that my particular code generating this error is useful, but will happily post code or link to the files in my repo if desired. -- Brief aside. While I was looking at Eigen/src/Core/MathFunctions.h:970 in an effort to ensure that there wasn't some obvious-to-me fix (there wasn't), I noticed a troubling (to me) #define at the top of that file, too: #define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L This scares me because if I use more than however many digits are in that #define during computation, Eigen may be getting a truncated representation of pi, right? How is this #define used? Wanted to mention it before it slipped my mind. -- For completeness sake, here are some previous posts related, all ultimately resolved. The Boost ticket is the most relevant, working on the interaction between expression templates and Eigen. https://svn.boost.org/trac/boost/ticket/11149 https://forum.kde.org/viewtopic.php?f=74&t=133221 https://forum.kde.org/viewtopic.php?f=74&t=128222 |
Registered Member
|
I will briefly follow up, and mention that ceil() has given me problems in the past, too, separately from Eigen, so this is possibly jointly an Eigen and Boost.Multiprecision problem. In particular, I located these two code samples from within my own codebase:
and
so I take away that I myself am passing the results of ceil(mpfr_float) through a constructor for another mpfr_float before doing something else with it. I hope this is useful in finding a solution to this problem! |
Moderator
|
The regression has probably been introduced by changeset 0cf5d7f1bff (for CUDA compatibility purposes):
where numext::ceil is implemented as:
I guess that the problem is that because to expression templates, here T is not a mpfr_float but some expression, and thus the return type cannot be of type T. A workaround would be to call numext::ceil<RealScalar>(....), thus effectively disable expression templates here. Of course, in C++14, we could properly implement numext::ceil, but in c++98 I'm not sure we can get the result type with automatic ADL. |
Registered Member
|
tried, and it worked. however, there is another problem which I got to after compilation succeeded on my core. also related to expression templates, i believe. here's the error:
I took your previous fix, and applied at the two sites needed to resolve the two similar errors, one given above. The two sites were Eigen/src/QR/ColPivHouseholderQR.h:493, Eigen/src/QR/ColPivHouseholderQR.h:544. The fix was numext::abs2 --> numext::abs2<RealScalar>. With this, my entire computational core and test suites once again compile with 3.3, as of yesterday's pull. Will you please confirm that these sets of changes (to Core/IO and QR/ColPivHouseholderQR) are incorporated into Eigen? Thanks very much for your help!!!! |
Moderator
|
Actually, I'm not 100% sure yet how to properly handle this issue as there are many more occurrences that would need to be fixed, and bypassing ET is not completely satisfactory.
|
Registered Member
|
Ok, thanks for letting me know. I'll await your further reply! Thanks!
|
Registered Member
|
any further information on a possible fix?
|
Registered Member
|
Rev 9265 still exhibits problems with ceil for me.
|
Moderator
|
You might try the following patch with -std=c++14:
|
Registered Member
|
what commit should i be at before trying this? thanks!!!!!!!
|
Registered Member
|
My project uses C++14 anyway, so trying this out was no trouble at all. The patch didn't apply perfectly to the commit I worked from, number 9348, pulled July 25 2016. Nonetheless, the patch solved my compilation problem, I can compile my entire library, and run my entire test suite again.
I am working on introducing expression templates for complexes in addition to the reals, so will let you know if I encounter any more problems in this vein. Thanks for the help!!! |
Moderator
|
Finally, I went with explicit casts from expressions to actual scalar. Only a few changes were required regarding calls to min/max to make it works with all our matrix decompositions. See the respective new unit test:
https://bitbucket.org/eigen/eigen/src/a ... ew-default for some required specializations. |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]