Commit Graph
8 Commits
Author SHA1 Message Date
Chip Hogg c339383873 Convert names to standard_case 2022-03-19 16:07:39 +00:00
Chip Hogg a99e5f9032 Switch tests to use top-level, anonymous namespace 2022-03-19 15:54:29 +00:00
Chip Hogg 28c4fe3c08 Run clang-format-15 on changed files 2022-03-19 14:29:11 +00:00
Chip Hogg 1e8460d401 Revert "Try upping the basis size further"
This reverts commit 87073856a7.
It didn't fix the problem, and it caused some new ones.  We need a
different approach.
2022-03-19 13:21:47 +00:00
Chip Hogg 87073856a7 Try upping the basis size further
We are well into a regime of diminishing returns, but we'd better start
by seeing if the easy thing works.  Besides, setting this to 7 trips the
step limit in _generating_ the algorithm!
2022-03-12 18:56:26 +00:00
Chip Hogg 73a56115a1 Fix wheel factorization algorithm 2022-03-11 03:42:19 +00:00
Chip Hogg 24b284fcbb Add tests to support claims in comment 2022-03-10 23:41:36 +00:00
Chip Hogg 04b80f0827 Use wheel factorization for prime numbers
Certain existing units in the library require very large prime
numbers---so large, in fact, that our naive trial division hits the
_iteration limit_ for `constexpr` loops.  We don't want to force users
to provide a compiler option override, so we'd better find another way.

The solution is to use the "wheel factorization" algorithm:
https://en.wikipedia.org/wiki/Wheel_factorization

This lets us skip most composite numbers in our trial division.  The
implementation presented here is configurable in terms of the size of
the "basis" of primes we use.  Bigger bases let us skip more primes, but
at the cost of storing more numbers.  Fortunately, it turns out that N=3
was good enough for our purposes.
2022-03-10 23:29:02 +00:00