29 constexpr T
sqrt(T x)
noexcept
31 static_assert(is_floating_point_v<T>,
"sqrt requires a floating-point type");
34 return is_same_v<T, float> ? __builtin_sqrtf(x) : __builtin_sqrt(x);
48 constexpr T
abs(T x)
noexcept
50 if constexpr (is_same_v<T, float>)
51 return __builtin_fabsf(x);
52 else if constexpr (is_same_v<T, double>)
53 return __builtin_fabs(x);
54 else if constexpr (is_same_v<T, int>)
55 return __builtin_abs(x);
56 else if constexpr (is_same_v<T, long>)
57 return __builtin_labs(x);
59 return x < T(0) ? -x : x;
70 constexpr T
sin(T x)
noexcept
72 static_assert(is_floating_point_v<T>,
"sin requires a floating-point type");
73 return is_same_v<T, float> ? __builtin_sinf(x) : __builtin_sin(x);
84 constexpr T
cos(T x)
noexcept
86 static_assert(is_floating_point_v<T>,
"cos requires a floating-point type");
87 return is_same_v<T, float> ? __builtin_cosf(x) : __builtin_cos(x);
98 constexpr T
acos(T x)
noexcept
100 static_assert(is_floating_point_v<T>,
"acos requires a floating-point type");
101 return is_same_v<T, float> ? __builtin_acosf(x) : __builtin_acos(x);
static void error(const T &msg)
Definition error_handler.h:30
Global configuration for the tesseract tensor library.
T cos(T x)
Definition cos.h:7
constexpr T abs(T x) noexcept
Compute the absolute value of a numeric value.
Definition math_utils.h:48
constexpr T acos(T x) noexcept
Compute the arc cosine of a floating-point value.
Definition math_utils.h:98
constexpr T sin(T x) noexcept
Compute the sine of a floating-point value (radians).
Definition math_utils.h:70
constexpr T sqrt(T x) noexcept
Compute the square root of a floating-point value.
Definition math_utils.h:29