template<std::uint64_t n>
struct StaticLog2
{
- static const int value = StaticLog2<n/2>::value+1; //!< Variable value used for recursive static calculation of Log2(int)
+ static const int value = StaticLog2<n / 2>::value
+ + 1; //!< Variable value used for recursive static calculation of Log2(int)
};
/*! \brief Specialization of StaticLog2<n> for n==1.
* \note This version of the overloaded function will assert that x is
* not negative.
*/
-unsigned int
-log2I(std::int32_t x);
+unsigned int log2I(std::int32_t x);
/*! \brief Compute floor of logarithm to base 2, 64 bit signed argument
*
* \note This version of the overloaded function will assert that x is
* not negative.
*/
-unsigned int
-log2I(std::int64_t x);
+unsigned int log2I(std::int64_t x);
/*! \brief Compute floor of logarithm to base 2, 32 bit unsigned argument
*
* \note This version of the overloaded function uses unsigned arguments to
* be able to handle arguments using all 32 bits.
*/
-unsigned int
-log2I(std::uint32_t x);
+unsigned int log2I(std::uint32_t x);
/*! \brief Compute floor of logarithm to base 2, 64 bit unsigned argument
*
* \note This version of the overloaded function uses unsigned arguments to
* be able to handle arguments using all 64 bits.
*/
-unsigned int
-log2I(std::uint64_t x);
+unsigned int log2I(std::uint64_t x);
/*! \brief Find greatest common divisor of two numbers
*
*
* \return Greatest common divisor of p and q
*/
-std::int64_t
-greatestCommonDivisor(std::int64_t p, std::int64_t q);
+std::int64_t greatestCommonDivisor(std::int64_t p, std::int64_t q);
/*! \brief Calculate 1.0/sqrt(x) in single precision
*
* \return 1.0/sqrt(x)
*/
-static inline float
-invsqrt(float x)
+static inline float invsqrt(float x)
{
- return 1.0F/std::sqrt(x);
+ return 1.0F / std::sqrt(x);
}
/*! \brief Calculate 1.0/sqrt(x) in double precision, but single range
*
* \return 1.0/sqrt(x)
*/
-static inline double
-invsqrt(double x)
+static inline double invsqrt(double x)
{
- return 1.0/std::sqrt(x);
+ return 1.0 / std::sqrt(x);
}
/*! \brief Calculate 1.0/sqrt(x) for integer x in double precision.
*
* \return 1.0/sqrt(x)
*/
-static inline double
-invsqrt(int x)
+static inline double invsqrt(int x)
{
return invsqrt(static_cast<double>(x));
}
*
* This routine is typically faster than using std::pow().
*/
-static inline float
-invcbrt(float x)
+static inline float invcbrt(float x)
{
- return 1.0F/std::cbrt(x);
+ return 1.0F / std::cbrt(x);
}
/*! \brief Calculate inverse sixth root of x in double precision
*
* This routine is typically faster than using std::pow().
*/
-static inline double
-invcbrt(double x)
+static inline double invcbrt(double x)
{
- return 1.0/std::cbrt(x);
+ return 1.0 / std::cbrt(x);
}
/*! \brief Calculate inverse sixth root of integer x in double precision
*
* This routine is typically faster than using std::pow().
*/
-static inline double
-invcbrt(int x)
+static inline double invcbrt(int x)
{
- return 1.0/std::cbrt(x);
+ return 1.0 / std::cbrt(x);
}
/*! \brief Calculate sixth root of x in single precision.
*
* This routine is typically faster than using std::pow().
*/
-static inline float
-sixthroot(float x)
+static inline float sixthroot(float x)
{
return std::sqrt(std::cbrt(x));
}
*
* This routine is typically faster than using std::pow().
*/
-static inline double
-sixthroot(double x)
+static inline double sixthroot(double x)
{
return std::sqrt(std::cbrt(x));
}
*
* This routine is typically faster than using std::pow().
*/
-static inline double
-sixthroot(int x)
+static inline double sixthroot(int x)
{
return std::sqrt(std::cbrt(x));
}
*
* This routine is typically faster than using std::pow().
*/
-static inline float
-invsixthroot(float x)
+static inline float invsixthroot(float x)
{
return invsqrt(std::cbrt(x));
}
*
* This routine is typically faster than using std::pow().
*/
-static inline double
-invsixthroot(double x)
+static inline double invsixthroot(double x)
{
return invsqrt(std::cbrt(x));
}
*
* This routine is typically faster than using std::pow().
*/
-static inline double
-invsixthroot(int x)
+static inline double invsixthroot(int x)
{
return invsqrt(std::cbrt(x));
}
*
* \return x^2
*/
-template <typename T>
-T
-square(T x)
+template<typename T>
+T square(T x)
{
- return x*x;
+ return x * x;
}
/*! \brief calculate x^3
*
* \return x^3
*/
-template <typename T>
-T
-power3(T x)
+template<typename T>
+T power3(T x)
{
- return x*square(x);
+ return x * square(x);
}
/*! \brief calculate x^4
*
* \return x^4
*/
-template <typename T>
-T
-power4(T x)
+template<typename T>
+T power4(T x)
{
return square(square(x));
}
*
* \return x^5
*/
-template <typename T>
-T
-power5(T x)
+template<typename T>
+T power5(T x)
{
- return x*power4(x);
+ return x * power4(x);
}
/*! \brief calculate x^6
*
* \return x^6
*/
-template <typename T>
-T
-power6(T x)
+template<typename T>
+T power6(T x)
{
return square(power3(x));
}
*
* \return x^12
*/
-template <typename T>
-T
-power12(T x)
+template<typename T>
+T power12(T x)
{
return square(power6(x));
}
*/
static inline real series_sinhx(real x)
{
- real x2 = x*x;
- return (1 + (x2/6.0_real)*(1 + (x2/20.0_real)*(1 + (x2/42.0_real)*(1 + (x2/72.0_real)*(1 + (x2/110.0_real))))));
+ real x2 = x * x;
+ return (1
+ + (x2 / 6.0_real)
+ * (1
+ + (x2 / 20.0_real)
+ * (1 + (x2 / 42.0_real) * (1 + (x2 / 72.0_real) * (1 + (x2 / 110.0_real))))));
}
/*! \brief Inverse error function, double precision.
* \return The inverse of the error function if the argument is inside the
* range, +/- infinity if it is exactly 1.0 or -1.0, and NaN otherwise.
*/
-double
-erfinv(double x);
+double erfinv(double x);
/*! \brief Inverse error function, single precision.
*
* \return The inverse of the error function if the argument is inside the
* range, +/- infinity if it is exactly 1.0 or -1.0, and NaN otherwise.
*/
-float
-erfinv(float x);
+float erfinv(float x);
/*! \brief Exact integer division, 32bit.
*
*/
constexpr int32_t exactDiv(int32_t a, int32_t b)
{
- return GMX_ASSERT(a%b == 0, "exactDiv called with non-divisible arguments"), a/b;
+ return GMX_ASSERT(a % b == 0, "exactDiv called with non-divisible arguments"), a / b;
}
//! Exact integer division, 64bit.
constexpr int64_t exactDiv(int64_t a, int64_t b)
{
- return GMX_ASSERT(a%b == 0, "exactDiv called with non-divisible arguments"), a/b;
+ return GMX_ASSERT(a % b == 0, "exactDiv called with non-divisible arguments"), a / b;
}
/*! \brief Round float to int