Skip to content

Commit d093708

Browse files
Fix bool return
1 parent f9ffdf2 commit d093708

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ void gaussianElimination(std::map<BigInteger, boost::dynamic_bitset<size_t>> *ma
751751
if (cpu >= rows) {
752752
break;
753753
}
754-
dispatch.dispatch([col, cpu, &cpuCount, &rows, &c, &mBegin]() {
754+
dispatch.dispatch([col, cpu, &cpuCount, &rows, &c, &mBegin]() -> bool {
755755
auto rowIt = mBegin;
756756
std::advance(rowIt, cpu);
757757
for (size_t row = cpu; row < rows; row += cpuCount) {
@@ -940,8 +940,9 @@ struct Factorizer {
940940
std::set<BigInteger> toStrike;
941941
auto iIt = smoothNumberMap->begin();
942942
const size_t rowCount = smoothNumberMap->size();
943-
for (size_t i = 0U; (i < rowCount) && (result == 1U); ++i) {
944-
dispatch.dispatch([&target, i, iIt, &rowCount, &result, &toStrike, &rowMutex]() {
943+
const size_t rowCountMin2 = rowCount - 2U;
944+
for (size_t i = 0U; (i < rowCountMin2) && (result == 1U); ++i) {
945+
dispatch.dispatch([&target, i, iIt, &rowCount, &result, &toStrike, &rowMutex]() -> bool {
945946
boost::dynamic_bitset<size_t> &iRow = iIt->second;
946947
auto jIt = iIt;
947948
for (size_t j = i + 1U; j < rowCount; ++j) {
@@ -983,12 +984,14 @@ struct Factorizer {
983984
return true;
984985
}
985986
}
987+
988+
return false;
986989
});
987990
++iIt;
988991
}
989992
dispatch.finish();
990993

991-
if ((result != 1U) && (result != target)) {
994+
if (result != 1U) {
992995
return result;
993996
}
994997

@@ -1046,7 +1049,7 @@ std::string find_a_factor(const std::string &toFactorStr, const bool &isConOfSqr
10461049
// This is simply trial division up to the ceiling.
10471050
std::mutex trialDivisionMutex;
10481051
for (size_t primeIndex = 0U; (primeIndex < primes.size()) && (result == 1U); primeIndex += 64U) {
1049-
dispatch.dispatch([&toFactor, &primes, &result, &trialDivisionMutex, primeIndex]() {
1052+
dispatch.dispatch([&toFactor, &primes, &result, &trialDivisionMutex, primeIndex]() -> bool {
10501053
const size_t maxLcv = std::min(primeIndex + 64U, primes.size());
10511054
for (size_t pi = primeIndex; pi < maxLcv; ++pi) {
10521055
const uint16_t &currentPrime = primes[pi];

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name='FindAFactor',
29-
version='3.0.0',
29+
version='3.0.1',
3030
author='Dan Strano',
3131
author_email='dan@unitary.fund',
3232
description='Find any nontrivial factor of a number',

0 commit comments

Comments
 (0)