file
math.hMath functions, mostly constexpr-friendly alternatives to functions from <cmath>
.
Namespaces
- namespace muu
- The root namespace for all muu functions and types.
- namespace muu::build
- Build environment information (compiler, date/time, support for various things...)
Functions
- auto abs(float x) -> float constexpr noexcept
- Returns the absolute value of a float.
- auto abs(double x) -> double constexpr noexcept
- Returns the absolute value of a double.
- auto abs(long double x) -> long double constexpr noexcept
- Returns the absolute value of a long double.
- auto abs(float128_t x) -> float128_t constexpr noexcept
- Returns the absolute value of a float128_t.
- auto abs(_Float16 x) -> _Float16 constexpr noexcept
- Returns the absolute value of a _Float16.
- auto abs(signed char x) -> signed char constexpr noexcept
- Returns the absolute value of a signed char.
- auto abs(short x) -> short constexpr noexcept
- Returns the absolute value of a short.
- auto abs(int x) -> int constexpr noexcept
- Returns the absolute value of an int.
- auto abs(long x) -> long constexpr noexcept
- Returns the absolute value of a long.
- auto abs(long long x) -> long long constexpr noexcept
- Returns the absolute value of a long long.
-
template <typename T>auto abs(T x) -> T constexpr noexcept
- Returns the absolute value of an integral type.
- auto acos(float x) -> float constexpr noexcept
- Returns the arc cosine of a float.
- auto acos(double x) -> double constexpr noexcept
- Returns the arc cosine of a double.
- auto acos(long double x) -> long double constexpr noexcept
- Returns the arc cosine of a long double.
- auto acos(float128_t x) -> float128_t constexpr noexcept
- Returns the arc cosine of a float128_t.
- auto acos(_Float16 x) -> _Float16 constexpr noexcept
- Returns the arc cosine of a _Float16.
-
template <typename T>auto acos(T x) -> double constexpr noexcept
- Returns the arc cosine of an integer.
- auto approx_equal(float a, float b, float epsilon = default_epsilon<float>) -> bool constexpr noexcept
- Returns true if two floats are approximately equal.
- auto approx_equal(double a, double b, double epsilon = default_epsilon<double>) -> bool constexpr noexcept
- Returns true if two doubles are approximately equal.
- auto approx_equal(long double a, long double b, long double epsilon = default_epsilon<long double>) -> bool constexpr noexcept
- Returns true if two long doubles are approximately equal.
- auto approx_equal(float128_t a, float128_t b, float128_t epsilon = default_epsilon<float128_t>) -> bool constexpr noexcept
- Returns true if two float128_ts are approximately equal.
- auto approx_equal(_Float16 a, _Float16 b, _Float16 epsilon = default_epsilon<_Float16>) -> bool constexpr noexcept
- Returns true if two _Float16s are approximately equal.
-
template <typename T, typename U>auto approx_equal(T a, U b) -> bool constexpr noexcept
- Returns true if two scalar values are approximately equal.
- auto approx_zero(float x, float epsilon = default_epsilon<float>) -> bool constexpr noexcept
- Returns true if a float is approximately equal to zero.
- auto approx_zero(double x, double epsilon = default_epsilon<double>) -> bool constexpr noexcept
- Returns true if a double is approximately equal to zero.
- auto approx_zero(long double x, long double epsilon = default_epsilon<long double>) -> bool constexpr noexcept
- Returns true if a long double is approximately equal to zero.
- auto approx_zero(float128_t x, float128_t epsilon = default_epsilon<float128_t>) -> bool constexpr noexcept
- Returns true if a float128_t is approximately equal to zero.
- auto approx_zero(_Float16 x, _Float16 epsilon = default_epsilon<_Float16>) -> bool constexpr noexcept
- Returns true if a _Float16 is approximately equal to zero.
-
template <typename T>auto approx_zero(T x) -> bool constexpr noexcept
- Returns true if a scalar value is approximately equal to zero.
- auto asin(float x) -> float constexpr noexcept
- Returns the arc sine of a float.
- auto asin(double x) -> double constexpr noexcept
- Returns the arc sine of a double.
- auto asin(long double x) -> long double constexpr noexcept
- Returns the arc sine of a long double.
- auto asin(float128_t x) -> float128_t constexpr noexcept
- Returns the arc sine of a float128_t.
- auto asin(_Float16 x) -> _Float16 constexpr noexcept
- Returns the arc sine of a _Float16.
-
template <typename T>auto asin(T x) -> double constexpr noexcept
- Returns the arc sine of an integer.
- auto atan(float x) -> float constexpr noexcept
- Returns the arc tangent of a float.
- auto atan(double x) -> double constexpr noexcept
- Returns the arc tangent of a double.
- auto atan(long double x) -> long double constexpr noexcept
- Returns the arc tangent of a long double.
- auto atan(float128_t x) -> float128_t constexpr noexcept
- Returns the arc tangent of a float128_t.
- auto atan(_Float16 x) -> _Float16 constexpr noexcept
- Returns the arc tangent of a _Float16.
-
template <typename T>auto atan(T x) -> double constexpr noexcept
- Returns the arc tangent of an integer.
- auto atan2(float y, float x) -> float constexpr noexcept
- Returns the arc tangent of a float.
- auto atan2(double y, double x) -> double constexpr noexcept
- Returns the arc tangent of a double.
- auto atan2(long double y, long double x) -> long double constexpr noexcept
- Returns the arc tangent of a long double.
- auto atan2(float128_t y, float128_t x) -> float128_t constexpr noexcept
- Returns the arc tangent of a float128_t.
- auto atan2(_Float16 y, _Float16 x) -> _Float16 constexpr noexcept
- Returns the arc tangent of a _Float16.
-
template <typename X, typename Y>auto atan2(Y y, X x) -> auto constexpr noexcept
- Returns the arc tangent of two arithmetic values.
- auto ceil(float x) -> float constexpr noexcept
- Returns the ceiling of a float value.
- auto ceil(double x) -> double constexpr noexcept
- Returns the ceiling of a double value.
- auto ceil(long double x) -> long double constexpr noexcept
- Returns the ceiling of a long double value.
- auto ceil(float128_t x) -> float128_t constexpr noexcept
- Returns the ceiling of a float128_t value.
- auto ceil(_Float16 x) -> _Float16 constexpr noexcept
- Returns the ceiling of a _Float16 value.
-
template <typename T>auto ceil(T x) -> double constexpr noexcept
- Returns the ceiling of an integer.
- auto consteval_sqrt(float x) -> float constexpr noexcept
- Returns the square-root of a float.
- auto consteval_sqrt(double x) -> double constexpr noexcept
- Returns the square-root of a double.
- auto consteval_sqrt(long double x) -> long double constexpr noexcept
- Returns the square-root of a long double.
- auto consteval_sqrt(float128_t x) -> float128_t constexpr noexcept
- Returns the square-root of a float128_t.
- auto consteval_sqrt(_Float16 x) -> _Float16 constexpr noexcept
- Returns the square-root of a _Float16.
-
template <typename T>auto consteval_sqrt(T x) -> double constexpr noexcept
- Returns the square-root of an integer.
-
template <typename T, typename U>auto contains(const T& outer, const U& inner) -> bool constexpr noexcept
- Checks if an object contains another object.
- auto cos(float x) -> float constexpr noexcept
- Returns the cosine of a float.
- auto cos(double x) -> double constexpr noexcept
- Returns the cosine of a double.
- auto cos(long double x) -> long double constexpr noexcept
- Returns the cosine of a long double.
- auto cos(float128_t x) -> float128_t constexpr noexcept
- Returns the cosine of a float128_t.
- auto cos(_Float16 x) -> _Float16 constexpr noexcept
- Returns the cosine of a _Float16.
-
template <typename T>auto cos(T x) -> double constexpr noexcept
- Returns the cosine of an integer.
-
template <typename T, size_t N>auto degenerate(const T(&vals)[N]) -> bool constexpr noexcept
- Returns true if any value in array is in a degenerate state.
-
template <typename T, typename U, typename... V>auto degenerate(const T& val1, const U& val2, const V&... vals) -> bool constexpr noexcept
- Returns true if any of the given values in a degenerate state.
-
template <typename T>auto evenly_distribute(T total, T bucket_count, T bucket_index) -> T constexpr noexcept
- Evenly divides an integer into buckets.
- auto floor(float x) -> float constexpr noexcept
- Returns the floor of a float value.
- auto floor(double x) -> double constexpr noexcept
- Returns the floor of a double value.
- auto floor(long double x) -> long double constexpr noexcept
- Returns the floor of a long double value.
- auto floor(float128_t x) -> float128_t constexpr noexcept
- Returns the floor of a float128_t value.
- auto floor(_Float16 x) -> _Float16 constexpr noexcept
- Returns the floor of a _Float16 value.
-
template <typename T>auto floor(T x) -> double constexpr noexcept
- Returns the floor of an integer.
-
template <typename T, typename U, typename... V>auto gcd(T val1, U val2, V... vals) -> std::
common_type_t<T, U, V...> constexpr noexcept - Returns the lowest common multiple of two or more integers.
- auto infinity_or_nan(float x) -> bool constexpr noexcept
- Returns true if a float is infinity or NaN.
- auto infinity_or_nan(double x) -> bool constexpr noexcept
- Returns true if a double is infinity or NaN.
- auto infinity_or_nan(long double x) -> bool constexpr noexcept
- Returns true if a long double is infinity or NaN.
- auto infinity_or_nan(float128_t x) -> bool constexpr noexcept
- Returns true if a float128_t is infinity or NaN.
- auto infinity_or_nan(_Float16 x) -> bool constexpr noexcept
- Returns true if a _Float16 is infinity or NaN.
-
template <typename T>auto infinity_or_nan(T x) -> bool constexpr noexcept
- Returns true if an arithmetic value is infinity or NaN.
-
template <typename T, size_t N>auto infinity_or_nan(const T(&vals)[N]) -> bool constexpr noexcept
- Returns true if any value in array is infinity or NaN.
-
template <typename T, typename U, typename... V>auto infinity_or_nan(const T& val1, const U& val2, const V&... vals) -> bool constexpr noexcept
- Returns true if any of the given values is infinity or NaN.
-
template <typename T, typename U>auto intersects(const T& obj1, const U& obj2) -> bool constexpr noexcept
- Checks if two objects intersect.
-
template <typename T, typename U, typename... V>auto lcm(T val1, U val2, V... vals) -> std::
common_type_t<T, U, V...> constexpr noexcept - Returns the lowest common multiple of two or more integers.
- auto lerp(float start, float finish, float alpha) -> float constexpr noexcept
- Returns a linear interpolation between two floats.
- auto lerp(double start, double finish, double alpha) -> double constexpr noexcept
- Returns a linear interpolation between two doubles.
- auto lerp(long double start, long double finish, long double alpha) -> long double constexpr noexcept
- Returns a linear interpolation between two long doubles.
- auto lerp(float128_t start, float128_t finish, float128_t alpha) -> float128_t constexpr noexcept
- Returns a linear interpolation between two float128_ts.
- auto lerp(_Float16 start, _Float16 finish, _Float16 alpha) -> _Float16 constexpr noexcept
- Returns a linear interpolation between two _Float16s.
-
template <typename T, typename U, typename V>auto lerp(T start, U finish, V alpha) -> auto constexpr noexcept
- Returns a linear interpolation between two arithmetic values.
- auto normalize_angle(float x) -> float constexpr noexcept
- Normalizes the angle value of a float.
- auto normalize_angle(double x) -> double constexpr noexcept
- Normalizes the angle value of a double.
- auto normalize_angle(long double x) -> long double constexpr noexcept
- Normalizes the angle value of a long double.
- auto normalize_angle(float128_t x) -> float128_t constexpr noexcept
- Normalizes the angle value of a float128_t.
- auto normalize_angle(_Float16 x) -> _Float16 constexpr noexcept
- Normalizes the angle value of a _Float16.
-
template <typename T>auto normalize_angle(T x) -> double constexpr noexcept
- Normalizes the angle of an integer.
- auto normalize_angle_signed(float x) -> float constexpr noexcept
- Normalizes the angle value of a float.
- auto normalize_angle_signed(double x) -> double constexpr noexcept
- Normalizes the angle value of a double.
- auto normalize_angle_signed(long double x) -> long double constexpr noexcept
- Normalizes the angle value of a long double.
- auto normalize_angle_signed(float128_t x) -> float128_t constexpr noexcept
- Normalizes the angle value of a float128_t.
- auto normalize_angle_signed(_Float16 x) -> _Float16 constexpr noexcept
- Normalizes the angle value of a _Float16.
-
template <typename T>auto normalize_angle_signed(T x) -> double constexpr noexcept
- Normalizes the angle of an integer.
- auto sin(float x) -> float constexpr noexcept
- Returns the sine of a float.
- auto sin(double x) -> double constexpr noexcept
- Returns the sine of a double.
- auto sin(long double x) -> long double constexpr noexcept
- Returns the sine of a long double.
- auto sin(float128_t x) -> float128_t constexpr noexcept
- Returns the sine of a float128_t.
- auto sin(_Float16 x) -> _Float16 constexpr noexcept
- Returns the sine of a _Float16.
-
template <typename T>auto sin(T x) -> double constexpr noexcept
- Returns the sine of an integer.
- auto sqrt(float x) -> float constexpr noexcept
- Returns the square-root of a float.
- auto sqrt(double x) -> double constexpr noexcept
- Returns the square-root of a double.
- auto sqrt(long double x) -> long double constexpr noexcept
- Returns the square-root of a long double.
- auto sqrt(float128_t x) -> float128_t constexpr noexcept
- Returns the square-root of a float128_t.
- auto sqrt(_Float16 x) -> _Float16 constexpr noexcept
- Returns the square-root of a _Float16.
-
template <typename T>auto sqrt(T x) -> double constexpr noexcept
- Returns the square-root of an integer.
- auto tan(float x) -> float constexpr noexcept
- Returns the tangent of a float.
- auto tan(double x) -> double constexpr noexcept
- Returns the tangent of a double.
- auto tan(long double x) -> long double constexpr noexcept
- Returns the tangent of a long double.
- auto tan(float128_t x) -> float128_t constexpr noexcept
- Returns the tangent of a float128_t.
- auto tan(_Float16 x) -> _Float16 constexpr noexcept
- Returns the tangent of a _Float16.
-
template <typename T>auto tan(T x) -> double constexpr noexcept
- Returns the tangent of an integer.
Variables
- bool supports_constexpr_infinity_or_nan constexpr
- True if using infinity_
or_ nan() in constexpr contexts is supported on this compiler. - bool supports_constexpr_math constexpr
- True if some math functions (sin, cos, sqrt etc.) can be used in constexpr contexts on this compiler.