Skip to content

Conversation

chriseclectic
Copy link
Member

  • Fixed measure and control gates to work on registers of qubits.
  • Fixed errors with concurrence and state_fidelity in tools.qi
  • Added unit tests for tools.qi functions

Description

  • circuit.measure(qr, cr) now will apply measure operations between all qubits in a quantum register and all bits in a classical register. If registers are not the same size it will raise an exception. Eg if both a size 2 it will return qasm measure qr[0]->cr[0]; measure qr[1]->cr[1];
  • circuit.cx(qr1, qr2) will apply CNOT gates between each qubit in register qr1 to each qubit in register qr2. If registers are not the same size it will raise an exception. Eg. if both a size 2 it will return qasm cx(qr1[0], qr2[0]); cx(qr1[1], qr2[1]);. The same change was made for cz, cy, ch, crz, cu1, cu3.
  • The state_fidelity function was returning NaN for pure state density matrices due to issues with scipy.linalg.sqrtm. I fixed this by adding a function funm_svd similar to the build in scipy.linalg.funm that applies a scalar function to the singular values of a matrix. The matrix square root for positive-semidefinite matrices is then computed using this function.
  • The concurrence function was returning negative values for some states which should have zero concurrence (for example the maximally mixed two qubit state). This has been fixed.
  • Fixed concurrence and purity to work for array_like input states (such as lists) by converting the input to a ndarray.
  • Added raise Exception in place of print statements for input errors to several tools.qi functions.

How Has This Been Tested?

All previous tests pass, and new unit tests have been added for functions in the tools.qi module.

Types of changes

  • Bug fix
  • New feature
  • Breaking change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

… to qi

- concurrence was returning negative values for some state with zero
concurrence
- state_fidelity was returning NaN for pure state density matrices.
Fixed by adding function funm_svd which applies as scalar function to
singular values of a matrix, and implementing sort this way.
- fixed concurrence and purity to work for array_like inputs (i.e.
lists)
- added unit tests for qi functions
@chriseclectic
Copy link
Member Author

Closed and split into two seperate pull requests

ewinston pushed a commit to ewinston/qiskit that referenced this pull request Aug 10, 2017
taalexander pushed a commit to taalexander/qiskit-terra that referenced this pull request May 2, 2019
* Adding template

* Renaming md
mantcep added a commit to mantcep/qiskit-terra that referenced this pull request Apr 18, 2021
* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

* Implement initial QFT adder circuit

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Fix QFT adder carry out; Switch to non-modular as default

* Expand adder tests with QFT adder

* Rename test_adder.py -> test_adders.py

* Include additional QFT adder documentation

* Fix typos

* Fix documentation math

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add non-modular test as default

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Remove duplicate file after merge

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
mergify bot added a commit that referenced this pull request May 21, 2021
* Implement ripple-carry adder circuit (#11)

* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Implement QFT adder (#22)

* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

* Implement initial QFT adder circuit

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Fix QFT adder carry out; Switch to non-modular as default

* Expand adder tests with QFT adder

* Rename test_adder.py -> test_adders.py

* Include additional QFT adder documentation

* Fix typos

* Fix documentation math

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add non-modular test as default

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Remove duplicate file after merge

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Implemented classical adder in QFT paper (#13)

* empty

* empty

* Implemented classical adder in QFT paper

* Implemented classical adder in QFT paper

* fix classicaladd imports

* fix missing imports

* Added the tests part for ClassicalAdd

* move cin to bottom

* Updated the documentation and test parts for ClassicalAdder

* Updated init files

* Deleted adder folder from the git repository

* Deleted test_classicaladd.py

* Deleted old classicaladder file

* Deleted __init__.py file from repository

* Updated classical_adder file

Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>

* unify tests

* inject base class ``Adder``

* add reno

* fix lint

* fix trailing whitespace in line beginning

* rework docstrings for less duplication

* several updates

* modular RippleCarryAdder
* test that ancillas are uncomputed
* fix ClassicalAdder ancilla uncompute
* replace all to_instruction by to_gate

* lint

* rename classical to plain, make plain modular

* Renamed PlainAdder to VBERippleCarryAdder (#29)

Co-authored-by: Cryoris <jules.gacon@googlemail.com>

* rename modular->fixed point

and fix lint

* add author names to adders

* add comment on how the test works

* black

* add fixed/half/full, misses test for full

* add test for "full"

* black

* update docstrings

* fix sphinx

* rename fixed-point to fixed-sized

Co-authored-by: Mantas Čepulkovskis <60826723+mantcep@users.noreply.github.com>
Co-authored-by: Manjula <64902594+ManjulaGandhi@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify bot added a commit that referenced this pull request Jun 1, 2021
* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

* Implement initial QFT adder circuit

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Fix QFT adder carry out; Switch to non-modular as default

* Expand adder tests with QFT adder

* Rename test_adder.py -> test_adders.py

* Include additional QFT adder documentation

* Fix typos

* Implement ripple-carry adder circuit (#11)

* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Fix documentation math

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add non-modular test as default

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Remove duplicate file after merge

* Implement QFT adder (#22)

* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

* Implement initial QFT adder circuit

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Fix QFT adder carry out; Switch to non-modular as default

* Expand adder tests with QFT adder

* Rename test_adder.py -> test_adders.py

* Include additional QFT adder documentation

* Fix typos

* Fix documentation math

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add non-modular test as default

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Remove duplicate file after merge

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Implemented classical adder in QFT paper (#13)

* empty

* empty

* Implemented classical adder in QFT paper

* Implemented classical adder in QFT paper

* fix classicaladd imports

* fix missing imports

* Added the tests part for ClassicalAdd

* move cin to bottom

* Updated the documentation and test parts for ClassicalAdder

* Updated init files

* Deleted adder folder from the git repository

* Deleted test_classicaladd.py

* Deleted old classicaladder file

* Deleted __init__.py file from repository

* Updated classical_adder file

Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>

* unify tests

* inject base class ``Adder``

* add reno

* fix lint

* Implement initial classical multiplier

* Implement test for multipliers

* Update docstring

* fix trailing whitespace in line beginning

* rework docstrings for less duplication

* Change instructions to gates in adder circuits

* Generalize multiplier for any adder

* Expand multiplier test with all adders

* Fix pylint errors

* Implement review suggestions

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* several updates

* modular RippleCarryAdder
* test that ancillas are uncomputed
* fix ClassicalAdder ancilla uncompute
* replace all to_instruction by to_gate

* lint

* rename classical to plain, make plain modular

* Implement initial QFT multiplier draft

* Update QFT multiplier docstring

* Create common multiplier class

* Renamed PlainAdder to VBERippleCarryAdder (#29)

Co-authored-by: Cryoris <jules.gacon@googlemail.com>

* rename modular->fixed point

and fix lint

* add author names to adders

* add comment on how the test works

* black

* Fix common multiplier errors

* Update classical multiplier default adder name

* Fix QFT multiplier registers

* Implement tests for multipliers

* Fix lint

* Add black formatter changes

* Switch to adder object instead of type

* Update classical multiplier drawing

* Switch to PhaseGate in QFT multiplier

* Rename multipliers

* Implement modulo in QFT multiplier

* Update to half adder in cumulative multiplier

* Make number of output qubits optional

* Implement modular cumulative multiplier

* Add test for modular multiplication

* Fix wrong parameter name

* Expand common multiplier class with checks; Add more tests for multipliers

* Add black and lint changes

* Add releasenote

* Attempt cyclic import fix

* Attempt to fix cyclic import once more

* Update qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py

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

* Update qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py

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

* Update qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py

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

* Update qiskit/circuit/library/arithmetic/multipliers/multiplier.py

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

* Update qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py

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

* Add additional test cases

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

* Include circuit diagram for QFT multiplier

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

* Update docstring as suggested

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

* Move num_result_qubits logic to parent class

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

* Switch to NotImplementedError for cumulative multiplier

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

* Add black changes

* Update Multiplier class docstring

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

* Add lint changes

* Update qiskit/circuit/library/arithmetic/multipliers/multiplier.py

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

* Update qiskit/circuit/library/arithmetic/multipliers/multiplier.py

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

* Add black and pylint fixes

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Manjula <64902594+ManjulaGandhi@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
gnannicini referenced this pull request in gnannicini/qiskit-terra Jun 15, 2021
Improved logical/physical qubit mapping
gadial pushed a commit to gadial/qiskit that referenced this pull request Dec 1, 2021
Small fixes and error handling test
t-imamichi referenced this pull request in t-imamichi/qiskit-terra Jan 14, 2022
eliarbel pushed a commit to eliarbel/qiskit that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant