Skip to content

Commit

Permalink
Example code for Store instruction (#12982)
Browse files Browse the repository at this point in the history
* Example code for Store function

* update shortened line

* Update qiskit/circuit/__init__.py

---------

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 19, 2024
1 parent 3981a84 commit 66fb6fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions qiskit/circuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,16 @@
:class:`Qubit` nor :class:`Clbit` operands, but has an explicit :attr:`~Store.lvalue` and
:attr:`~Store.rvalue`.
For example, to determine the parity of a bitstring ``cr`` and store it in another register ``creg``,
the :class:`Store` instruction can be used in the following way::
parity = expr.lift(cr[0])
for i in range(1,n):
parity = expr.bit_xor(cr[i], parity)
qc.store(creg[0], parity)
.. autoclass:: Store
:show-inheritance:
:members:
Expand Down

0 comments on commit 66fb6fe

Please sign in to comment.