Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ repos:
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ python -m pygridsynth <theta> <epsilon> [options]

### Options

- `--dps`: Sets the working precision of the calculation. If `--dps` is not given, then the working precision will
be calculated from `epsilon`.
- `--dtimeout`, `-dt`: Sets the timeout for solving diophantine equations in milliseconds.
- `--ftimeout`, `-ft`: Sets the timeout for factorization in milliseconds.
- `--dloop`, `-dl`: Sets the maximum loop count for the diophantine algorithm (default: `2000`).
- `--floop`, `-fl`: Sets the maximum loop count for the factoring algorithm (default: `500`).
- `--seed`: Sets the random seed for deterministic results (default: `0`).
- `--dps`: Sets the working precision of the calculation. If not specified, the working precision will be calculated from `epsilon`.
- `--dtimeout`, `-dt`: Maximum milliseconds allowed for a single Diophantine equation solving.
- `--ftimeout`, `-ft`: Maximum milliseconds allowed for a single integer factoring attempt.
- `--dloop`, `-dl`: Maximum number of failed integer factoring attempts allowed during Diophantine equation solving (default: `2000`).
- `--floop`, `-fl`: Maximum number of failed integer factoring attempts allowed during the factoring process (default: `500`).
- `--seed`: Random seed for deterministic results.(default: `0`)
- `--verbose`, `-v`: Enables detailed output.
- `--time`, `-t`: Measures the execution time.
- `--showgraph`, `-g`: Displays the decomposition result as a graph.
Expand Down
14 changes: 10 additions & 4 deletions pygridsynth/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
from .loop_controller import LoopController

helps = {
"dt": "Diophantine algorithm timeout in milliseconds",
"ft": "Factoring algorithm timeout in milliseconds",
"dl": "Diophantine algorithm max loop count",
"fl": "Factoring algorithm max loop count",
"dt": "Maximum milliseconds allowed for a single Diophantine equation solving",
"ft": "Maximum milliseconds allowed for a single integer factoring attempt",
"dl": (
"Maximum number of failed integer factoring attempts "
"allowed during Diophantine equation solving"
),
"fl": (
"Maximum number of failed integer factoring attempts "
"allowed during the factoring process"
),
"seed": "Random seed for deterministic results",
}

Expand Down
4 changes: 2 additions & 2 deletions pygridsynth/diophantine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _find_factor(n, loop_controller: LoopController, M=128):
L = int(10 ** (len(str(n)) / 4) * 1.1774 + 10)

loop_controller.start_factoring()
while loop_controller.check_factoring_continue():
while True:
x = y + n
while k < r:
q = 1
Expand All @@ -47,7 +47,7 @@ def _find_factor(n, loop_controller: LoopController, M=128):
if g != 1:
break
return None if g == n else g
if k >= L:
if k >= L and not loop_controller.check_factoring_continue():
return None
r <<= 1

Expand Down