From 66fb6fee64ca9113417bd51f904a66509be7a9d8 Mon Sep 17 00:00:00 2001 From: ebaeumer <48065247+ebaeumer@users.noreply.github.com> Date: Mon, 19 Aug 2024 18:41:25 +0200 Subject: [PATCH] Example code for Store instruction (#12982) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Example code for Store function * update shortened line * Update qiskit/circuit/__init__.py --------- Co-authored-by: Luciano Bello Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --- qiskit/circuit/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qiskit/circuit/__init__.py b/qiskit/circuit/__init__.py index 65a88519a0..1ab084ef20 100644 --- a/qiskit/circuit/__init__.py +++ b/qiskit/circuit/__init__.py @@ -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: