COMP: make mathematical constants constexpr

- these are compile-time constants and can be marked as such in C++11.
This commit is contained in:
Mark Olesen
2017-06-02 07:55:04 +02:00
parent a4b826aa1e
commit 361398a64a
2 changed files with 5 additions and 9 deletions

View File

@ -47,13 +47,13 @@ namespace mathematical
static const char* const group = "mathematical";
const scalar e(M_E);
const scalar pi(M_PI);
const scalar twoPi(2*pi);
const scalar piByTwo(0.5*pi);
constexpr scalar e(M_E);
constexpr scalar pi(M_PI);
constexpr scalar twoPi(2*M_PI);
constexpr scalar piByTwo(0.5*M_PI);
//- Euler's constant
const scalar Eu(0.57721566490153286060651209);
constexpr scalar Eu(0.57721566490153286060651209);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -44,14 +44,12 @@ namespace Foam
//- Conversion from degrees to radians
inline constexpr scalar degToRad(const scalar deg) noexcept
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0);
}
//- Conversion from radians to degrees
inline constexpr scalar radToDeg(const scalar rad) noexcept
{
//return (rad*180.0/Foam::constant::mathematical::pi);
return (rad*180.0/M_PI);
}
@ -71,14 +69,12 @@ inline constexpr scalar paToAtm(const scalar pa) noexcept
//- User literal for degrees to radians conversion (integers)
inline constexpr scalar operator "" _deg(unsigned long long int deg) noexcept
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0);
}
//- User literal for degrees to radians conversion (floats)
inline constexpr scalar operator "" _deg(long double deg) noexcept
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0);
}