Re: [eigen] no matching function for call to 'abs(const float&)'

[ Thread Index | Date Index | More Archives ]

That's definitely a problem with your cmath (which is included as soon as you include Eigen, no need to add it manually). The fix you proposed is fine for your purpose, but you will need to redo it each time you change your version of eigen. I think it is best to include something like
namespace std
  float abs(float f) { return f>=0?f:-f; }
before including Eigen

Best regards,
Adrien Escande

On Friday, August 28, 2015, Ilja Honkonen <ilja.j.honkonen@xxxxxxxx> wrote:
cmath has been included.
 > > OK, replacing line 44 of Eigen/src/Core/functors/UnaryFunctors.h with:
 > > EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator()
 > > (const Scalar& a) const { using std::fabs; return fabs(a); }
 > Will this work even if cmath hasn't been included at all?

And if it's not? Eigen cannot control what has been included before or after Eigen headers and I'm guessing your fix would break as soon as someone uses that code without including cmath first.

Mail converted by MHonArc 2.6.19+