MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::math Namespace Reference

Math utilities, often with constexpr support. More...

Classes

struct  AddRatios
 Template to add two std::ratio numbers. More...
 
struct  AddRatios< std::ratio< N1, D1 >, std::ratio< N2, D2 > >
 
struct  GCD
 Template to get GCD of numbers. More...
 
struct  GCD< A, 0 >
 
struct  IntPowRatio
 
struct  IntPowRatioImpl
 Template to get the integer power (positive or negative) of a ratio. More...
 
struct  IntPowRatioImpl< std::ratio< N, D >, 0, false, false, true >
 
struct  IntPowRatioImpl< std::ratio< N, D >, Pow, false, false, false >
 
struct  IntPowRatioImpl< std::ratio< N, D >, Pow, Odd, true, false >
 
struct  IntPowRatioImpl< std::ratio< N, D >, Pow, true, false, false >
 
struct  InvertRatio
 Template to invert a ratio number. More...
 
struct  InvertRatio< std::ratio< Num, Den > >
 
struct  LCM
 Template to get LCM of numbers. More...
 
struct  MultRatios
 Template to multiply two std::ratio numbers. More...
 
struct  MultRatios< std::ratio< N1, D1 >, std::ratio< N2, D2 > >
 
struct  NegateRatio
 Template to negate the power of a ratio. More...
 
struct  NegateRatio< std::ratio< Num, Den > >
 
struct  RatioParts
 Template to get the Numerator and Denominator of a std::ratio. More...
 
struct  RatioParts< std::ratio< Num, Den > >
 

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.
 

Detailed Description

Math utilities, often with constexpr support.