Bugzilla – Bug 1182
Implementation of abs2_impl seems incorrect
Last modified: 2016-03-19 08:42:03 UTC
Created attachment 668 [details]
Possible fix for the problem mentioned above.
I am trying to write a program that uses a C++ wrappers around mpfr_t as complex and real types. While compiling, I got into trouble with the following code from Eigen/src/Core/MathFunctions.h.
typedef typename NumTraits<Scalar>::Real RealScalar;
static inline RealScalar run(const Scalar& x)
The compiler tries to instantiate the function run() for a complex type. The multiplication operator * for the complex type returns a complex value, not a real scalar as required. I think the intent here was to return real(x) * real(x) + imag(x) + imag(x). This also agrees with the name of the function.
Well, your suggestion is not good, since it could create overhead for real-valued abs2 calls.
I backported the implementation from the devel-branch to 3.2: