Skip to content

Commit

Permalink
Refactor Shor's algorithm (qiskit-community/qiskit-aqua#975)
Browse files Browse the repository at this point in the history
* Use AlgorithmResult for return from run()

* Store phi_add as a gate, create _init_circuit method

* Use inverse and control logic inside controlled_controlled_phi_add_mod_N

* Use a separate circuit to be inverted during _controlled_multiple_mod_N

* Typing on _get_factors

* Import Gate from qiskit.circuit

* Use name in init_circuit

* Use inverse of controlled_multiple_mod_N

* Use gates for multiplication functions

* Reduce gate name and keep register order consistent

* Revert back to circuit functions

* Update documentation and extract modinv

* Update documentation in accordance with contribution guidelines

* Add tests

* Update for spell check

* Apply suggestions from code review

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Rename to double_controlled_phi_add

* Initialise QuantumCircuit without private method

* Make modinv error message more meaningful

* Remove phi_add_gate test

* Add int type hint

* Omit quantum register in _phi_add_gate

* replace compose calls with append

* Use angles ParameterVector and rewrite double_controlled_phi_add_mod_N

* Mak phi_add_gate static

* Update indexing in _double_controlled_phi_add_mod_N

* Move inverted controlled addition into _controlled_multiple_mod_N

* Update documentation

* Apply angles correctly

* Revert "Remove phi_add_gate test"

This reverts commit 907e86136b505b627d491251f5f0e54ab9918971.

* Optimize imports

* Update phi_add_gate test logic

* Remove phi_add_gate test

* Remove redundant qubit index call

* rename multiple_mod_N to gate, update formatting

* Add extra test case for modinv test

* Use circuit.qubits explicitly when reconstructing registers

* replace append calls in controlled addition circuit

* Make qft an instruction during __init__

* replace compose calls in _controlled_multiple_mod_N_gate

* Update docstrings

* Apply IQFT at the end of the exponentiation

* refactor logging formatting for results

* Make trivial factor check less verbose

* Return counts of successful results instead of each measurement

* Refactor factorization logic and logging in _get_factors()

* Add test cases for result counts

* Use % for logging statements

* extract continued fraction logic

* Sort factors in return of _get_factors

* rename x_value to x_final

* Fix type hint

* Do not evaluate i = N+1 in _get_factors()

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
  • Loading branch information
4 people authored Jun 3, 2020
1 parent a9e0acc commit f1ec822
Showing 1 changed file with 209 additions and 212 deletions.
Loading

0 comments on commit f1ec822

Please sign in to comment.