Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of register names with multiple underscores in mpl and latex drawers #7459

Merged
merged 19 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions qiskit/visualization/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,23 +451,18 @@ def _get_bit_labels(self):
initial_qbit = " |0>" if self._initial_state else ""
initial_cbit = " 0" if self._initial_state else ""

def _fix_double_script(bit_label):
words = bit_label.split(" ")
words = [word.replace("_", r"\_") if word.count("_") > 1 else word for word in words]
words = [
word.replace("^", r"\^{\ }") if word.count("^") > 1 else word for word in words
]
bit_label = " ".join(words).replace(" ", "\\;")
return bit_label

# quantum register
for ii, reg in enumerate(self._qubits):
register = self._bit_locations[reg]["register"]
index = self._bit_locations[reg]["index"]
reg_size = 0 if register is None else register.size
qubit_label = get_bit_label("mpl", register, index, qubit=True, layout=self._layout)
qubit_label = "$" + _fix_double_script(qubit_label) + "$" + initial_qbit
qubit_label = "$" + qubit_label + "$" + initial_qbit

text_width = self._get_text_width(qubit_label, self._fs) * 1.15
reg_single = 0 if reg_size < 2 else 1
text_width = (
self._get_text_width(qubit_label, self._fs, reg_to_remove=reg_single) * 1.15
)
if text_width > longest_bit_label_width:
longest_bit_label_width = text_width
pos = -ii
Expand All @@ -487,6 +482,7 @@ def _fix_double_script(bit_label):
for ii, reg in enumerate(self._clbits):
register = self._bit_locations[reg]["register"]
index = self._bit_locations[reg]["index"]
reg_size = 0 if register is None else register.size
if register is None or not self._cregbundle or prev_creg != register:
n_lines += 1
idx += 1
Expand All @@ -495,12 +491,14 @@ def _fix_double_script(bit_label):
clbit_label = get_bit_label(
"mpl", register, index, qubit=False, cregbundle=self._cregbundle
)
clbit_label = _fix_double_script(clbit_label)
if register is None or not self._cregbundle:
clbit_label = "$" + clbit_label + "$"
clbit_label += initial_cbit

text_width = self._get_text_width(clbit_label, self._fs) * 1.15
reg_single = 0 if reg_size < 2 or self._cregbundle else 1
text_width = (
self._get_text_width(clbit_label, self._fs, reg_to_remove=reg_single) * 1.15
)
if text_width > longest_bit_label_width:
longest_bit_label_width = text_width
pos = y_off - idx
Expand Down Expand Up @@ -579,7 +577,7 @@ def _get_coords(self, n_lines):
anchors = [self._q_anchors[ii].get_index() for ii in self._qubits_dict]
return max(anchors) if anchors else 0

def _get_text_width(self, text, fontsize, param=False):
def _get_text_width(self, text, fontsize, param=False, reg_to_remove=None):
"""Compute the width of a string in the default font"""
if not text:
return 0.0
Expand All @@ -596,6 +594,11 @@ def _get_text_width(self, text, fontsize, param=False):
# If there are subscripts or superscripts in mathtext string
# we need to account for that spacing by manually removing
# from text string for text length

# if it's a register and there's a subscript at the end,
# remove 1 underscore, otherwise don't remove any
if reg_to_remove is not None:
num_underscores = reg_to_remove
if num_underscores:
text = text.replace("_", "", num_underscores)
if num_carets:
jakelishman marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
30 changes: 26 additions & 4 deletions qiskit/visualization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,18 @@ def get_bit_label(drawer, register, index, qubit=True, layout=None, cregbundle=T
reg_name = f"{register.name}"
reg_name_index = f"{register.name}_{index}"
else:
reg_name = f"{{{register.name}}}"
reg_name_index = f"{{{register.name}}}_{{{index}}}"
reg_name = f"{{{fix_special_characters(register.name)}}}"
reg_name_index = f"{reg_name}_{{{index}}}"

# Clbits
if not qubit:
if cregbundle:
if cregbundle and drawer != "latex":
bit_label = f"{register.name}"
elif register.size == 1:
return bit_label

size = register.size
if size == 1 or cregbundle:
size = 1
bit_label = reg_name
else:
bit_label = reg_name_index
Expand All @@ -218,6 +222,8 @@ def get_bit_label(drawer, register, index, qubit=True, layout=None, cregbundle=T
bit_label = f"{virt_bit} -> {index}"
else:
bit_label = f"{{{virt_bit}}} \\mapsto {{{index}}}"
if drawer != "text":
bit_label = bit_label.replace(" ", "\\;") # use wider spaces
else:
bit_label = index_str

Expand Down Expand Up @@ -272,6 +278,22 @@ def get_condition_label(condition, clbits, bit_locations, cregbundle):
return label, clbit_mask, vlist


def fix_special_characters(label):
"""
Convert any special characters for mpl and latex drawers.
Currently only checks for multiple underscores in register names
and uses wider space for mpl and latex drawers.

Args:
label (str): the label to fix

Returns:
str: label to display
"""
label = label.replace("_", r"\_").replace(" ", "\\;")
return label


def generate_latex_label(label):
"""Convert a label to a valid latex string."""
if not HAS_PYLATEX:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
Fixes a problem in the ``mpl`` circuit drawer when register names
with multiple underscores in the name did not display correctly.
Also the same problem would cause the ``latex`` drawer to fail,
which has been fixed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions test/ipynb/mpl/circuit/test_circuit_matplotlib_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ def test_long_name(self):

self.circuit_drawer(circuit, filename="long_name.png")

def test_multi_underscore_reg_names(self):
"""Test that multi-underscores in register names display properly"""
q_reg1 = QuantumRegister(1, "q1_re__g__g")
q_reg3 = QuantumRegister(3, "q3_re_g__g")
c_reg1 = ClassicalRegister(1, "c1_re_g__g")
c_reg3 = ClassicalRegister(3, "c3_re_g__g")
circuit = QuantumCircuit(q_reg1, q_reg3, c_reg1, c_reg3)

self.circuit_drawer(circuit, cregbundle=True, filename="multi_underscore_true.png")
self.circuit_drawer(circuit, cregbundle=False, filename="multi_underscore_false.png")

def test_conditional(self):
"""Test that circuits with conditionals draw correctly"""
qr = QuantumRegister(2, "q")
Expand Down
2 changes: 1 addition & 1 deletion test/python/visualization/references/test_latex_4597.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \qw & \qw & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \qw & \qw & \qw & \qw\\
\nghost{{q}_{2} : } & \lstick{{q}_{2} : } & \qw & \gate{\mathrm{X}} & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{3}}} \cw & \control \cw^(0.0){^{\mathtt{0x2}}} \cwx[-1] & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{3}}} \cw & \control \cw^(0.0){^{\mathtt{0x2}}} \cwx[-1] & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{qr}_{0} : } & \lstick{{qr}_{0} : } & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\
\nghost{{qr}_{1} : } & \lstick{{qr}_{1} : } & \qw & \qw & \gate{\mathrm{X}} & \qw & \qw\\
\nghost{\mathrm{cr : }} & \lstick{\mathrm{cr : }} & \lstick{/_{_{2}}} \cw & \controlo \cw^(0.0){^{\mathtt{cr_1=0x0}}} \cwx[-2] & \control \cw^(0.0){^{\mathtt{cr_0=0x1}}} \cwx[-1] & \cw & \cw\\
\nghost{\mathrm{{cr} : }} & \lstick{\mathrm{{cr} : }} & \lstick{/_{_{2}}} \cw & \controlo \cw^(0.0){^{\mathtt{cr_1=0x0}}} \cwx[-2] & \control \cw^(0.0){^{\mathtt{cr_0=0x1}}} \cwx[-1] & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{H}} & \meter & \qw & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \gate{\mathrm{H}} & \qw & \meter & \qw & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{2}}} \cw & \dstick{_{_{\hspace{0.0em}0}}} \cw \ar @{<=} [-2,0] & \dstick{_{_{\hspace{0.0em}1}}} \cw \ar @{<=} [-1,0] & \control \cw^(0.0){^{\mathtt{0x2}}} \cwx[-2] & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{2}}} \cw & \dstick{_{_{\hspace{0.0em}0}}} \cw \ar @{<=} [-2,0] & \dstick{_{_{\hspace{0.0em}1}}} \cw \ar @{<=} [-1,0] & \control \cw^(0.0){^{\mathtt{0x2}}} \cwx[-2] & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{0} : \ket{{0}} } & \lstick{{q}_{0} : \ket{{0}} } & \gate{\mathrm{X}} & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{{q}_{1} : \ket{{0}} } & \lstick{{q}_{1} : \ket{{0}} } & \gate{\mathrm{X}} & \qw & \qw & \qw\\
\nghost{\mathrm{c : 0 }} & \lstick{\mathrm{c : 0 }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{c} : 0 }} & \lstick{\mathrm{{c} : 0 }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
\nghost{{1} : } & \lstick{{1} : } & \qw & \qw & \qw & \qw & \qw\\
\nghost{\mathrm{{0} : }} & \lstick{\mathrm{{0} : }} & \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{1} : }} & \lstick{\mathrm{{1} : }} & \cw & \cw & \dstick{_{_{\hspace{0.0em}}}} \cw \ar @{<=} [-3,0] & \cw & \cw\\
\nghost{\mathrm{cr : }} & \lstick{\mathrm{cr : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{cr} : }} & \lstick{\mathrm{{cr} : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{4} : }} & \lstick{\mathrm{{4} : }} & \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{cs : }} & \lstick{\mathrm{cs : }} & \lstick{/_{_{3}}} \cw & \controlo \cw^(0.0){^{\mathtt{cs_1=0x0}}} \cwx[-6] & \cw & \cw & \cw\\
\nghost{\mathrm{{cs} : }} & \lstick{\mathrm{{cs} : }} & \lstick{/_{_{3}}} \cw & \controlo \cw^(0.0){^{\mathtt{cs_1=0x0}}} \cwx[-6] & \cw & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{qr}_{0} : } & \lstick{{qr}_{0} : } & \gate{\mathrm{H}} & \meter & \qw & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{{qr}_{1} : } & \lstick{{qr}_{1} : } & \gate{\mathrm{H}} & \qw & \meter & \qw & \qw & \qw\\
\nghost{\mathrm{cr1 : }} & \lstick{\mathrm{cr1 : }} & \lstick{/_{_{2}}} \cw & \dstick{_{_{\hspace{0.0em}1}}} \cw \ar @{<=} [-2,0] & \control \cw^(-0.3){^{\mathtt{0x1}}} \cwx[-1] & \cw & \cw & \cw\\
\nghost{\mathrm{cr2 : }} & \lstick{\mathrm{cr2 : }} & \lstick{/_{_{2}}} \cw & \cw & \dstick{_{_{\hspace{1.5em}0}}} \cw \ar @{<=} [-2,0] & \control \cw^(0.0){^{\mathtt{0x3}}} \cwx[-3] & \cw & \cw\\
\nghost{\mathrm{{cr1} : }} & \lstick{\mathrm{{cr1} : }} & \lstick{/_{_{2}}} \cw & \dstick{_{_{\hspace{0.0em}1}}} \cw \ar @{<=} [-2,0] & \control \cw^(-0.3){^{\mathtt{0x1}}} \cwx[-1] & \cw & \cw & \cw\\
\nghost{\mathrm{{cr2} : }} & \lstick{\mathrm{{cr2} : }} & \lstick{/_{_{2}}} \cw & \cw & \dstick{_{_{\hspace{1.5em}0}}} \cw \ar @{<=} [-2,0] & \control \cw^(0.0){^{\mathtt{0x3}}} \cwx[-3] & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{qr}_{0} : } & \lstick{{qr}_{0} : } & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw\\
\nghost{{qr}_{1} : } & \lstick{{qr}_{1} : } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{\mathrm{cr : }} & \lstick{\mathrm{cr : }} & \lstick{/_{_{2}}} \cw & \dstick{_{_{\hspace{0.0em}0}}} \cw \ar @{<=} [-2,0] & \control \cw^(0.0){^{\mathtt{0x1}}} \cwx[-1] & \cw & \cw\\
\nghost{\mathrm{{cr} : }} & \lstick{\mathrm{{cr} : }} & \lstick{/_{_{2}}} \cw & \dstick{_{_{\hspace{0.0em}0}}} \cw \ar @{<=} [-2,0] & \control \cw^(0.0){^{\mathtt{0x1}}} \cwx[-1] & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\documentclass[border=2px]{standalone}

\usepackage[braket, qm]{qcircuit}
\usepackage{graphicx}

\begin{document}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{{q1\_re\_\_g\_\_g} : } & \lstick{{q1\_re\_\_g\_\_g} : } & \qw & \qw\\
\nghost{{q3\_re\_g\_\_g}_{0} : } & \lstick{{q3\_re\_g\_\_g}_{0} : } & \qw & \qw\\
\nghost{{q3\_re\_g\_\_g}_{1} : } & \lstick{{q3\_re\_g\_\_g}_{1} : } & \qw & \qw\\
\nghost{{q3\_re\_g\_\_g}_{2} : } & \lstick{{q3\_re\_g\_\_g}_{2} : } & \qw & \qw\\
\nghost{{c1\_re\_g\_\_g} : } & \lstick{{c1\_re\_g\_\_g} : } & \cw & \cw\\
\nghost{{c3\_re\_g\_\_g}_{0} : } & \lstick{{c3\_re\_g\_\_g}_{0} : } & \cw & \cw\\
\nghost{{c3\_re\_g\_\_g}_{1} : } & \lstick{{c3\_re\_g\_\_g}_{1} : } & \cw & \cw\\
\nghost{{c3\_re\_g\_\_g}_{2} : } & \lstick{{c3\_re\_g\_\_g}_{2} : } & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\documentclass[border=2px]{standalone}

\usepackage[braket, qm]{qcircuit}
\usepackage{graphicx}

\begin{document}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{{q1\_re\_\_g\_\_g} : } & \lstick{{q1\_re\_\_g\_\_g} : } & \qw & \qw\\
\nghost{{q3\_re\_g\_\_g}_{0} : } & \lstick{{q3\_re\_g\_\_g}_{0} : } & \qw & \qw\\
\nghost{{q3\_re\_g\_\_g}_{1} : } & \lstick{{q3\_re\_g\_\_g}_{1} : } & \qw & \qw\\
\nghost{{q3\_re\_g\_\_g}_{2} : } & \lstick{{q3\_re\_g\_\_g}_{2} : } & \qw & \qw\\
\nghost{\mathrm{{c1\_re\_g\_\_g} : }} & \lstick{\mathrm{{c1\_re\_g\_\_g} : }} & \lstick{/_{_{1}}} \cw & \cw\\
\nghost{\mathrm{{c3\_re\_g\_\_g} : }} & \lstick{\mathrm{{c3\_re\_g\_\_g} : }} & \lstick{/_{_{3}}} \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{2}}} \cw & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{2}}} \cw & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{3}}} \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{3}}} \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
\begin{document}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{2} \mapsto {0} : } & \lstick{{q}_{2} \mapsto {0} : } & \qw & \qw & \qw\\
\nghost{{q}_{0} \mapsto {1} : } & \lstick{{q}_{0} \mapsto {1} : } & \qw & \qw & \qw\\
\nghost{{q}_{1} \mapsto {2} : } & \lstick{{q}_{1} \mapsto {2} : } & \gate{\mathrm{U_2}\,(\mathrm{0,\pi})} & \qw & \qw\\
\nghost{{ancilla}_{0} \mapsto {3} : } & \lstick{{ancilla}_{0} \mapsto {3} : } & \qw & \qw & \qw\\
\nghost{{ancilla}_{1} \mapsto {4} : } & \lstick{{ancilla}_{1} \mapsto {4} : } & \qw & \qw & \qw\\
\nghost{{q}_{2}\;\mapsto\;{0} : } & \lstick{{q}_{2}\;\mapsto\;{0} : } & \qw & \qw & \qw\\
\nghost{{q}_{0}\;\mapsto\;{1} : } & \lstick{{q}_{0}\;\mapsto\;{1} : } & \qw & \qw & \qw\\
\nghost{{q}_{1}\;\mapsto\;{2} : } & \lstick{{q}_{1}\;\mapsto\;{2} : } & \gate{\mathrm{U_2}\,(\mathrm{0,\pi})} & \qw & \qw\\
\nghost{{ancilla}_{0}\;\mapsto\;{3} : } & \lstick{{ancilla}_{0}\;\mapsto\;{3} : } & \qw & \qw & \qw\\
\nghost{{ancilla}_{1}\;\mapsto\;{4} : } & \lstick{{ancilla}_{1}\;\mapsto\;{4} : } & \qw & \qw & \qw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{H}} \barrier[0em]{1} & \qw & \qw \barrier[0em]{1} & \qw & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{H}} \barrier[0em]{0} & \qw & \gate{\mathrm{H}} & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \qw & \qw & \qw & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
\nghost{{qry} : } & \lstick{{qry} : } & \qw & \qw\\
\nghost{\mathrm{{0} : }} & \lstick{\mathrm{{0} : }} & \cw & \cw\\
\nghost{\mathrm{{1} : }} & \lstick{\mathrm{{1} : }} & \cw & \cw\\
\nghost{\mathrm{crx : }} & \lstick{\mathrm{crx : }} & \lstick{/_{_{2}}} \cw & \cw\\
\nghost{\mathrm{{crx} : }} & \lstick{\mathrm{{crx} : }} & \lstick{/_{_{2}}} \cw & \cw\\
\\ }}
\end{document}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{U}\,(\mathrm{0.3,0.2,0.1})} & \qw \barrier[0em]{2} & \qw & \ctrl{1} & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw & \qw & \qw\\
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \gate{\mathrm{H}} & \ctrl{1} & \qw & \targ & \meter & \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{{q}_{2} : } & \lstick{{q}_{2} : } & \qw & \targ & \qw & \qw & \qw & \qw & \gate{\mathrm{Z}} & \gate{\mathrm{X}} & \meter & \qw & \qw\\
\nghost{\mathrm{c : }} & \lstick{\mathrm{c : }} & \lstick{/_{_{3}}} \cw & \cw & \cw & \cw & \dstick{_{_{\hspace{0.0em}1}}} \cw \ar @{<=} [-2,0] & \dstick{_{_{\hspace{0.0em}0}}} \cw \ar @{<=} [-3,0] & \control \cw^(0.0){^{\mathtt{0x1}}} \cwx[-1] & \control \cw^(0.0){^{\mathtt{0x2}}} \cwx[-1] & \dstick{_{_{\hspace{0.0em}2}}} \cw \ar @{<=} [-1,0] & \cw & \cw\\
\nghost{\mathrm{{c} : }} & \lstick{\mathrm{{c} : }} & \lstick{/_{_{3}}} \cw & \cw & \cw & \cw & \dstick{_{_{\hspace{0.0em}1}}} \cw \ar @{<=} [-2,0] & \dstick{_{_{\hspace{0.0em}0}}} \cw \ar @{<=} [-3,0] & \control \cw^(0.0){^{\mathtt{0x1}}} \cwx[-1] & \control \cw^(0.0){^{\mathtt{0x2}}} \cwx[-1] & \dstick{_{_{\hspace{0.0em}2}}} \cw \ar @{<=} [-1,0] & \cw & \cw\\
\\ }}
\end{document}
Loading