Skip to content
Snippets Groups Projects
Commit 361398a6 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

COMP: make mathematical constants constexpr

- these are compile-time constants and can be marked as such in C++11.
parent a4b826aa
Branches
Tags
No related merge requests found
...@@ -47,13 +47,13 @@ namespace mathematical ...@@ -47,13 +47,13 @@ namespace mathematical
static const char* const group = "mathematical"; static const char* const group = "mathematical";
const scalar e(M_E); constexpr scalar e(M_E);
const scalar pi(M_PI); constexpr scalar pi(M_PI);
const scalar twoPi(2*pi); constexpr scalar twoPi(2*M_PI);
const scalar piByTwo(0.5*pi); constexpr scalar piByTwo(0.5*M_PI);
//- Euler's constant //- Euler's constant
const scalar Eu(0.57721566490153286060651209); constexpr scalar Eu(0.57721566490153286060651209);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
...@@ -44,14 +44,12 @@ namespace Foam ...@@ -44,14 +44,12 @@ namespace Foam
//- Conversion from degrees to radians //- Conversion from degrees to radians
inline constexpr scalar degToRad(const scalar deg) noexcept inline constexpr scalar degToRad(const scalar deg) noexcept
{ {
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0); return (deg*M_PI/180.0);
} }
//- Conversion from radians to degrees //- Conversion from radians to degrees
inline constexpr scalar radToDeg(const scalar rad) noexcept inline constexpr scalar radToDeg(const scalar rad) noexcept
{ {
//return (rad*180.0/Foam::constant::mathematical::pi);
return (rad*180.0/M_PI); return (rad*180.0/M_PI);
} }
...@@ -71,14 +69,12 @@ inline constexpr scalar paToAtm(const scalar pa) noexcept ...@@ -71,14 +69,12 @@ inline constexpr scalar paToAtm(const scalar pa) noexcept
//- User literal for degrees to radians conversion (integers) //- User literal for degrees to radians conversion (integers)
inline constexpr scalar operator "" _deg(unsigned long long int deg) noexcept 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); return (deg*M_PI/180.0);
} }
//- User literal for degrees to radians conversion (floats) //- User literal for degrees to radians conversion (floats)
inline constexpr scalar operator "" _deg(long double deg) noexcept inline constexpr scalar operator "" _deg(long double deg) noexcept
{ {
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0); return (deg*M_PI/180.0);
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment