nicoo
e91155519a
factor::factor: Add integration tests
2020-06-15 19:10:16 +02:00
nicoo
bada7530fb
factor::miller_rabin: Add tests
2020-06-15 19:10:16 +02:00
Roy Ivy III
fbbd881ca9
docs ~ reduce sub-crate meta-information keywords to the maximum of five
2020-05-31 15:48:54 -05:00
Roy Ivy III
f82de13847
docs ~ spell-check repairs and addition of exceptions
2020-05-30 01:36:02 -05:00
Roy Ivy III
ea3235c7e2
change ~ new_coreopts!()
=> app!()
(from uucore v0.0.4)
2020-05-29 22:59:48 -05:00
Roy Ivy III
6f465eeb9f
deps ~ update utils to uucore/uucore_procs v0.0.4
2020-05-29 22:59:48 -05:00
Roy Ivy III
d4aa3a2231
fix 'edition="2018"' module import errors
...
- ref: <https://users.rust-lang.org/t/imports-can-only-refer-to-extern-crate-names/24388 > @@ <https://archive.is/iCaXp >
2020-05-29 22:59:47 -05:00
Roy Ivy III
d70db1f7d2
docs ~ improve/update sub-crate meta information
2020-05-29 22:59:47 -05:00
Roy Ivy III
db2e950918
change ~ make all sub-crates independent
2020-05-29 22:59:40 -05:00
Nicolas Braud-Santoni
4c3682aec7
factor::Factors::add: Split up to work without NLL
...
Co-authored-by: Roy Ivy III <rivy.dev@gmail.com>
2020-05-24 19:14:37 +02:00
nicoo
36a2948959
factor::miller_rabin: Avoid unecessary exponentiation
...
Instead of computing a^r and a^(n-1) = a^(r 2ⁱ) separately,
compute the latter by repeatedly squaring the former.
33.6% performance improvement
2020-05-24 19:10:34 +02:00
nicoo
543c7b941a
factor::rho: Small refactor
2020-05-24 19:10:29 +02:00
nicoo
30fd6a0309
factor::numeric: Replace lose functions with an Arithmetic trait
2020-05-24 18:16:21 +02:00
nicoo
29eb8fd77b
format: Make clippy happy
2020-05-24 17:06:19 +02:00
nicoo
8241037690
factor::miller_rabin: Extract dividers from the primality test
...
Another 36% improvement.
2020-05-24 15:41:23 +02:00
nicoo
6b9585b1dc
factor::miller_rabbin: Refactor before extracting dividers
...
Replace iterated division with u64::trailing_zeros, hoist the selection of `mul`
out of the loop, another cool 49.5% runtime improvement.
2020-05-24 15:41:23 +02:00
nicoo
e3ecc81d97
factor: Move the Miller-Rabin primality test to its own module.
2020-05-24 15:41:23 +02:00
nicoo
74054feb94
factor::factor: Remove extraneous call to the primality test
...
Another 6.97% runtime improvement
2020-05-24 15:41:23 +02:00
nicoo
e1a6dbe619
factor::table: Remove obsolete, commented code
2020-05-24 15:41:23 +02:00
nicoo
169740629b
factor::table: Remove extraneous calls to the primality test
...
50% performance improvement on factoring all numbers between 2 and 10⁶.
2020-05-24 15:41:23 +02:00
nicoo
418fd61759
factor::factor: Short-circuit the fallback to Pollard's rho
...
When the remainder is smaller than the max. entry in the table,
it is guaranteed to be prime.
2020-05-24 15:41:23 +02:00
nicoo
bc11e57962
factor::factor: Use u64::trailing_zero instead of iterated division
...
No significant performance impact (most of the time is spent elsewhere),
but an easy and satisfying fix nevertheless.
2020-05-24 15:41:23 +02:00
nicoo
a1b2522750
factor: Move each factorisation method to its own module
...
Also decoupled the factorisation methods; now factor::factor contains
the logic that chains the different algorithms and aggregates results.
As a side-effect, rho::factor now performs extraneous allocations (as each
recursive step creates a new `Factors` value, which is then aggregated into
the previous one) but there is no significant performance impact.
2020-05-24 15:41:23 +02:00
nicoo
d9095a2539
factor: Refactor (eheh) around a Factors
datatype
...
It is clearer to see what is going on, as opposed to passing around an
unmarked `Vec<u64>`, and there is a single place to add invariants checks.
This is also a more compact memory representation: each prime factor is
represented only once, with an additional byte for multiplicity. The
performance impact is however not significant.
2020-05-24 15:41:23 +02:00
Roy Ivy III
5aa2b039a5
change ~ fixup paths (within workspace packages) to common code
2020-04-14 13:46:19 -05:00
Roy Ivy III
78c362c8b5
change ~ fixup paths (within workspace packages)
2020-04-14 13:46:18 -05:00
Roy Ivy III
f0b0e3b867
change ~ reorganize code files
2020-04-14 13:46:18 -05:00