mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
fix and slight optimization for factor
This commit builds upon @wikol's Pollard rho implementation. It adds the following: 1. A generator for prime inverse tables. With these, we can do very fast divisibility tests (a single multiply and comparison) for small primes (presently, the first 1000 primes are in the table, which means all numbers of ~26 bits or less can be factored very quickly. 2. Always try prime inverse tables before jumping into Pollard's rho method or using trial division. 3. Since we have eliminated all small factors by the time we're done with the table division, only use slow trial division when the number is big enough to cause overflow issues in Pollard's rho, and jump out of trial division and into Pollard's rho as soon as the number is small enough. 4. Updates the Makefile to regenerate the prime table if it's not up-to-date.
This commit is contained in:
parent
06b70877db
commit
6c4e967fc6
7 changed files with 875 additions and 117 deletions
5
Makefile
5
Makefile
|
@ -30,7 +30,7 @@ RUSTCTESTFLAGS := $(RUSTCFLAGS)
|
|||
|
||||
# Handle config setup
|
||||
ifeq ($(ENABLE_LTO),y)
|
||||
RUSTCBINFLAGS := $(RUSTCLIBFLAGS) -Z lto
|
||||
RUSTCBINFLAGS := $(RUSTCLIBFLAGS) -C lto
|
||||
else
|
||||
RUSTCBINFLAGS := $(RUSTCLIBFLAGS)
|
||||
endif
|
||||
|
@ -305,6 +305,9 @@ $(BUILDDIR)/mkuutils: mkuutils.rs | $(BUILDDIR)
|
|||
$(SRCDIR)/cksum/crc_table.rs: $(SRCDIR)/cksum/gen_table.rs
|
||||
cd $(SRCDIR)/cksum && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table && $(RM) gen_table
|
||||
|
||||
$(SRCDIR)/factor/prime_table.rs: $(SRCDIR)/factor/gen_table.rs
|
||||
cd $(SRCDIR)/factor && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table 1000 > $@ && $(RM) gen_table
|
||||
|
||||
crates:
|
||||
echo $(EXES)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue