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);
114[[nodiscard]]
constexpr T abs(T a)
noexcept
116 return a < T{} ? -a : a;
119template<std::
floating_po
int T>
120[[nodiscard]]
constexpr bool almost_equal(T a, T b)
noexcept
123 return std::abs(a - b) <= e;
131template<std::
floating_po
int T>
134 return degree * (std::numbers::pi_v<T> / T{180.0});
142template<std::
unsigned_
integral T>
143[[nodiscard]]
constexpr T floor(T value, T
alignment)
noexcept
153template<std::
unsigned_
integral T>
154[[nodiscard]]
constexpr T ceil(T value, T
alignment)
noexcept
159template<std::
floating_po
int T>
160[[nodiscard]]
constexpr bool isnan(T value)
noexcept
162 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:133
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:15
constexpr T to_radian(T degree) noexcept
Convert degree to radian.
Definition math.hpp:132
geometry/margins.hpp
Definition assert.hpp:18
Horizontal/Vertical alignment combination.
Definition alignment.hpp:232