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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ python -m pygridsynth <theta> <epsilon> [options]

### Options

- `--dps`: Sets the calculation precision (default: `128`).
- `--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 (default: `200`).
- `--ftimeout`, `-ft`: Sets the timeout for factorization in milliseconds (default: `50`).
- `--verbose`, `-v`: Enables detailed output.
Expand All @@ -50,7 +51,7 @@ python -m pygridsynth <theta> <epsilon> [options]
### Example Execution

```bash
python -m pygridsynth 0.5 1e-50 --dps 256 --verbose --time
python -m pygridsynth 0.5 1e-50 --verbose --time
```

This command will:
Expand Down Expand Up @@ -89,4 +90,4 @@ This project is licensed under the GNU General Public License v3 or later.
- Neil J. Ross and Peter Selinger. Optimal ancilla-free Clifford+T approximation of z-rotations, 2016.
- Peter Selinger. Efficient Clifford+T approximation of single-qubit operators, 2014.
- Peter Selinger and Neil J. Ross. Exact and approximate synthesis of quantum circuits. https://www.mathstat.dal.ca/~selinger/newsynth/, 2018.
- Vadym Kliuchnikov, Dmitri Maslov, and Michele Mosca. Fast and efficient exact synthesis of single qubit unitaries generated by Clifford and T gates, 2013.
- Vadym Kliuchnikov, Dmitri Maslov, and Michele Mosca. Fast and efficient exact synthesis of single qubit unitaries generated by Clifford and T gates, 2013.
11 changes: 8 additions & 3 deletions pygridsynth/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ def main():

parser.add_argument('theta', type=str)
parser.add_argument('epsilon', type=str)
parser.add_argument('--dps', type=int, default=128)
parser.add_argument('--dps', type=int, default=None)
parser.add_argument('--dtimeout', '-dt', type=int, default=200)
parser.add_argument('--ftimeout', '-ft', type=int, default=50)
parser.add_argument('--verbose', '-v', action='store_true')
parser.add_argument('--time', '-t', action='store_true')
parser.add_argument('--showgraph', '-g', action='store_true')

args = parser.parse_args()
epsilon1 = mpmath.mpmathify(args.epsilon)
dps_of_result = -mpmath.log10(epsilon1)
# Use the same heuristic as Haskell gridsynth for setting dps
if args.dps is None:
args.dps = 15 + 2.5 * dps_of_result
mpmath.mp.dps = args.dps
epsilon = mpmath.mpmathify(f"{args.epsilon}")
mpmath.mp.pretty = True
theta = mpmath.mpmathify(args.theta)
epsilon = mpmath.mpmathify(args.epsilon)
theta = mpmath.mpmathify(f"{args.theta}")

gates = gridsynth_gates(theta=theta, epsilon=epsilon,
verbose=args.verbose, measure_time=args.time,
Expand Down