MT Core (C++)
Core library for replacing C++ standard in project usage
|
Math utilities, often with constexpr support. More...
Functions | |
template<typename T, typename R = double> | |
constexpr R | floor_constexpr (T num) noexcept |
Constexpr floor function. | |
template<typename T, typename R = double> | |
constexpr R | ceil_constexpr (T num) noexcept |
Constexpr ceil function. | |
template<typename T, typename R = T> | |
constexpr R | floor (T num) noexcept |
Floors a number with support for constexpr and fast runtime compilation. | |
template<typename T, typename R = T> | |
constexpr R | ceil (T v) noexcept |
Ceils a number with support for constexpr and fast runtime compilation. | |
template<typename L, typename R, typename Res = L> | |
constexpr Res | mod (L left, R right) noexcept |
Calculates the mathematical mod of two numbers. | |
template<typename T> | |
constexpr auto | mod_range (T x, i64 a, i64 b) noexcept -> T |
x mod [a..b) | |
template<typename L, typename R, typename Res = L> | |
constexpr auto | amod (L x, R y) noexcept -> Res |
x mod [1..y] | |
template<typename T, typename R = T> | |
constexpr auto | approx_eq (T x, R y, T epsilon=T{0.000001}) noexcept -> bool |
Checks if two numbers are approximately equal (within epsilon distance) | |
template<typename T> | |
constexpr int | sign (const T &v) |
Gets the sign (1 for positive, -1 for negative, 0 for zero) | |
template<typename L> | |
constexpr L | abs (L l) |
Gets absolute value of a number. | |
template<typename T> | |
constexpr T | int_pow (T val, int exp) |
Raises to an integer power (positive or negative) | |
template<std::integral T> | |
constexpr T | gcd (T a, T b) |
Calculates the GCD (Greatest Common Divisor) of two integer numbers. | |
template<std::integral T> | |
constexpr T | lcm (T a, T b) |
Calculates the LCM (Least Common Multiple) of two integer numbers. | |
Math utilities, often with constexpr support.