Registered Member
|
Hi Eigen,
I use Eigen for linear algebra in Bertini, a numerical multivariate polynomial system solver. I have enjoyed great success so far with Eigen 3.2.x, with my custom complex type using Boost.Multiprecision's mpfr_float type. I have two issues. One is scalar multiplication of matrices of my complex type against integers. The other is a compiler error from Eigen 3.3-beta1. The first issue: creation of temporaries when converting integral types to my complex type are expensive, and this must be avoided. I am concerned about scalars magically changing type from integers to floating points, incurring the cost of construction of a multiple precision complex number. Second, when I compile my library against 3.3-beta1, I am getting ambiguous operator * for right scalar multiplication. Not left, just right. I have not put together a minimal example, as that would take several files. See github.com/bertiniteam/b2 if you want full code. For now, believe that I have a typical complex class defined as one would. I then create the NumTraits, etc, for Eigen. Below is some code that demonstrates my errors: -- The code enabling scalar multiplication by other types than the main data type, or its Real or Nested type. see viewtopic.php?f=74&t=111176
-- The test code which fails:
For the errors, it's the scalar multiplication on the right that I am working on. The error exists independently of the scalar_product_traits templates. -- The errors I am trying to solve, again, are ambiguous operator errors from scalar multiplication on the right:
The deeper issue I see here is that I would really like to be able to use scalar multiplication by integers of various types, as construction of the multiprecision complex type from integers is expensive, including a heap allocation from mpfr. So resolving the ambiguous operator is the biggest hurdle I am having right now for users wanting Eigen 3.3, but getting integer-multipleprecision arithmetic enabled without temporaries holding those integers is a high priority too. -- please note (in an effort to be complete) that the scalar_product_traits are needed for multiplication on the left, as without, i get error (eigen 3.2.7):
this is true when using the current dev 3.3-beta1, the unstable dev, and 3.2. Hence, the scalar_product_traits are necessary. -- Thanks a ton for reading, and helping! |
Moderator
|
Indeed, so far Eigen provides scalar operator* only with Scalar and Real types, so in your case "complex<mp>" and "mp". I guess that both your complex class and "mp" have a ctor taking an integer? Then I do understand the ambiguity, but I don't understand why it does not show up with 3.2! Prototypes are the same...
Actually, fixing the second issue (conversion) would also fix the former, so maybe we could look at it first. One possibility would be to declare a generic operator* with SFINAE to enable it based on scalar_product_traits, for instance:
You can try it by adding it in plugins/CommonCwiseUnaryOps.h (and doing the same for the non-friend version, that is left multiply). Let me known how this is working. |
Moderator
|
I've pushed such changes: https://bitbucket.org/eigen/eigen/commits/d896d06d500d, so you can simply "hg pull -u", and everything should be fine!
|
Registered Member
|
the mentioned commit https://bitbucket.org/eigen/eigen/commits/d896d06d500d does indeed solve the ambiguous operator problem. Thanks!
|
Registered Member
|
Rules of multiplication can be found on Aztekium site - http://www.aztekium.pl/master.
Very helpful, really |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]