From 115591b9e37c0400c8a529728cda6215a76b27d6 Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Wed, 18 Aug 2021 11:35:02 -0700 Subject: [PATCH] Workaround VS 2017 arg bug. In VS 2017, `std::arg` for real inputs always returns 0, even for negative inputs. It should return `PI` for negative real values. This seems to be fixed in VS 2019 (MSVC 1920). (cherry picked from commit 2b410ecbefea1bf4b9d50decb946a4ebe4a73f98) --- Eigen/src/Core/MathFunctions.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index d7ac4d64d..61b78f4f2 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -572,7 +572,9 @@ struct rint_retval * Implementation of arg * ****************************************************************************/ -#if EIGEN_HAS_CXX11_MATH +// Visual Studio 2017 has a bug where arg(float) returns 0 for negative inputs. +// This seems to be fixed in VS 2019. +#if EIGEN_HAS_CXX11_MATH && (!EIGEN_COMP_MSVC || EIGEN_COMP_MSVC >= 1920) // std::arg is only defined for types of std::complex, or integer types or float/double/long double template::IsComplex || is_integral::value