Skip to content

Commit 94d2fa2

Browse files
Smooth/diff wheel radius
1 parent 0fc3977 commit 94d2fa2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ struct Factorizer {
749749
BigInteger batchNumber;
750750
BigInteger batchOffset;
751751
BigInteger batchTotal;
752-
BigInteger wheelRadius;
752+
BigInteger smoothWheelRadius;
753+
BigInteger diffWheelRadius;
753754
size_t firstGaussianElimPrimeId;
754755
size_t wheelEntryCount;
755756
size_t rowLimit;
@@ -764,10 +765,15 @@ struct Factorizer {
764765
Factorizer(const BigInteger &tf, const BigInteger &tfsqrt, const BigInteger &range, size_t nodeCount, size_t nodeId, size_t fgepi, size_t w, size_t rl, size_t bn,
765766
const std::vector<size_t> &p, ForwardFn ffn, ForwardFn bfn)
766767
: toFactorSqr(tf * tf), toFactor(tf), toFactorSqrt(tfsqrt), batchRange(range), batchNumber(bn), batchOffset(nodeId * range), batchTotal(nodeCount * range),
767-
firstGaussianElimPrimeId(fgepi), wheelRadius(1U), wheelEntryCount(w), rowLimit(rl), isIncomplete(true), primes(p), forwardFn(ffn), backwardFn(bfn)
768+
firstGaussianElimPrimeId(fgepi), smoothWheelRadius(1U), diffWheelRadius(1U), wheelEntryCount(w), rowLimit(rl), isIncomplete(true), primes(p), forwardFn(ffn), backwardFn(bfn)
768769
{
769-
for (size_t i = 0U; i < primes.size(); ++i) {
770-
wheelRadius *= primes[i];
770+
for (size_t i = 0U; i < firstGaussianElimPrimeId; ++i) {
771+
smoothWheelRadius *= primes[i];
772+
}
773+
for (size_t i = firstGaussianElimPrimeId; i < primes.size(); ++i) {
774+
const size_t& p = primes[i];
775+
smoothWheelRadius *= p;
776+
diffWheelRadius *= p;
771777
}
772778
}
773779

@@ -994,7 +1000,7 @@ struct Factorizer {
9941000
boost::dynamic_bitset<size_t> vec(primes.size(), 0);
9951001
while (true) {
9961002
// Proceed in steps of the GCD with the smooth prime wheel radius.
997-
BigInteger factor = gcd(num, wheelRadius);
1003+
BigInteger factor = gcd(num, diffWheelRadius);
9981004
if (factor == 1U) {
9991005
break;
10001006
}
@@ -1043,7 +1049,7 @@ struct Factorizer {
10431049
boost::dynamic_bitset<size_t> vec(primes.size(), 0);
10441050
while (true) {
10451051
// Proceed in steps of the GCD with the smooth prime wheel radius.
1046-
BigInteger factor = gcd(num, wheelRadius);
1052+
BigInteger factor = gcd(num, smoothWheelRadius);
10471053
if (factor == 1U) {
10481054
break;
10491055
}

0 commit comments

Comments
 (0)