26#if HI_COMPILER == HI_CC_MSVC
29#if HI_PROCESSOR == HI_CPU_X64
33namespace hi::inline
v1 {
35constexpr long long pow10_table[20]{
50 100'000'000'000'000LL,
51 1'000'000'000'000'000LL,
52 10'000'000'000'000'000LL,
53 100'000'000'000'000'000LL,
54 1'000'000'000'000'000'000LL,
57[[nodiscard]]
constexpr long long pow10ll(
int x)
noexcept
60 return pow10_table[x];
63template<
typename Iterator>
64[[nodiscard]]
auto mean(Iterator first, Iterator last)
68 hilet sum = std::reduce(first, last, init);
74template<
typename Iterator,
typename T>
75[[nodiscard]]
auto stddev(Iterator first, Iterator last, T mean)
80 hilet tmp = value - mean;
81 return acc + tmp * tmp;
89constexpr bool inplace_max(T& a, T
const& b)
noexcept
97constexpr bool inplace_min(T& a, T
const& b)
noexcept
105constexpr void inplace_clamp(T& a, T
const& lo, T
const&
hi)
noexcept
110 a = clamp(a, lo,
hi);
121template<std::
signed_
integral T>
122[[nodiscard]]
constexpr friend std::make_unsigned_t<T>
abs_unsigned(T rhs)
noexcept
124 auto rhs_u =
static_cast<std::make_unsigned_t<T>
>(rhs);
128 if (
static_cast<T
>(res_u) < 0) {
135template<std::
floating_po
int T>
136[[nodiscard]]
constexpr bool almost_equal(T a, T b)
noexcept
139 return std::abs(a - b) <= e;
147template<std::
floating_po
int T>
150 return degree * (std::numbers::pi_v<T> / T{180.0});
158template<std::
unsigned_
integral T>
159[[nodiscard]]
constexpr T floor(T value, T
alignment)
noexcept
169template<std::
unsigned_
integral T>
170[[nodiscard]]
constexpr T ceil(T value, T
alignment)
noexcept
175template<std::
floating_po
int T>
176[[nodiscard]]
constexpr bool isnan(T value)
noexcept
178 return not (value == value);
Utilities to assert and bound check.
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:238
Utilities used by the HikoGUI library itself.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
constexpr friend std::make_unsigned_t< T > abs_unsigned(T rhs) noexcept
Absolute value of a signed number converted to an unsigned number.
Definition math.hpp:122
constexpr T to_radian(T degree) noexcept
Convert degree to radian.
Definition math.hpp:148
geometry/margins.hpp
Definition cache.hpp:11
Horizontal/Vertical alignment combination.
Definition alignment.hpp:231