forked from mpusz/mp-units
Convert names to standard_case
This commit is contained in:
@@ -124,7 +124,7 @@ constexpr std::size_t product(const std::array<std::size_t, N>& values)
|
||||
//
|
||||
// [1] https://en.wikipedia.org/wiki/Wheel_factorization
|
||||
template<std::size_t BasisSize>
|
||||
struct WheelFactorizer {
|
||||
struct wheel_factorizer {
|
||||
static constexpr auto basis = first_n_primes<BasisSize>();
|
||||
static constexpr std::size_t wheel_size = product(basis);
|
||||
static constexpr auto coprimes_in_first_wheel =
|
||||
|
@@ -34,7 +34,7 @@
|
||||
namespace units {
|
||||
namespace detail {
|
||||
// Higher numbers use fewer trial divisions, at the price of more storage space.
|
||||
using Factorizer = WheelFactorizer<4>;
|
||||
using factorizer = wheel_factorizer<4>;
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
@@ -274,7 +274,7 @@ constexpr std::intmax_t remove_power(std::intmax_t base, std::intmax_t pow, std:
|
||||
}
|
||||
|
||||
// A way to check whether a number is prime at compile time.
|
||||
constexpr bool is_prime(std::intmax_t n) { return (n >= 0) && Factorizer::is_prime(static_cast<std::size_t>(n)); }
|
||||
constexpr bool is_prime(std::intmax_t n) { return (n >= 0) && factorizer::is_prime(static_cast<std::size_t>(n)); }
|
||||
|
||||
constexpr bool is_valid_base_power(const BasePower auto& bp)
|
||||
{
|
||||
@@ -502,7 +502,7 @@ struct prime_factorization {
|
||||
if constexpr (known_first_factor<N>.has_value()) {
|
||||
return known_first_factor<N>.value();
|
||||
} else {
|
||||
return static_cast<std::intmax_t>(Factorizer::find_first_factor(N));
|
||||
return static_cast<std::intmax_t>(factorizer::find_first_factor(N));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ namespace {
|
||||
template<std::size_t BasisSize, std::size_t... Is>
|
||||
constexpr bool check_primes(std::index_sequence<Is...>)
|
||||
{
|
||||
return ((Is < 2 || WheelFactorizer<BasisSize>::is_prime(Is) == is_prime_by_trial_division(Is)) && ...);
|
||||
return ((Is < 2 || wheel_factorizer<BasisSize>::is_prime(Is) == is_prime_by_trial_division(Is)) && ...);
|
||||
}
|
||||
|
||||
static_assert(check_primes<2>(std::make_index_sequence<122>{}));
|
||||
@@ -44,33 +44,33 @@ static_assert(check_primes<2>(std::make_index_sequence<122>{}));
|
||||
// using numbers of the form (210 * n + 121) as trial divisors, which is a problem if any are prime. For n = 1, we have
|
||||
// a divisor of (210 + 121 = 331), which happens to be prime but will not be used. Thus, (331 * 331 = 109561) is a
|
||||
// composite number which could wrongly appear prime if we skip over 331.
|
||||
static_assert(WheelFactorizer<4>::is_prime(109561) == is_prime_by_trial_division(109561));
|
||||
static_assert(wheel_factorizer<4>::is_prime(109561) == is_prime_by_trial_division(109561));
|
||||
|
||||
static_assert(WheelFactorizer<1>::coprimes_in_first_wheel.size() == 1);
|
||||
static_assert(WheelFactorizer<2>::coprimes_in_first_wheel.size() == 2);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel.size() == 8);
|
||||
static_assert(WheelFactorizer<4>::coprimes_in_first_wheel.size() == 48);
|
||||
static_assert(WheelFactorizer<5>::coprimes_in_first_wheel.size() == 480);
|
||||
static_assert(wheel_factorizer<1>::coprimes_in_first_wheel.size() == 1);
|
||||
static_assert(wheel_factorizer<2>::coprimes_in_first_wheel.size() == 2);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel.size() == 8);
|
||||
static_assert(wheel_factorizer<4>::coprimes_in_first_wheel.size() == 48);
|
||||
static_assert(wheel_factorizer<5>::coprimes_in_first_wheel.size() == 480);
|
||||
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[0] == 1);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[1] == 7);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[2] == 11);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[3] == 13);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[4] == 17);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[5] == 19);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[6] == 23);
|
||||
static_assert(WheelFactorizer<3>::coprimes_in_first_wheel[7] == 29);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[0] == 1);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[1] == 7);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[2] == 11);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[3] == 13);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[4] == 17);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[5] == 19);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[6] == 23);
|
||||
static_assert(wheel_factorizer<3>::coprimes_in_first_wheel[7] == 29);
|
||||
|
||||
static_assert(!WheelFactorizer<1>::is_prime(0));
|
||||
static_assert(!WheelFactorizer<1>::is_prime(1));
|
||||
static_assert(WheelFactorizer<1>::is_prime(2));
|
||||
static_assert(!wheel_factorizer<1>::is_prime(0));
|
||||
static_assert(!wheel_factorizer<1>::is_prime(1));
|
||||
static_assert(wheel_factorizer<1>::is_prime(2));
|
||||
|
||||
static_assert(!WheelFactorizer<2>::is_prime(0));
|
||||
static_assert(!WheelFactorizer<2>::is_prime(1));
|
||||
static_assert(WheelFactorizer<2>::is_prime(2));
|
||||
static_assert(!wheel_factorizer<2>::is_prime(0));
|
||||
static_assert(!wheel_factorizer<2>::is_prime(1));
|
||||
static_assert(wheel_factorizer<2>::is_prime(2));
|
||||
|
||||
static_assert(!WheelFactorizer<3>::is_prime(0));
|
||||
static_assert(!WheelFactorizer<3>::is_prime(1));
|
||||
static_assert(WheelFactorizer<3>::is_prime(2));
|
||||
static_assert(!wheel_factorizer<3>::is_prime(0));
|
||||
static_assert(!wheel_factorizer<3>::is_prime(1));
|
||||
static_assert(wheel_factorizer<3>::is_prime(2));
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user