src/nt/gl/gcd/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../../util/traits/math/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | namespace gcd_impl_ { | ||
| 8 | template <uint_c T, uint_c U> | ||
| 9 | 79769814 | CEXP std::common_type_t<T, U> gcd__(T u, U v) NE { | |
| 10 | using W = std::common_type_t<T, U>; | ||
| 11 |
7/8std::common_type<unsigned int, unsigned int>::type tifa_libs::gcd_impl_::gcd__<unsigned int, unsigned int>(unsigned int, unsigned int):
✓ Branch 0 taken 69992320 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 69992319 times.
std::common_type<unsigned long, unsigned long>::type tifa_libs::gcd_impl_::gcd__<unsigned long, unsigned long>(unsigned long, unsigned long):
✓ Branch 0 taken 9735506 times.
✓ Branch 1 taken 41986 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9735506 times.
|
79769814 | retif_((!u || !v) [[unlikely]], u ^ v); |
| 12 | 79727825 | const auto k = std::__countr_zero(u | v); | |
| 13 | 79727825 | u >>= k, v >>= k; | |
| 14 | do { | ||
| 15 |
4/4std::common_type<unsigned int, unsigned int>::type tifa_libs::gcd_impl_::gcd__<unsigned int, unsigned int>(unsigned int, unsigned int):
✓ Branch 1 taken 323216612 times.
✓ Branch 2 taken 282060432 times.
std::common_type<unsigned long, unsigned long>::type tifa_libs::gcd_impl_::gcd__<unsigned long, unsigned long>(unsigned long, unsigned long):
✓ Branch 1 taken 230434796 times.
✓ Branch 2 taken 271033838 times.
|
1106745678 | if (W const _ = v >> std::__countr_zero(v); u > _) v = u - _, u = _; |
| 16 | 553094270 | else v = _ - u; | |
| 17 |
4/4std::common_type<unsigned int, unsigned int>::type tifa_libs::gcd_impl_::gcd__<unsigned int, unsigned int>(unsigned int, unsigned int):
✓ Branch 0 taken 535284725 times.
✓ Branch 1 taken 69992319 times.
std::common_type<unsigned long, unsigned long>::type tifa_libs::gcd_impl_::gcd__<unsigned long, unsigned long>(unsigned long, unsigned long):
✓ Branch 0 taken 491733128 times.
✓ Branch 1 taken 9735506 times.
|
1106745678 | } while (v); |
| 18 | 79727825 | return u << k; | |
| 19 | } | ||
| 20 | } // namespace gcd_impl_ | ||
| 21 | |||
| 22 | template <int_c T, int_c U> | ||
| 23 | 79769433 | CEXP auto gcd(T a, U b) NE { return gcd_impl_::gcd__((to_uint_t<T>)abs(a), (to_uint_t<U>)abs(b)); } | |
| 24 | |||
| 25 | } // namespace tifa_libs | ||
| 26 |