Skip to content

Commit

Permalink
Don't inline constexpr array wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jan 3, 2025
1 parent 32c5058 commit b218157
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Eratosthenes/_eratosthenes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ inline size_t backward3(const BigInteger& n) { return (size_t)((~(~n | 1U)) / 3U
constexpr unsigned char wheel5[8U] = { 1U, 7U, 11U, 13U, 17U, 19U, 23U, 29U };

// Make this NOT a multiple of 2, 3, or 5.
inline BigInteger forward5(const size_t& p) { return wheel5[p % 8U] + (p / 8U) * 30U; }
BigInteger forward5(const size_t& p) { return wheel5[p % 8U] + (p / 8U) * 30U; }

inline size_t backward5(const BigInteger &n) {
size_t backward5(const BigInteger &n) {
return std::distance(wheel5, std::lower_bound(wheel5, wheel5 + 8U, (size_t)(n % 30U))) + 8U * (size_t)(n / 30U) + 1U;
}

Expand All @@ -83,9 +83,9 @@ constexpr unsigned char wheel7[48U] = {
};

// Make this NOT a multiple of 2, 3, 5, or 7.
inline BigInteger forward7(const size_t& p) { return wheel7[p % 48U] + (p / 48U) * 210U; }
BigInteger forward7(const size_t& p) { return wheel7[p % 48U] + (p / 48U) * 210U; }

inline size_t backward7(const BigInteger& n) {
size_t backward7(const BigInteger& n) {
return std::distance(wheel7, std::lower_bound(wheel7, wheel7 + 48U, (size_t)(n % 210U))) + 48U * (size_t)(n / 210U) + 1U;
}

Expand All @@ -112,9 +112,9 @@ constexpr unsigned short wheel11[480U] = {
2203U, 2207U, 2209U, 2213U, 2221U, 2227U, 2231U, 2237U, 2239U, 2243U, 2249U, 2251U, 2257U, 2263U, 2267U, 2269U, 2273U, 2279U, 2281U, 2287U, 2291U, 2293U, 2297U, 2309U};

// Make this NOT a multiple of 2, 3, 5, 7, or 11.
inline BigInteger forward11(const size_t &p) { return wheel11[p % 480U] + (p / 480U) * 2310U; }
BigInteger forward11(const size_t &p) { return wheel11[p % 480U] + (p / 480U) * 2310U; }

inline size_t backward11(const BigInteger &n) {
size_t backward11(const BigInteger &n) {
return std::distance(wheel11, std::lower_bound(wheel11, wheel11 + 480U, (size_t)(n % 2310U))) + 480U * (size_t)(n / 2310U) + 1U;
}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='Eratosthenes',
version='4.0.5',
version='4.0.6',
author='Dan Strano',
author_email='[email protected]',
description='Fast prime generation for Python based on Sieve of Eratosthenes',
Expand Down

0 comments on commit b218157

Please sign in to comment.