FindAFactor 3.6.7__tar.gz → 3.6.8__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor/_find_a_factor.cpp +22 -25
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor.egg-info/PKG-INFO +1 -1
- {findafactor-3.6.7 → findafactor-3.6.8}/PKG-INFO +1 -1
- {findafactor-3.6.7 → findafactor-3.6.8}/setup.py +1 -1
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor/__init__.py +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor/dispatchqueue.cpp +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor/find_a_factor.py +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor/oclengine.cpp +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor.egg-info/SOURCES.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor.egg-info/dependency_links.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor.egg-info/requires.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/FindAFactor.egg-info/top_level.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/LICENSE +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/README.md +0 -0
- {findafactor-3.6.7 → findafactor-3.6.8}/setup.cfg +0 -0
@@ -189,7 +189,7 @@ inline size_t backward3(const size_t &n) { return (size_t)((~(~n | 1U)) / 3U) +
|
|
189
189
|
constexpr unsigned char wheel5[8U] = {1U, 7U, 11U, 13U, 17U, 19U, 23U, 29U};
|
190
190
|
|
191
191
|
// Make this NOT a multiple of 2, 3, or 5.
|
192
|
-
size_t forward5(const size_t &p) { return wheel5[p
|
192
|
+
size_t forward5(const size_t &p) { return wheel5[p & 7U] + (p >> 3U) * 30U; }
|
193
193
|
|
194
194
|
size_t backward5(const size_t &n) { return std::distance(wheel5, std::lower_bound(wheel5, wheel5 + 8U, (size_t)(n % 30U))) + 8U * (size_t)(n / 30U) + 1U; }
|
195
195
|
|
@@ -486,7 +486,7 @@ inline BigInteger _forward3(const BigInteger &p) { return (p << 1U) + (~(~p | 1U
|
|
486
486
|
|
487
487
|
inline BigInteger _backward3(const BigInteger &n) { return ((~(~n | 1U)) / 3U) + 1U; }
|
488
488
|
|
489
|
-
BigInteger _forward5(const BigInteger &p) { return wheel5[(size_t)(p
|
489
|
+
BigInteger _forward5(const BigInteger &p) { return wheel5[(size_t)(p & 7U)] + (p >> 3U) * 30U; }
|
490
490
|
|
491
491
|
BigInteger _backward5(const BigInteger &n) { return std::distance(wheel5, std::lower_bound(wheel5, wheel5 + 8U, (size_t)(n % 30U))) + 8U * (n / 30U) + 1U; }
|
492
492
|
|
@@ -769,7 +769,6 @@ struct Factorizer {
|
|
769
769
|
size_t rowOffset;
|
770
770
|
bool isIncomplete;
|
771
771
|
std::vector<size_t> primes;
|
772
|
-
std::vector<size_t> sqrPrimes;
|
773
772
|
ForwardFn forwardFn;
|
774
773
|
std::vector<BigInteger> smoothNumberKeys;
|
775
774
|
std::vector<boost::dynamic_bitset<size_t>> smoothNumberValues;
|
@@ -782,7 +781,6 @@ struct Factorizer {
|
|
782
781
|
for (size_t i = 0U; i < primes.size(); ++i) {
|
783
782
|
const size_t& p = primes[i];
|
784
783
|
wheelRadius *= p;
|
785
|
-
sqrPrimes.push_back(p * p);
|
786
784
|
smoothNumberKeys.push_back(p);
|
787
785
|
smoothNumberValues.emplace_back(primes.size(), 0);
|
788
786
|
smoothNumberValues.back()[i] = true;
|
@@ -875,7 +873,7 @@ struct Factorizer {
|
|
875
873
|
if (num == 1U) {
|
876
874
|
return vec;
|
877
875
|
}
|
878
|
-
}
|
876
|
+
}
|
879
877
|
if (num != 1U) {
|
880
878
|
return boost::dynamic_bitset<size_t>();
|
881
879
|
}
|
@@ -995,26 +993,24 @@ struct Factorizer {
|
|
995
993
|
}
|
996
994
|
|
997
995
|
BigInteger checkPerfectSquare(BigInteger perfectSquare) {
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
}
|
996
|
+
// Compute x and y
|
997
|
+
const BigInteger x = perfectSquare % toFactor;
|
998
|
+
const BigInteger y = modExp(x, toFactor >> 1U, toFactor);
|
999
|
+
|
1000
|
+
// Check congruence of squares
|
1001
|
+
BigInteger factor = gcd(toFactor, x + y);
|
1002
|
+
if ((factor != 1U) && (factor != toFactor)) {
|
1003
|
+
return factor;
|
1004
|
+
}
|
1008
1005
|
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
if ((factor != 1U) && (factor != toFactor)) {
|
1013
|
-
return factor;
|
1014
|
-
}
|
1015
|
-
}
|
1006
|
+
if (x == y) {
|
1007
|
+
return 1U;
|
1008
|
+
}
|
1016
1009
|
|
1017
|
-
|
1010
|
+
// Try x - y as well
|
1011
|
+
factor = gcd(toFactor, x - y);
|
1012
|
+
if ((factor != 1U) && (factor != toFactor)) {
|
1013
|
+
return factor;
|
1018
1014
|
}
|
1019
1015
|
|
1020
1016
|
return 1U;
|
@@ -1198,10 +1194,11 @@ std::string find_a_factor(const std::string &toFactorStr, const bool &isConOfSqr
|
|
1198
1194
|
const size_t maxPrimeCount = std::min(primes.size(), smoothPrimeCount);
|
1199
1195
|
std::vector<size_t> smoothPrimes;
|
1200
1196
|
for (size_t primeId = 0U; (primeId < primes.size()) && (smoothPrimes.size() < maxPrimeCount); ++primeId) {
|
1201
|
-
const size_t
|
1197
|
+
const size_t p = primes[primeId];
|
1198
|
+
const size_t residue = (size_t)(toFactor % p);
|
1202
1199
|
const size_t sr = _sqrt(residue);
|
1203
1200
|
if ((sr * sr) == residue) {
|
1204
|
-
smoothPrimes.push_back(
|
1201
|
+
smoothPrimes.push_back(p);
|
1205
1202
|
}
|
1206
1203
|
}
|
1207
1204
|
if (smoothPrimes.size() < maxPrimeCount) {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|