Replace M_LOG2E and M_LN2 with custom macros.

For these to exist we would need to define `_USE_MATH_DEFINES` before
`cmath` or `math.h` is first included.  However, we don't
control the include order for projects outside Eigen, so even defining
the macro in `Eigen/Core` does not fix the issue for projects that
end up including `<cmath>` before Eigen does (explicitly or transitively).

To fix this, we define `EIGEN_LOG2E` and `EIGEN_LN2` ourselves.
This commit is contained in:
Antonio Sanchez
2020-12-11 14:34:31 -08:00
parent e82722a4a7
commit c6efc4e0ba
7 changed files with 13 additions and 11 deletions

View File

@@ -668,7 +668,7 @@ Packet plog10(const Packet& a) { EIGEN_USING_STD(log10); return log10(a); }
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
Packet plog2(const Packet& a) {
typedef typename internal::unpacket_traits<Packet>::type Scalar;
return pmul(pset1<Packet>(Scalar(M_LOG2E)), plog(a));
return pmul(pset1<Packet>(Scalar(EIGEN_LOG2E)), plog(a));
}
/** \internal \returns the square-root of \a a (coeff-wise) */