Skip to content

Commit 0491aab

Browse files
Stumbling in the dark
1 parent afa264e commit 0491aab

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ struct Factorizer {
823823
BigInteger candidate = forwardFn(backwardFn(y * y - toFactor));
824824
// This actually just goes ahead and FORCES
825825
// the number into a "close-by" smooth perfect square.
826-
candidate = makeSmoothPerfectSquare(candidate);
826+
candidate = makeSmooth(candidate);
827827
// We want two numbers multiplied together to be larger than toFactor.
828828
if (candidate < toFactorSqrt) {
829829
continue;
@@ -1013,7 +1013,7 @@ struct Factorizer {
10131013
}
10141014

10151015
// Produce a smooth number with its factorization vector.
1016-
BigInteger makeSmoothPerfectSquare(BigInteger num) {
1016+
BigInteger makeSmooth(BigInteger num) {
10171017
BigInteger n = num;
10181018
boost::dynamic_bitset<size_t> vec(primes.size(), 0);
10191019
while (true) {
@@ -1046,17 +1046,26 @@ struct Factorizer {
10461046
// The number was not fully factored, because it is not smooth.
10471047
// Make it smooth, by dividing out the remaining non-smooth factors!
10481048
num /= n;
1049+
// This probably won't work, for the sieve, but notice that it is
1050+
// basically no more expensive, at this point, to try this.
10491051
}
1052+
1053+
// We skip the section below, only because it's the only deviation
1054+
// from the usual smooth number distirbution on the sieving interval.
1055+
// The "coercion" into a smooth number above happens only is the
1056+
// number is not smooth in the first place, yet we might as well
1057+
// test the residue for smoothness.
1058+
10501059
// We actually want not just a smooth number,
10511060
// but a smooth perfect square.
1052-
for (size_t pi = 0U; pi < primes.size(); ++pi) {
1053-
if (vec.test(pi)) {
1054-
// If the prime factor component parity is odd,
1055-
// multiply by the prime once to make it even.
1056-
num *= primes[pi];
1057-
}
1058-
// The parity is necessarily even in this factor, by now.
1059-
}
1061+
// for (size_t pi = 0U; pi < primes.size(); ++pi) {
1062+
// if (vec.test(pi)) {
1063+
// // If the prime factor component parity is odd,
1064+
// // multiply by the prime once to make it even.
1065+
// num *= primes[pi];
1066+
// }
1067+
// // The parity is necessarily even in this factor, by now.
1068+
// }
10601069
// Note that forcing a perfect square is the only part of our
10611070
// modified Quadratic Sieve that changes the distribution of
10621071
// distinct smooth numbers on the sieving range, in theory,

0 commit comments

Comments
 (0)