MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
core.hpp File Reference
#include <type_traits>
Include dependency graph for core/mtcore/math/core.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  mtcore
 Core library for C++ with Zig-related functionality.
 
namespace  mtcore::math
 Math utilities, often with constexpr support.
 

Functions

template<typename T, typename R = double>
constexpr R mtcore::math::floor_constexpr (T num) noexcept
 Constexpr floor function.
 
template<typename T, typename R = double>
constexpr R mtcore::math::ceil_constexpr (T num) noexcept
 Constexpr ceil function.
 
template<typename T, typename R = T>
constexpr R mtcore::math::floor (T num) noexcept
 Floors a number with support for constexpr and fast runtime compilation.
 
template<typename T, typename R = T>
constexpr R mtcore::math::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 mtcore::math::mod (L left, R right) noexcept
 Calculates the mathematical mod of two numbers.
 
template<typename T>
constexpr auto mtcore::math::mod_range (T x, i64 a, i64 b) noexcept -> T
 x mod [a..b)
 
template<typename L, typename R, typename Res = L>
constexpr auto mtcore::math::amod (L x, R y) noexcept -> Res
 x mod [1..y]
 
template<typename T, typename R = T>
constexpr auto mtcore::math::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 mtcore::math::sign (const T &v)
 Gets the sign (1 for positive, -1 for negative, 0 for zero)
 
template<typename L>
constexpr L mtcore::math::abs (L l)
 Gets absolute value of a number.
 
template<typename T>
constexpr T mtcore::math::int_pow (T val, int exp)
 Raises to an integer power (positive or negative)
 
template<std::integral T>
constexpr T mtcore::math::gcd (T a, T b)
 Calculates the GCD (Greatest Common Divisor) of two integer numbers.
 
template<std::integral T>
constexpr T mtcore::math::lcm (T a, T b)
 Calculates the LCM (Least Common Multiple) of two integer numbers.