Skip to content

Commit

Permalink
Make sentinels constexpr and move them
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jan 22, 2020
1 parent ede6e7e commit 3f29600
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/core/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ bool thermo_virtual = true;

using Thermostat::GammaType;

namespace {
/** @name Integrators parameters sentinels.
* These functions return the sentinel value for the Langevin/Brownian
* parameters, indicating that they have not been set yet.
*/
/*@{*/
constexpr double sentinel(double) { return -1.0; }
Utils::Vector3d sentinel(Utils::Vector3d) { return {-1.0, -1.0, -1.0}; }
constexpr double set_nan(double) { return NAN; }
Utils::Vector3d set_nan(Utils::Vector3d) { return {NAN, NAN, NAN}; }
/*@}*/
} // namespace

GammaType langevin_gamma = sentinel(GammaType{});
GammaType langevin_gamma_rotation = sentinel(GammaType{});
GammaType langevin_pref1;
Expand Down
15 changes: 15 additions & 0 deletions src/core/thermostat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ using GammaType = double;
#endif
} // namespace Thermostat

namespace {
/** @name Integrators parameters sentinels.
* These functions return the sentinel value for the Langevin/Brownian
* parameters, indicating that they have not been set yet.
*/
/*@{*/
constexpr double sentinel(double) { return -1.0; }
constexpr Utils::Vector3d sentinel(Utils::Vector3d) {
return {-1.0, -1.0, -1.0};
}
constexpr double set_nan(double) { return NAN; }
constexpr Utils::Vector3d set_nan(Utils::Vector3d) { return {NAN, NAN, NAN}; }
/*@}*/
} // namespace

/************************************************
* exported variables
************************************************/
Expand Down

0 comments on commit 3f29600

Please sign in to comment.