Polynomial roots via eigenvalues of the companion matrix#1131
Polynomial roots via eigenvalues of the companion matrix#1131NAThompson wants to merge 1 commit intodevelopfrom
Conversation
ebc1f48 to
2344f88
Compare
|
@jzmaddock : I did test it! @mborland , @jzmaddock : Quick question: Given a floating point type |
2344f88 to
4e6c0ce
Compare
Ugh, seems to be a bridge we haven't crossed yet. However, Note that in order to use multiprecision types with Eigen we need to include <boost/multiprecision/eigen.hpp> which specializes a bunch of Eigen traits classes. I guess to avoid nasty surprises this header should include that when available, though it adds an often not needed dependency :( The static_assert on is_floating_point would have to go as well... |
3607f34 to
5df7bca
Compare
Meh, who cares. Got rid of it.
I did the following: #if __has_include(<Eigen/Eigenvalues>)
#include <Eigen/Eigenvalues>
#include <complex> // roots are complex numbers.
#if __has_include(<boost/multiprecision/eigen.hpp>)
#include <boost/multiprecision/eigen.hpp>
#include <boost/math/cstdfloat/cstdfloat_complex_std.hpp>
#endif
#endifI don't feel too bad about this . . .
Suffering just a bit on this one: |
We really shouldn't need that, and it might get rid of the error? And of course I should have said |
Got rid of it; now I'm here: Looks like this is a pure Eigen/Multiprecision interop issue? For example, this: #include <Eigen/Dense>
#include <Eigen/Eigenvalues>
#include <boost/multiprecision/eigen.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
using boost::multiprecision::cpp_bin_float_100;
int main() {
Eigen::Matrix<cpp_bin_float_100, Eigen::Dynamic, Eigen::Dynamic> A = Eigen::Matrix<cpp_bin_float_100, Eigen::Dynamic, Eigen::Dynamic>::Identity(3,3);
Eigen::EigenSolver<decltype(A)> es;
es.compute(A, /*computeEigenvectors=*/ false);
auto eigs = es.eigenvalues();
for (auto eig : eigs) {
std::cout << eig << "\n";
}
}yields the same error: Naively I feel like I should submit this to Eigen and see how much they want to prioritize multiprecision integration. |
|
Ok, upon further investigation is appears that Eigen has the following lines of code everywhere: typedef std::complex<RealScalar> ComplexScalar;I think we could probably convince them to do: using std::complex;
typedef complex<RealScalar> ComplexScalar;but I doubt we could get them to agree to using std::complex;
using std::polar;
typedef decltype(polar(RealScalar(), RealScalar()) ComplexScalar;So we may have to construct the bridge before we can get multiprecision integration. |
5df7bca to
04bd67a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1131 +/- ##
===========================================
- Coverage 93.71% 93.69% -0.02%
===========================================
Files 771 771
Lines 61105 61105
===========================================
- Hits 57264 57254 -10
- Misses 3841 3851 +10
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
|
Well, I was going to say we should file a bug report again Eigen... and tried but gitlab tied me up in circles and I gave up :( |
Done: https://gitlab.com/libeigen/eigen/-/issues/2818; I do have some worry that they'll set it to WONTFIX until we have some canonical way of providing |
We won't WONTFIX ;). But you'll need to provide the merge request.
Provided a suggestion on the Eigen bug. Not really a "trick", but we have some traits you can use. Otherwise, you could explicitly specialize |
|
Thanks @cantonios for the prompt reply.
We're looking at that now, as you say specializing |
Why do you need to? You should be able to rig it up so that non-members are found via ADL. e.g. https://godbolt.org/z/fxTb8c8cf
The better way (at least for Eigen) is to add an |
For sure, those overloads can be found via ADL, my expectation is that most users using
Yes, that's what we were hoping for ;) |
Yes, this is usually true, but arguably a bug on the users' end if they expect it to work with custom types. Besides, you still have this issue if you don't specialize |
No description provided.