Skip to content

Commit

Permalink
Merge pull request #1395 from Atharva-Kanherkar/new-code
Browse files Browse the repository at this point in the history
  Migrated typedefs and changed const to constexpr
  • Loading branch information
ghutchis authored Oct 28, 2023
2 parents 58af023 + 49268ab commit 21faabd
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions avogadro/core/avogadrocore.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,57 +35,57 @@ typedef double Real;

/** Typedef for indices and sizes. */
typedef size_t Index;
const Index MaxIndex = std::numeric_limits<Index>::max();
constexpr Index MaxIndex = std::numeric_limits<Index>::max();

/** Used to represent an invalid atomic number. */
const unsigned char InvalidElement = 255;
constexpr unsigned char InvalidElement = 255;

/**
* Minimum value for atomic numbers that represent custom, non-elemental
* particles. */
const unsigned char CustomElementMin = 128;
constexpr unsigned char CustomElementMin = 128;

/**
* Maximum value for atomic numbers that represent custom, non-elemental
* particles. */
const unsigned char CustomElementMax = 254;
constexpr unsigned char CustomElementMax = 254;

/**
* Count of atomic number values that are used to represent custom,
* non-elemental particles. */
const unsigned char CustomElementCount =
constexpr unsigned char CustomElementCount =
CustomElementMax - CustomElementMin + 1;

/**
* @return True if @a atomicNumber denotes a custom element type.
*/
namespace Core {
inline bool isCustomElement(unsigned char atomicNumber)
inline constexpr bool isCustomElement(unsigned char atomicNumber)
{
return atomicNumber >= CustomElementMin && atomicNumber <= CustomElementMax;
}
}

/** Unit conversion factors. @{ */
const double PI_D = 3.141592653589793238462643;
const float PI_F = static_cast<float>(PI_D);
const Real PI = static_cast<Real>(PI_D);
constexpr double PI_D = 3.141592653589793238462643;
constexpr float PI_F = static_cast<float>(PI_D);
constexpr Real PI = static_cast<Real>(PI_D);

const double DEG_TO_RAD_D = PI_D / 180.0;
const float DEG_TO_RAD_F = static_cast<float>(DEG_TO_RAD_D);
const Real DEG_TO_RAD = static_cast<Real>(DEG_TO_RAD_D);
constexpr double DEG_TO_RAD_D = PI_D / 180.0;
constexpr float DEG_TO_RAD_F = static_cast<float>(DEG_TO_RAD_D);
constexpr Real DEG_TO_RAD = static_cast<Real>(DEG_TO_RAD_D);

const double RAD_TO_DEG_D = 180.0 / PI_D;
const float RAD_TO_DEG_F = static_cast<float>(RAD_TO_DEG_D);
const Real RAD_TO_DEG = static_cast<Real>(RAD_TO_DEG_D);
constexpr double RAD_TO_DEG_D = 180.0 / PI_D;
constexpr float RAD_TO_DEG_F = static_cast<float>(RAD_TO_DEG_D);
constexpr Real RAD_TO_DEG = static_cast<Real>(RAD_TO_DEG_D);

const double BOHR_TO_ANGSTROM_D = 0.52917721092;
const float BOHR_TO_ANGSTROM_F = static_cast<float>(BOHR_TO_ANGSTROM_D);
const Real BOHR_TO_ANGSTROM = static_cast<Real>(BOHR_TO_ANGSTROM_D);
constexpr double BOHR_TO_ANGSTROM_D = 0.52917721092;
constexpr float BOHR_TO_ANGSTROM_F = static_cast<float>(BOHR_TO_ANGSTROM_D);
constexpr Real BOHR_TO_ANGSTROM = static_cast<Real>(BOHR_TO_ANGSTROM_D);

const double ANGSTROM_TO_BOHR_D = 1.0 / BOHR_TO_ANGSTROM_D;
const float ANGSTROM_TO_BOHR_F = static_cast<float>(ANGSTROM_TO_BOHR_D);
const Real ANGSTROM_TO_BOHR = static_cast<Real>(ANGSTROM_TO_BOHR_D);
constexpr double ANGSTROM_TO_BOHR_D = 1.0 / BOHR_TO_ANGSTROM_D;
constexpr float ANGSTROM_TO_BOHR_F = static_cast<float>(ANGSTROM_TO_BOHR_D);
constexpr Real ANGSTROM_TO_BOHR = static_cast<Real>(ANGSTROM_TO_BOHR_D);
/** @} */

} // end Avogadro namespace
Expand Down

0 comments on commit 21faabd

Please sign in to comment.