mirror of https://github.com/Qiskit/qiskit.git
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:
parent
3981a84e74
commit
66fb6fee64
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue