Example code for Store instruction (#12982)

* 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>
This commit is contained in:
ebaeumer 2024-08-19 18:41:25 +02:00 committed by GitHub
parent 3981a84e74
commit 66fb6fee64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -579,6 +579,16 @@ The :class:`Store` instruction is particularly special, in that it allows writin
: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: