Skip to content

Commit 8c922e8

Browse files
Optimize Gaussian elimination
1 parent 8e9792e commit 8c922e8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,14 +754,15 @@ void gaussianElimination(std::map<BigInteger, boost::dynamic_bitset<size_t>> *ma
754754
dispatch.dispatch([col, cpu, &cpuCount, &rows, &c, &mBegin]() -> bool {
755755
auto rowIt = mBegin;
756756
std::advance(rowIt, cpu);
757-
for (size_t row = cpu; row < rows; row += cpuCount) {
757+
for (size_t row = cpu; ; row += cpuCount) {
758758
boost::dynamic_bitset<size_t> &r = rowIt->second;
759759
if ((row != col) && r[col]) {
760760
r ^= c;
761761
}
762-
if ((row + cpuCount) < rows) {
763-
std::advance(rowIt, cpuCount);
762+
if ((row + cpuCount) >= rows) {
763+
return false;
764764
}
765+
std::advance(rowIt, cpuCount);
765766
}
766767

767768
return false;

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.2.0',
29+
version='3.2.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)