From 0bfe597468694fd6bd73beade1cf554f6dc65006 Mon Sep 17 00:00:00 2001 From: Antonin Dudermel Date: Thu, 26 Nov 2020 20:52:10 +0100 Subject: [PATCH 1/2] add multigate with classical wire incoming legacy goes to LogicFan (https://github.com/CQuIC/qcircuit/issues/36) --- qcircuit.sty | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qcircuit.sty b/qcircuit.sty index 1b93638..483f69b 100644 --- a/qcircuit.sty +++ b/qcircuit.sty @@ -138,7 +138,9 @@ % Inserts half a swap gate. % Must be connected to the other swap with \qwx. \newcommand{\multigate}[2]{*+<1em,.9em>{\hphantom{#2}} \POS [0,0]="i",[0,0].[#1,0]="e",!C *{#2},"e"+UR;"e"+UL **\dir{-};"e"+DL **\dir{-};"e"+DR **\dir{-};"e"+UR **\dir{-},"i" \qw} - % Draws a multiple qubit gate starting at the current position and spanning #1 additional gates below. +\newcommand{\cmultigate}[2]{*+<1em,.9em>{\hphantom{#2}} \POS [0,0]="i",[0,0].[#1,0]="e",!C *{#2},"e"+UR;"e"+UL **\dir{-};"e"+DL **\dir{-};"e"+DR **\dir{-};"e"+UR **\dir{-},"i" \cw} +% Same as multigate but with a classical incoming wire +% Draws a multiple qubit gate starting at the current position and spanning #1 additional gates below. % #2 gives the label for the gate. % You must use an argument of the same width as #2 in \ghost for the wires to connect properly on the lower lines. \newcommand{\ghost}[1]{*+<1em,.9em>{\hphantom{#1}} \qw} From a0ca8d3fa90de5186fd93cd138f67762655ed05e Mon Sep 17 00:00:00 2001 From: Antonin Dudermel Date: Thu, 4 Nov 2021 19:57:30 +0100 Subject: [PATCH 2/2] add `cmultigate` to the tutorial --- Qtutorial.tex | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Qtutorial.tex b/Qtutorial.tex index 8920fb0..9cde4c7 100644 --- a/Qtutorial.tex +++ b/Qtutorial.tex @@ -361,6 +361,21 @@ \subsection{Multiple qubit gates \label{S:multigate}} & \qw & \ghost{U} & \qw & \qw }\end{verbatim}} +Finally, the command \verb=\cmultigate= creates a multigate with a classical first input (for which \verb=\cghost= is not an option). + +\[ \Qcircuit @C=1em @R=0em { +& \cw & \cmultigate{3}{U} & \cw & \cw \\ +& \qw & \ghost{U} & \qw & \qw \\ +& \cdots & \nghost{U} & \cdots & \\ +& \qw & \ghost{U} & \qw & \qw +}\] +{\small \begin{verbatim}\Qcircuit @C=1em @R=0em { +& \cw & \cmultigate{3}{U} & \cw & \cw \\ +& \qw & \ghost{U} & \qw & \qw \\ +& \cdots & \nghost{U} & \cdots & \\ +& \qw & \ghost{U} & \qw & \qw +}\end{verbatim}} + Note that controls to multiple qubit gates work the same as for single qubit gates, using \verb=\ctrl= and \verb=\qwx=. @@ -766,6 +781,7 @@ \section{Table of Commands} \char92 targ \\ \char92 qswap \\ \char92 multigate\{\#1\}\{\#2\} \\ + \char92 cmultigate\{\#1\}\{\#2\} \\ \char92 sgate\{\#1\}\{\#2\}\\ \char92 ghost\{\#1\} \\ \char92 cghost\{\#1\} \\