Skip to content

Commit

Permalink
as equivalence
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 committed Mar 10, 2023
1 parent e3bc46a commit 1a474f6
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,7 @@ def measure(self, qubit: QubitSpecifier, cbit: ClbitSpecifier) -> InstructionSet
.. code-block::
from qiskit import QuantumCircuit
circuit = QuantumCircuit(1,1)
circuit = QuantumCircuit(1, 1)
circuit.h(0)
circuit.measure(0, 0)
circuit.draw()
Expand All @@ -2302,41 +2302,33 @@ def measure(self, qubit: QubitSpecifier, cbit: ClbitSpecifier) -> InstructionSet
c: 1/══════╩═
0
It is possible to call ``measure`` with lists of qubits and cbits of the same size:
It is possible to call ``measure`` with lists of qubits and cbits of the same size, as a
shortcut. These two forms produce identical output::
.. code-block::
circuit = QuantumCircuit(2,2)
circuit.measure([0,1], [0,1]) # same as "circuit.measure(0,0); circuit.measure(1,1);"
circuit = QuantumCircuit(2, 2)
circuit.measure([0,1], [0,1])
.. parsed-literal::
.. code-block::
┌─┐
q_0: ┤M├───
└╥┘┌─┐
q_1: ─╫─┤M├
║ └╥┘
c: 2/═╩══╩═
0 1
circuit = QuantumCircuit(2, 2)
circuit.measure(0, 0)
circuit.measure(1, 1)
It is also possible to do a one-to-many readout:
It is also possible to do a one-to-many readout. These two forms produce identical output::
.. code-block::
circuit = QuantumCircuit(2,2)
circuit.measure(0, [0,1]) # same as "circuit.measure(0,0); circuit.measure(0,1);"
circuit.measure(0, [0,1])
.. code-block::
.. parsed-literal::
circuit = QuantumCircuit(2, 2)
circuit.measure(0, 0)
circuit.measure(0, 1)
┌─┐┌─┐
q_0: ┤M├┤M├
└╥┘└╥┘
q_1: ─╫──╫─
║ ║
c: 2/═╩══╩═
0 1
Instead of lists, you can use :class:`~qiskit.circuit.QuantumRegister` and
:class:`~qiskit.circuit.ClassicalRegister` under the same logic.
Expand All @@ -2349,14 +2341,13 @@ def measure(self, qubit: QubitSpecifier, cbit: ClbitSpecifier) -> InstructionSet
circuit = QuantumCircuit(qreg, creg)
circuit.measure(qreg, creg)
This is equivalent to::
.. parsed-literal::
.. code-block::
┌─┐┌─┐
qreg: ┤M├┤M├
└╥┘└╥┘
creg: 2/═╩══╩═
0 1
circuit = QuantumCircuit(qreg, creg)
circuit.measure(qreg[0], creg[0])
circuit.measure(qreg[0], creg[1])
"""
return self.append(Measure(), [qubit], [cbit])
Expand Down

0 comments on commit 1a474f6

Please sign in to comment.