pytorch/c10/util/MathConstants.cpp
Nikita Shulga de8cd6b201 [BE] Replace M_PI with c10::pi constexpr variable (#50819)
Summary:
Also, get rid of MSVC specific `_USE_MATH_DEFINES`

Test at compile time that c10::pi<double> == M_PI

Pull Request resolved: https://github.com/pytorch/pytorch/pull/50819

Reviewed By: albanD

Differential Revision: D25976330

Pulled By: malfet

fbshipit-source-id: 8f3ddfd58a5aa4bd382da64ad6ecc679706d1284
2021-01-22 15:15:31 -08:00

12 lines
274 B
C++

// define constants like M_PI and C keywords for MSVC
#ifdef _MSC_VER
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#endif
#include <c10/util/MathConstants.h>
#include <math.h>
static_assert(M_PI == c10::pi<double>, "c10::pi<double> must be equal to M_PI");