From 83e5b7656b6e3d68539584baf703ad30e96fa0de Mon Sep 17 00:00:00 2001 From: Deanna Hood Date: Sun, 22 Mar 2015 06:04:31 +1000 Subject: [PATCH] Use M_PI instead of acos(-1) for pi --- Eigen/src/Core/MathFunctions.h | 3 +-- test/array.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 734a5e373..787634081 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -421,8 +421,7 @@ struct round_retval EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { - const double pi = std::acos(-1.0); - return (x < 0.0) ? pi : 0.0; } + return (x < 0.0) ? M_PI : 0.0; } }; template diff --git a/test/array.cpp b/test/array.cpp index 0208ba7c9..efccd2b0c 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -237,7 +237,7 @@ template void array_real(const ArrayType& m) VERIFY_IS_APPROX(sinh(m1), 0.5*(exp(m1)-exp(-m1))); VERIFY_IS_APPROX(cosh(m1), 0.5*(exp(m1)+exp(-m1))); VERIFY_IS_APPROX(tanh(m1), (0.5*(exp(m1)-exp(-m1)))/(0.5*(exp(m1)+exp(-m1)))); - VERIFY_IS_APPROX(arg(m1), ((ArrayType)(m1<0))*std::acos(-1.0)); + VERIFY_IS_APPROX(arg(m1), ((ArrayType)(m1<0))*M_PI); VERIFY((round(m1) <= ceil(m1) && round(m1) >= floor(m1)).all()); VERIFY(isNaN(m1*0.0/0.0).all()); VERIFY(isInf(m1/0.0).all());