FindAFactor 3.6.7__tar.gz → 3.6.9__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.9}/FindAFactor/_find_a_factor.cpp +23 -32
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor.egg-info/PKG-INFO +1 -1
- {findafactor-3.6.7 → findafactor-3.6.9}/PKG-INFO +1 -1
- {findafactor-3.6.7 → findafactor-3.6.9}/setup.py +1 -1
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor/__init__.py +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor/dispatchqueue.cpp +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor/find_a_factor.py +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor/oclengine.cpp +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor.egg-info/SOURCES.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor.egg-info/dependency_links.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor.egg-info/requires.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/FindAFactor.egg-info/top_level.txt +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/LICENSE +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/README.md +0 -0
- {findafactor-3.6.7 → findafactor-3.6.9}/setup.cfg +0 -0
@@ -41,12 +41,7 @@
|
|
41
41
|
#include "dispatchqueue.hpp"
|
42
42
|
|
43
43
|
#include <algorithm>
|
44
|
-
#include <chrono>
|
45
|
-
#include <cmath>
|
46
|
-
#include <float.h>
|
47
|
-
#include <fstream>
|
48
44
|
#include <future>
|
49
|
-
#include <iomanip>
|
50
45
|
#include <iostream>
|
51
46
|
#include <map>
|
52
47
|
#include <memory>
|
@@ -54,7 +49,6 @@
|
|
54
49
|
#include <random>
|
55
50
|
#include <stdlib.h>
|
56
51
|
#include <string>
|
57
|
-
#include <time.h>
|
58
52
|
|
59
53
|
#include <boost/dynamic_bitset.hpp>
|
60
54
|
#include <boost/multiprecision/cpp_int.hpp>
|
@@ -189,7 +183,7 @@ inline size_t backward3(const size_t &n) { return (size_t)((~(~n | 1U)) / 3U) +
|
|
189
183
|
constexpr unsigned char wheel5[8U] = {1U, 7U, 11U, 13U, 17U, 19U, 23U, 29U};
|
190
184
|
|
191
185
|
// Make this NOT a multiple of 2, 3, or 5.
|
192
|
-
size_t forward5(const size_t &p) { return wheel5[p
|
186
|
+
size_t forward5(const size_t &p) { return wheel5[p & 7U] + (p >> 3U) * 30U; }
|
193
187
|
|
194
188
|
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
189
|
|
@@ -486,7 +480,7 @@ inline BigInteger _forward3(const BigInteger &p) { return (p << 1U) + (~(~p | 1U
|
|
486
480
|
|
487
481
|
inline BigInteger _backward3(const BigInteger &n) { return ((~(~n | 1U)) / 3U) + 1U; }
|
488
482
|
|
489
|
-
BigInteger _forward5(const BigInteger &p) { return wheel5[(size_t)(p
|
483
|
+
BigInteger _forward5(const BigInteger &p) { return wheel5[(size_t)(p & 7U)] + (p >> 3U) * 30U; }
|
490
484
|
|
491
485
|
BigInteger _backward5(const BigInteger &n) { return std::distance(wheel5, std::lower_bound(wheel5, wheel5 + 8U, (size_t)(n % 30U))) + 8U * (n / 30U) + 1U; }
|
492
486
|
|
@@ -769,7 +763,6 @@ struct Factorizer {
|
|
769
763
|
size_t rowOffset;
|
770
764
|
bool isIncomplete;
|
771
765
|
std::vector<size_t> primes;
|
772
|
-
std::vector<size_t> sqrPrimes;
|
773
766
|
ForwardFn forwardFn;
|
774
767
|
std::vector<BigInteger> smoothNumberKeys;
|
775
768
|
std::vector<boost::dynamic_bitset<size_t>> smoothNumberValues;
|
@@ -782,7 +775,6 @@ struct Factorizer {
|
|
782
775
|
for (size_t i = 0U; i < primes.size(); ++i) {
|
783
776
|
const size_t& p = primes[i];
|
784
777
|
wheelRadius *= p;
|
785
|
-
sqrPrimes.push_back(p * p);
|
786
778
|
smoothNumberKeys.push_back(p);
|
787
779
|
smoothNumberValues.emplace_back(primes.size(), 0);
|
788
780
|
smoothNumberValues.back()[i] = true;
|
@@ -867,7 +859,7 @@ struct Factorizer {
|
|
867
859
|
continue;
|
868
860
|
}
|
869
861
|
factor /= p;
|
870
|
-
vec
|
862
|
+
vec.flip(pi);
|
871
863
|
if (factor == 1U) {
|
872
864
|
break;
|
873
865
|
}
|
@@ -875,7 +867,7 @@ struct Factorizer {
|
|
875
867
|
if (num == 1U) {
|
876
868
|
return vec;
|
877
869
|
}
|
878
|
-
}
|
870
|
+
}
|
879
871
|
if (num != 1U) {
|
880
872
|
return boost::dynamic_bitset<size_t>();
|
881
873
|
}
|
@@ -995,26 +987,24 @@ struct Factorizer {
|
|
995
987
|
}
|
996
988
|
|
997
989
|
BigInteger checkPerfectSquare(BigInteger perfectSquare) {
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
}
|
990
|
+
// Compute x and y
|
991
|
+
const BigInteger x = perfectSquare % toFactor;
|
992
|
+
const BigInteger y = modExp(x, toFactor >> 1U, toFactor);
|
993
|
+
|
994
|
+
// Check congruence of squares
|
995
|
+
BigInteger factor = gcd(toFactor, x + y);
|
996
|
+
if ((factor != 1U) && (factor != toFactor)) {
|
997
|
+
return factor;
|
998
|
+
}
|
1008
999
|
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
if ((factor != 1U) && (factor != toFactor)) {
|
1013
|
-
return factor;
|
1014
|
-
}
|
1015
|
-
}
|
1000
|
+
if (x == y) {
|
1001
|
+
return 1U;
|
1002
|
+
}
|
1016
1003
|
|
1017
|
-
|
1004
|
+
// Try x - y as well
|
1005
|
+
factor = gcd(toFactor, x - y);
|
1006
|
+
if ((factor != 1U) && (factor != toFactor)) {
|
1007
|
+
return factor;
|
1018
1008
|
}
|
1019
1009
|
|
1020
1010
|
return 1U;
|
@@ -1198,10 +1188,11 @@ std::string find_a_factor(const std::string &toFactorStr, const bool &isConOfSqr
|
|
1198
1188
|
const size_t maxPrimeCount = std::min(primes.size(), smoothPrimeCount);
|
1199
1189
|
std::vector<size_t> smoothPrimes;
|
1200
1190
|
for (size_t primeId = 0U; (primeId < primes.size()) && (smoothPrimes.size() < maxPrimeCount); ++primeId) {
|
1201
|
-
const size_t
|
1191
|
+
const size_t p = primes[primeId];
|
1192
|
+
const size_t residue = (size_t)(toFactor % p);
|
1202
1193
|
const size_t sr = _sqrt(residue);
|
1203
1194
|
if ((sr * sr) == residue) {
|
1204
|
-
smoothPrimes.push_back(
|
1195
|
+
smoothPrimes.push_back(p);
|
1205
1196
|
}
|
1206
1197
|
}
|
1207
1198
|
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
|