Skip to content

Commit 1ec6062

Browse files
wheel_tuner.py
1 parent 482ba66 commit 1ec6062

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ struct Factorizer {
460460
continue;
461461
}
462462
// We have a successful candidate.
463+
std::cout << x << ", ";
463464

464465
// If the candidate is already a perfect square,
465466
// we got lucky, and we might be done already.
@@ -679,6 +680,9 @@ struct Factorizer {
679680
throw std::runtime_error("No smooth numbers found. Sieve more, or increase smoothness bound to reduce selectiveness. (The sieving bound multiplier is equivalent to that many times the square root of the number to factor, for calculated numerical range above an offset of the square root of the number to factor.)");
680681
}
681682

683+
std::cout << std::endl;
684+
std::cout << "Performing Gaussian elimination..." << std::endl;
685+
682686
const std::vector<std::vector<size_t>> solutions = gaussianElimination();
683687
for (const std::vector<size_t>& solution : solutions) {
684688
const BigInteger factor = solveCongruence(solution);
@@ -914,6 +918,10 @@ std::string find_a_factor(std::string toFactorStr, size_t method, size_t nodeCou
914918
return isFactorFinder ? worker.sievePolynomials(&inc_seqs_clone) : worker.bruteForce(&inc_seqs_clone);
915919
};
916920

921+
if (isFactorFinder) {
922+
std::cout << "Smooth numbers: ";
923+
}
924+
917925
for (unsigned cpu = 0U; cpu < CpuCount; ++cpu) {
918926
futures.push_back(std::async(std::launch::async, workerFn));
919927
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "FindAFactor"
11-
version = "6.6.0"
11+
version = "6.7.0"
1212
requires-python = ">=3.8"
1313
description = "Find any nontrivial factor of a number"
1414
readme = {file = "README.txt", content-type = "text/markdown"}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def build_extension(self, ext):
4040

4141
setup(
4242
name='FindAFactor',
43-
version='6.6.0',
43+
version='6.7.0',
4444
author='Dan Strano',
4545
author_email='[email protected]',
4646
description='Find any nontrivial factor of a number',

wheel_test.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

wheel_tuner.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Choose a wheel factorization ceiling:
2+
wheel_factorization_level = 50
3+
# Grab a sample of smooth numbers from `FACTOR_FINDER` mode, and paste them here.
4+
smooth_nums = [42571, 42576, 42583, 42589, 42591, 42592, 42593, 42595, 42598, 42601, 42612, 42615, 42617, 42634, 42635, 42639, 42641, 42650, 42677, 42687, 42689, 42696, 42709, 42723, 42747, 42754, 42786, 42800, 42806, 42849, 42851, 42852, 42864, 42871, 42909, 42929, 42931, 42936, 42937, 42942, 42962, 42978, 42985, 42986, 42994, 43013, 43059, 43061, 43079, 43094, 43105, 43109, 43114, 43133, 43150, 43168, 43187, 43209, 43247, 43279]
5+
6+
# Primes up to 1000 are likely enough to choose from in general (but you can add more).
7+
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
8+
small_primes = [p for p in primes if p < wheel_factorization_level]
9+
smooth_num_count = len(smooth_nums)
10+
11+
for p in small_primes:
12+
mult_count = 0
13+
for x in smooth_nums:
14+
if (x % p) == 0:
15+
mult_count += 1
16+
17+
print("Prime = " + str(p) + ", quality = " + str((1 / p) / ((mult_count / smooth_num_count)) if mult_count else 0))
18+
19+
print("(Any low quality score, particularly less than 1.0, might be worth excluding.)")

0 commit comments

Comments
 (0)