Skip to content

Commit 6af1e0a

Browse files
Found a tiny bug!
1 parent 65101ab commit 6af1e0a

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -796,15 +796,15 @@ struct Factorizer {
796796
smoothNumberSet.insert(candidate);
797797
smoothNumberKeys.push_back(candidate);
798798
smoothNumberValues.push_back(rfv);
799-
}
800-
}
801-
// If we have enough rows for Gaussian elimination already,
802-
// there's no reason to sieve any further.
803-
if (smoothNumberKeys.size() > rowLimit) {
804-
isIncomplete = false;
805-
smoothNumberSet.clear();
799+
// If we have enough rows for Gaussian elimination already,
800+
// so there's no reason to sieve any further.
801+
if (smoothNumberKeys.size() > rowLimit) {
802+
isIncomplete = false;
803+
smoothNumberSet.clear();
806804

807-
return;
805+
return;
806+
}
807+
}
808808
}
809809
}
810810
}
@@ -1003,7 +1003,7 @@ struct Factorizer {
10031003
boost::dynamic_bitset<size_t> vec(primes.size(), 0);
10041004
while (true) {
10051005
// Proceed in steps of the GCD with the smooth prime wheel radius.
1006-
BigInteger factor = gcd(num, diffWheelRadius);
1006+
BigInteger factor = gcd(n, diffWheelRadius);
10071007
if (factor == 1U) {
10081008
break;
10091009
}

FindAFactor/find_a_factor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def find_a_factor(n,
1212
method=FactoringMethod(int(os.environ.get('FINDAFACTOR_METHOD'))) if os.environ.get('FINDAFACTOR_METHOD') else FactoringMethod.PRIME_SOLVER,
1313
node_count=int(os.environ.get('FINDAFACTOR_NODE_COUNT')) if os.environ.get('FINDAFACTOR_NODE_COUNT') else 1,
1414
node_id=int(os.environ.get('FINDAFACTOR_NODE_ID')) if os.environ.get('FINDAFACTOR_NODE_ID') else 0,
15-
gear_factorization_level=int(os.environ.get('FINDAFACTOR_GEAR_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_GEAR_FACTORIZATION_LEVEL') else 11,
16-
wheel_factorization_level=int(os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL') else 11,
15+
gear_factorization_level=int(os.environ.get('FINDAFACTOR_GEAR_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_GEAR_FACTORIZATION_LEVEL') else 1,
16+
wheel_factorization_level=int(os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL') else 1,
1717
sieving_bound_multiplier=float(os.environ.get('FINDAFACTOR_SIEVING_BOUND_MULTIPLIER')) if os.environ.get('FINDAFACTOR_SIEVING_BOUND_MULTIPLIER') else 1.0,
1818
smoothness_bound_multiplier=float(os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER')) if os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER') else 1.0,
1919
gaussian_elimination_row_multiplier=float(os.environ.get('FINDAFACTOR_GAUSSIAN_ELIMINATION_ROW_MULTIPLIER')) if os.environ.get('FINDAFACTOR_GAUSSIAN_ELIMINATION_ROW_MULTIPLIER') else 1.0,

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ The `find_a_factor()` function should return any nontrivial factor of `to_factor
4545
- `method` (default value: `PRIME_SOLVER`/`0`): `PRIME_SOLVER`/`0` will prove that a number is prime (by failing to find any factors with wheel and gear factorization). `FACTOR_FINDER`/`1` is optimized for the assumption that the number has at least two nontrivial factors.
4646
- `node_count` (default value: `1`): `FindAFactor` can perform factorization in a _distributed_ manner, across nodes, without network communication! When `node_count` is set higher than `1`, the search space for factors is segmented equally per node. If the number to factor is semiprime, and brute-force search is used instead of congruence of squares, for example, all nodes except the one that happens to contain the (unknown) prime factor less than the square root of `to_factor` will ultimately return `1`, while one node will find and return this factor. For best performance, every node involved in factorization should have roughly the same CPU throughput capacity. For `FACTOR_FINDER` mode, this splits the sieving range between nodes, but it does not actually coordinate Gaussian elimination rows between nodes.
4747
- `node_id` (default value: `0`): This is the identifier of this node, when performing distributed factorization with `node_count` higher than `1`. `node_id` values start at `0` and go as high as `(node_count - 1)`.
48-
- `gear_factorization_level` (default value: `11`): This is the value up to which "wheel (and gear) factorization" are applied to "brute force." A value of `11` includes all prime factors of `11` and below and works well for `PRIME_PROVER`, though significantly higher might be preferred in certain cases.
49-
- `wheel_factorization_level` (default value: `11`): "Wheel" vs. "gear" factorization balances two types of factorization wheel ("wheel" vs. "gear" design) that often work best when the "wheel" is only a few prime number levels lower than gear factorization. Optimized implementation for wheels is only available up to `13`. The primes above "wheel" level, up to "gear" level, are the primes used specifically for "gear" factorization. Wheel factorization is also applied to "peturb" `FACTOR_FINDER` mode into non-multiples on the wheel, if the level is set above `1` (which might not actually work, but we leave it for your experimentation).
48+
- `gear_factorization_level` (default value: `1`): This is the value up to which "wheel (and gear) factorization" are applied to "brute force." A value of `11` includes all prime factors of `11` and below and works well for `PRIME_PROVER`, though significantly higher might be preferred in certain cases.
49+
- `wheel_factorization_level` (default value: `1`): "Wheel" vs. "gear" factorization balances two types of factorization wheel ("wheel" vs. "gear" design) that often work best when the "wheel" is only a few prime number levels lower than gear factorization. Optimized implementation for wheels is only available up to `13`. The primes above "wheel" level, up to "gear" level, are the primes used specifically for "gear" factorization. Wheel factorization is also applied to "peturb" `FACTOR_FINDER` mode into non-multiples on the wheel, if the level is set above `1` (which might not actually work, but we leave it for your experimentation).
5050
- `sieving_bound_multiplier` (default value: `1.0`): This controls the sieving bound and is calibrated such that it linearly multiplies the square root of the number to factor (for each `1.0` increment). While this might be a huge bound, remember that sieving termination is primarily controlled by when `gaussian_elimination_row_multiplier` is exactly satisfied.
5151
- `smoothness_bound_multiplier` (default value: `1.0`): This controls smoothness bound and is calibrated such that it linearliy multiplies `exp(0.5 * std::sqrt(log(N) * log(log(N))))` for `N` being the number to factor (for each `1.0` increment). This was a heuristic suggested by Elara (an OpenAI custom GPT).
5252
- `gaussian_elimination_row_multiplier` (default value: `1.0`): This controls the number of rows sieved for Gaussian elimination before terminating the sieve and is calibrated such that it linearly multiplies one plus the number of smooth prime columns in the Gaussian elimination matrix (for each `1.0` increment). So long as this setting is appropriately low enough, `sieving_bound_multiplier` can be set basically arbitrarily high.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "FindAFactor"
11-
version = "5.0.6"
11+
version = "5.1.0"
1212
requires-python = ">=3.8"
1313
description = "Find any nontrivial factor of a number"
1414
readme = {file = "README.txt", content-type = "text/markdown"}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def build_extension(self, ext):
4040

4141
setup(
4242
name='FindAFactor',
43-
version='5.0.6',
43+
version='5.1.0',
4444
author='Dan Strano',
4545
author_email='stranoj@gmail.com',
4646
description='Find any nontrivial factor of a number',

0 commit comments

Comments
 (0)