summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-07-24 23:07:27 +0000
committerKarl Berry <karl@freefriends.org>2014-07-24 23:07:27 +0000
commit369ffb24863654c2f800915b021b3f483dd7bca2 (patch)
treeaad854959f51f383a8afc4d55d984d23fde89e22
parenta9483c887815e8976dd5ee214736c1de4e66497d (diff)
qcircuit (24jul14)
git-svn-id: svn://tug.org/texlive/trunk@34712 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/qcircuit/Qtutorial.pdfbin0 -> 261254 bytes
-rw-r--r--Master/texmf-dist/doc/latex/qcircuit/Qtutorial.tex617
-rw-r--r--Master/texmf-dist/doc/latex/qcircuit/README49
-rw-r--r--Master/texmf-dist/tex/latex/qcircuit/qcircuit.sty144
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check3
-rw-r--r--Master/tlpkg/tlpsrc/collection-pictures.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/qcircuit.tlpsrc0
7 files changed, 813 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/qcircuit/Qtutorial.pdf b/Master/texmf-dist/doc/latex/qcircuit/Qtutorial.pdf
new file mode 100644
index 00000000000..1d236ea01f5
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/qcircuit/Qtutorial.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/qcircuit/Qtutorial.tex b/Master/texmf-dist/doc/latex/qcircuit/Qtutorial.tex
new file mode 100644
index 00000000000..446b6407f71
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/qcircuit/Qtutorial.tex
@@ -0,0 +1,617 @@
+\documentclass[twocolumn,nofootinbib]{revtex4}
+\usepackage[bookmarks = true, pdfpagemode = None, pdfstartview = FitH, colorlinks = true, urlcolor = blue]{hyperref}
+\usepackage[braket, qm]{qcircuit}
+\usepackage{amsmath}
+\usepackage{listings}
+\renewcommand{\arraystretch}{1.5}
+
+\begin{document}
+\lstset{language=TeX}
+
+\title{qcircuit 2.0 Tutorial}
+
+\author{Original Authors: Bryan Eastin, Steven T. Flammia\\Edits: Travis L Scholten}
+\affiliation{Department of Physics and Astronomy, University of New
+Mexico, Albuquerque, New Mexico 87131-0001, USA}
+
+\begin{abstract}qcircuit is a list of macros that greatly simplifies the construction of
+quantum circuit diagrams (QCDs) in \LaTeX \ with the help of the \Xy-pic
+package. This tutorial should help the reader acquire
+the skill to render arbitrary QCDs in a matter of minutes. The source code for qcircuit is available for free\footnote{The qcircuit package is distributed under the GNU public license.} at \href{https://github.com/CQuIC-GitHub/qcircuit/tree/master}{https://github.com/CQuIC-GitHub/qcircuit/tree/master}.
+\end{abstract}
+
+\maketitle
+
+\section{Introduction}
+\setcounter{footnote}{1}
+Ever tried to use \LaTeX\ to typeset something like this?
+\[
+\Qcircuit @C=.5em @R=0em @!R {
+& \ctrl{1} & \qw & & & \qw & \ctrl{1} & \qw & \ctrl{1} & \ctrl{2} & \qw\\
+& \ctrl{1} & \qw & \push{\rule{.3em}{0em}=\rule{.3em}{0em}} & & \ctrl{1} & \targ & \ctrl{1} & \targ & \qw & \qw\\
+& \gate{U} & \qw & & & \gate{V} & \qw & \gate{V^\dag} & \qw & \gate{V} & \qw
+}
+\]
+\noindent Or maybe this?
+\[
+\Qcircuit @C=.7em @R=.4em @! {
+\lstick{\ket{\psi}} & \qw & \qw & \ctrl{1} & \gate{H} & \meter & \control \cw\\
+\lstick{\ket{0}} & \qw & \targ & \targ & \qw & \meter & \cwx\\
+\lstick{\ket{0}} & \gate{H} & \ctrl{-1} & \qw & \qw & \gate{X} \cwx & \gate{Z} \cwx & \rstick{\ket{\psi}} \qw
+}
+\]
+\noindent Or how about\footnote{Code for these circuits is given in Appendix \ref{S:code}.}
+\[
+\Qcircuit @C=1.3em @R=.6em {
+ & & & & & & \mbox{Syndrome Measurement} & & & &
+ \mbox{Recovery}\\
+ & \qw & \qw & \ctrl{3} & \qw & \qw & \qw &
+ \ctrl{5} & \qw & \qw &
+ \multigate{2}{\ \mathcal{R}\ } & \qw\\
+ & \qw & \qw & \qw & \ctrl{2} & \ctrl{3} & \qw &
+ \qw & \qw & \qw & \ghost{\ \mathcal{R}\ } \qw &
+ \qw\\
+ & \qw & \qw & \qw & \qw & \qw & \ctrl{2} & \qw &
+ \ctrl{3} & \qw & \ghost{\ \mathcal{R}\ } \qw &
+ \qw\\
+ & & \lstick{\ket{0}} & \targ \qw & \targ \qw &
+ \qw & \qw & \qw & \qw & \measure{M_a} &
+ \control \cw \cwx\\
+ & & \lstick{\ket{0}} & \qw & \qw & \targ \qw &
+ \targ \qw & \qw & \qw & \measure{M_b} &
+ \control \cw \cwx\\
+ & & \lstick{\ket{0}} & \qw & \qw & \qw & \qw &
+ \targ \qw & \targ \qw & \measure{M_c}
+ \gategroup{2}{2}{7}{10}{.8em}{--} &
+ \control \cw \cwx
+}
+\]
+
+Typesetting quantum circuit diagrams using standard \LaTeX\ graphics packages is a difficult and time consuming business. qcircuit is a high level macro package designed to change that. With qcircuit, drawing quantum circuit diagrams is as easy as constructing an array. In a matter of minutes you can learn the basic syntax and start producing circuits of your own.
+
+This tutorial teaches you to use qcircuit from the ground up. Many readers will find that they've learned everything they need to know by the end of \S\ref{S:basics}, but plenty of material is included for those that wish to typeset more complicated circuits.
+
+\section{Getting Started}
+
+To install qcircuit, place the file \verb=qcircuit.sty= somewhere your \TeX\ distribution can find it and run the appropriate command to update your \TeX\ tree. To use it, place the command
+{\small \begin{verbatim}\usepackage[options]{qcircuit}\end{verbatim}}
+\noindent in the preamble of your document. \verb=qcircuit.sty= loads the \verb=amsmath= and \verb=xy= packages and implements a set of circuit commands. If need be, you can obtain the necessary packages at \href{http://www.ctan.org/}{http://www.ctan.org/}.
+
+qcircuit comes with two options - \verb=braket= and \verb=qm= - which provide defined commands for bras, kets, inner and outer products, matrix elements, and expectation values. By default, these options are not enabled, allowing you to define your own commands if you wish.
+
+\section{Special Commands}
+As mentioned above, qcircuit comes with predefined commands for some commonly used functions. We have chosen to use the \verb=ensuremath= command, meaning you do not need to put dollar signs around the calls to these commands.
+
+We demonstrate the commands below along with their respective outputs:
+
+\begin{center}
+\begin{tabular}{l c l c}
+\begin{lstlisting}
+\ket{A}
+\end{lstlisting} & \ket{A} & \begin{lstlisting}
+\bra{B}
+\end{lstlisting} & \bra{B}\\
+\begin{lstlisting}
+\ip{A}{B}
+\end{lstlisting} & \ip{A}{B} & \begin{lstlisting}
+\op{A}{B}
+\end{lstlisting} & \op{A}{B}\\
+\begin{lstlisting}
+\melem{j}{B}{k}
+\end{lstlisting} & \melem{j}{B}{k} &
+\begin{lstlisting}
+\expval{B}
+\end{lstlisting} & \expval{B}\\
+\end{tabular}
+\end{center}
+
+To enable bras and kets, call qcircuit using the \verb=braket= option. To enable quantum mechanics commands, call the option \verb=qm=.
+\section{Simple Quantum Circuits\label{S:basics}}
+
+To begin, suppose the reader would like to typeset the following
+simple circuit:
+\[ \Qcircuit @C=1em @R=.7em {
+ & \gate{X} & \qw
+}\]
+
+This was typeset using
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \gate{X} & \qw
+}\end{verbatim}}
+
+The command \verb=\Qcircuit= is simply a disguised \verb=\xymatrix= command
+with a default parameter set. For readers unfamiliar with the \verb=xymatrix= environment, it suffices
+to know that it behaves more or less like the \verb=array= environment.
+That is, new columns are denoted by \verb=&= and new rows by \verb=\\=,
+as in the following example:
+\[ \Qcircuit @C=1.4em @R=1.2em {
+ a & i \\
+ 1 & x
+} \]
+which was typeset using
+{\small \begin{verbatim}\Qcircuit @C=1.4em @R=1.2em {
+ a & i \\
+ 1 & x
+} \end{verbatim}}
+The parameters \verb?@C=1.4em? and \verb?@R=1.2em? that appear after \verb=\Qcircuit= specify the spacing between the columns and the rows of the circuit, respectively. They may take any length as an argument. Additional parameters are discussed in \S\ref{S:spaces}.
+
+\subsection{Wires and gates}
+
+The command \verb=\qw= draws a wire between two columns of
+a QCD. The command derives its name from an abbreviation of `quantum wire'.
+\[ \Qcircuit @C=1em @R=.7em {
+ & \gate{H} & \gate{Z} & \gate{H} & \qw \\
+ & \qw & \gate{X} & \qw & \qw
+} \]
+
+The diagram above was drawn using
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \gate{H} & \gate{Z} & \gate{H} & \qw \\
+ & \qw & \gate{X} & \qw & \qw
+}\end{verbatim}}
+\noindent Note that \verb=\qw= is used to connect a wire {\it towards the left}.
+
+The \verb=\gate= command draws the argument of the function inside a
+framed box and extends a wire {\it back to the previous column}. When using the
+\verb=\gate= and \verb=\qw= commands, make sure there is another column
+entry to the left of the current column entry in your QCD, otherwise the wire will not
+connect to anything (and you'll get an error), as in the following example code:
+
+{\small \begin{verbatim} (**Wrong!**)
+\Qcircuit @C=1em @R=.7em {
+ \gate{U} & \qw \\
+ \gate{U^\dag} & \qw
+} \end{verbatim}}
+
+The proper way to render this circuit would be to include space for the incoming
+wires at the beginning by inserting the \verb=&= character at the start of each new line:
+\[ \Qcircuit @C=1em @R=.7em {
+ & \gate{U} & \qw \\
+ & \gate{U^\dag} & \qw
+} \]
+
+{\small \begin{verbatim}\[ \Qcircuit @C=1em @R=.7em {
+ & \gate{U} & \qw \\
+ & \gate{U^\dag} & \qw
+} \]\end{verbatim}}
+
+The only difference between these two codes is that the correct code has an ampersand (\verb=&=) at the start of each new line.
+
+\subsection{CNOT and other controlled single qubit gates \label{S:CNOT}}
+
+With just these few commands, one can already render a circuit with an arbitrary number of wires and single qubit gates. In this section, we'll learn how to draw CNOT
+gates and controlled single qubit gates with an arbitrary number
+of controls.
+
+A simple circuit with two CNOT gates in it is
+\[ \Qcircuit @C=1em @R=.7em {
+ & \ctrl{1} & \targ & \qw \\
+ & \targ & \ctrl{-1} & \qw
+}\]
+which was typeset by
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \ctrl{1} & \targ & \qw \\
+ & \targ & \ctrl{-1} & \qw
+}\end{verbatim}}
+In this circuit, the command \verb=\targ= draws the target gate on the
+wire, and the \verb=\ctrl{#1}= puts a bullet down, and connects to the
+target which is \verb=#1= array elements \textit{below} the control.
+Hence, to connect the second CNOT gate properly, we used -1.
+
+A more complicated circuit with multiple controls and arbitrary gates
+might look like
+\[ \Qcircuit @C=1em @R=.7em {
+ & \ctrl{2} & \targ & \gate{U} & \qw \\
+ & \qw & \ctrl{-1} & \qw & \qw \\
+ & \targ & \ctrl{-1} & \ctrl{-2} & \qw \\
+ & \qw & \ctrl{-1} & \qw & \qw
+}\]
+which was drawn using
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \ctrl{2} & \targ & \gate{U} & \qw \\
+ & \qw & \ctrl{-1} & \qw & \qw \\
+ & \targ & \ctrl{-1} & \ctrl{-2} & \qw \\
+ & \qw & \ctrl{-1} & \qw & \qw
+}\end{verbatim}}
+
+In the first gate, the control bit connects to the
+target on wire 3. In the second gate, each control connects to the object
+directly above it. Finally, the third gate is an example of how to do
+controls on arbitrary gates; simply place the desired gate where you would
+normally put a target.
+
+\subsection{Vertical wires}
+
+Suppose we want to typeset the following circuit:
+\[ \Qcircuit @C=1em @R=1.2em {
+ & \gate{U_1} & \qw \\
+ & \ctrl{1} \qwx & \qw \\
+ & \gate{U_2} & \qw \\
+}\]
+so that the middle control has to connect to more than one gate. The way
+to accomplish this is with the \verb=\qwx= command. The command
+\verb=\qwx[#1]= takes an optional input, \verb=#1=, and connects from
+the current position to a position \verb=#1= entries {\it below}
+the current position. The default argument is -1. Thus, one way to
+typeset the above diagram is with the following code:
+{\small \begin{verbatim}\Qcircuit @C=1em @R=1.2em {
+ & \gate{U_1} & \qw \\
+ & \ctrl{-1} \qwx[1] & \qw \\
+ & \gate{U_2} & \qw \\
+}\end{verbatim}}
+\noindent or, equivalently,
+{\small \begin{verbatim}\Qcircuit @C=1em @R=1.2em {
+ & \gate{U_1} & \qw \\
+ & \ctrl{1} \qwx & \qw \\
+ & \gate{U_2} & \qw \\
+}\end{verbatim}}
+\noindent which is what the author used.
+
+Note that wire commands must not precede the gate command in an entry.
+Also, remember that commands taking an optional
+argument use {\it square} braces rather than curly braces.
+
+\subsection{Labelling input and output states \label{S:labels}}
+The last element we need for simple circuits is the ability to add labels. We'll look at input and output labels here, other kinds of labels are discussed in \S\ref{S:labels2}.
+
+When labelling input and output qubits, one should use the \verb=\lstick= and \verb=\rstick= commands. These commands ensure that the labels and the wires connecting to them line up correctly. The \verb=\lstick= command is used for input labels (on the left of the diagram), and the \verb=\rstick= command is used for output labels (on the right of the diagram). Placement rules are the same as those for gates with the exception that \verb=\lstick= and \verb=\rstick= can be inserted in the leftmost column of the array. Here is an example circuit:
+\[ \Qcircuit @C=1em @R=1em {
+\lstick{\ket{1}} & \targ & \rstick{\ket{0}} \qw \\
+\lstick{\ket{1}} & \ctrl{-1} & \rstick{\ket{1}} \qw
+}\]
+typeset with
+{\small \begin{verbatim}\Qcircuit @C=1em @R=1em {
+ \lstick{\ket{1}} & \targ & \rstick{\ket{0}} \qw \\
+ \lstick{\ket{1}} & \ctrl{-1} & \rstick{\ket{1}} \qw
+}\end{verbatim}}
+
+
+\section{More Complicated Circuits: Multiple Qubit Gates and Beyond}
+
+So far, we have seen how to make arbitrary QCDs involving single qubit gates and controlled gates, including CNOT. Since this is known to be universal for computation, we could just stop here! Of course, many circuit diagrams use more complicated structures such as multi-qubit gates, measurements, classical wires, and swaps. We will learn how to use Q-circuit to make all of these in this section.
+
+\subsection{Multiple qubit gates \label{S:multigate}}
+
+Let's look at an example, and then we'll explain the code.
+\[ \Qcircuit @C=1em @R=.7em {
+ & \multigate{2}{U^\dag} & \qw \\
+ & \ghost{U^\dag}& \qw \\
+ & \ghost{U^\dag} & \qw
+}\]
+The 3-qubit gate above was typeset with
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \multigate{2}{U^\dag} & \qw \\
+ & \ghost{U^\dag}& \qw \\
+ & \ghost{U^\dag} & \qw
+}\end{verbatim}}
+First let's go over the \verb=\multigate= command.
+\verb=\multigate{#1}{#2}= is a two argument gate that takes the
+\textit{depth} of the
+gate for the first argument and the \textit{label} of the gate for the
+second argument. In the above example, \verb=#1= equals 2 because the 3-qubit gate
+extends two rows below the position of \verb=\multigate=. On the other two lines,
+the \verb=\ghost= command is used to get the spacing and connections right. \verb=\ghost= behaves like an invisible gate that allows the quantum wires on either side of your multigate to connect correctly.
+
+The generalization to an arbitrarily large gate is now obvious. Let's look at a 6-qubit gate. The code
+{\small \begin{verbatim}\Qcircuit @C=1em @R=0em {
+ & \multigate{5}{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw
+}\end{verbatim}}
+\noindent yields
+\[ \Qcircuit @C=1em @R=0em {
+ & \multigate{5}{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw \\
+ & \ghost{\mathcal{F}} & \qw
+}\]
+Thus, for every entry below the top, a \verb=\ghost= command
+with the label for the gate is needed. Strictly speaking, the name of the gate is not necessary inside the \verb=\ghost= command. Since \verb=\ghost= is just an invisible place holder, anything with the same width as the label specified in multigate will work as well. In practice, however, it is usually easiest to use the same argument.
+
+Note that controls to multiple qubit gates work the same as for single
+qubit gates, using \verb=\ctrl= and \verb=\qwx=.
+
+\subsection{Measurements and classical bits}
+
+Measurement gates are typeset just like ordinary gates, but they typically have some sort of decoration to indicate that measurement has occurred. At present, Q-circuit supports the following single qubit measurement gates.
+{\small \begin{center}
+ \begin{tabular}{l | l | l}
+ \multicolumn{1}{c}{\itshape Example} & \multicolumn{1}{c}{\itshape Command} & \multicolumn{1}{c}{\itshape Example Code }\\ \hline
+ \Qcircuit @C=1em @R=.7em {& \meter}
+ & \verb=\meter= & \verb=\meter=\\
+ \Qcircuit @C=1em @R=.7em {& \measure{\mbox{Basis}}}
+ & \verb=\measure = & \verb=\measure{\mbox{Basis}}=\\
+ \Qcircuit @C=1em @R=.7em {& \measuretab{M_{ijk}}} \hspace{.5em}
+ & \verb=\measuretab= & \verb=\measuretab{M_{ijk}}=\\
+ \Qcircuit @C=1em @R=.7em {& \measureD{\chi}}
+ & \verb=\measureD= & \verb=\measureD{\chi}=
+ \end{tabular}
+\end{center}}
+
+Often we want to condition some gate on the output of a measurement. One convenient way illustrate this is with the classical wire commands, \verb=\cw= and \verb=\cwx=. The classical wire commands work exactly like the quantum wire commands, but they draw double instead of single lines.
+
+Here is an example using measurement gates and classical wires and the corresponding code.
+\[\Qcircuit @C=1em @R=.7em {
+ & \qw & \measure{\mbox{Codebit}} \cwx[1] \\
+ & \qw & \gate{\chi} & \meter & \rstick{\cdots} \cw
+}\]
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \qw & \measure{\mbox{Codebit}} \cwx[1] \\
+ & \qw & \gate{\chi} & \meter &
+ \rstick{\cdots} \cw
+}\end{verbatim}}
+
+Q-circuit also includes the commands \verb=\multimeasure= and \verb=\multimeasureD= for typesetting measurements on multiple qubits. The syntax for these commands exactly parallels that of the \verb=\multigate= command (see \S\ref{S:multigate}). An example is shown below.
+\[\Qcircuit @C=1em @R=.7em {
+ & \multimeasureD{1}{\text{Bell}} \\
+ & \ghost{\text{Bell}}
+}\]
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \multimeasureD{1}{\text{Bell}} \\
+ & \ghost{\text{Bell}}
+}\end{verbatim}}
+
+\subsection{Non-gate inserts, forcing space, and swap \label{S:inserts}}
+
+In addition to the gates defined by Q-circuit, standard \LaTeX\ can function as a gate if enclosed in curly brackets. By default, inputs are assumed to have zero size, so no space will be made for the resulting object and any wires connecting to it will run straight to the object's middle. Standard \LaTeX\ entries can serve as labels or wire decorations.
+
+To force an object to take up space, you should use the \verb=\push= command. \verb=\push= is most useful in conjunction with the \LaTeX\ command \verb=\rule=. Together they can be used to construct various sorts of invisible props and struts.
+
+Q-circuit implements a gate command called \verb=\qswap= that is equivalent to the text \verb={\times} \qw=. The effect of \verb=\qswap= is to insert half of a swap gate (that is a $\times$) which can then be connected (using \verb=\qwx=) to another instance of \verb=\qswap= to create a swap gate.
+
+Here is a circuit that shows how to construct swap, decorate wires, and use \verb=\push= to make an invisible prop.
+\[\Qcircuit @C=1em @R=.3em {
+ & & \mbox{Defective Circuit}\\
+ & \qswap & \qw & \push{\rule{0em}{1em}} \qw \\
+ & \qswap \qwx & \push{X} \qw & \qw \\
+ & {/} \qw & \gate{H^{\otimes n}} & \qw
+}\]
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.3em {
+ & & \mbox{Defective Circuit}\\
+ & \qswap & \qw & \push{\rule{0em}{1em}} \qw \\
+ & \qswap \qwx & \push{X} \qw & \qw \\
+ & {/} \qw & \gate{H^{\otimes n}} & \qw
+}\end{verbatim}}
+
+\subsection{How to control anything}
+
+Controlled-Z gates, wires with bends, and gates that control-on-zero can all be made using the extended family of control commands. The complete family of control commands is \verb=\ctrl=, \verb=\crtlo=, \verb=\control=, and \verb=\controlo=.
+
+\verb=\ctrlo= is identical to the \verb=\ctrl= command (see \S\ref{S:CNOT}) except that it draws an open bullet (indicating control-on-zero). Both commands place a wire to the left and take one argument indicating which wire to connect to.
+
+The commands \verb=\control= and \verb=\controlo= are isolated controls; they don't automatically connect to anything. Isolated controls allow you to decide exactly what connections are made to your control operator, which makes them very useful for working with classical wires and rendering things like the controlled-Z.
+
+Here is an example circuit using various controls.
+\[ \Qcircuit @C=1em @R=.7em {
+ & \ctrl{2} & \ctrlo{1} & \ctrl{1} & \qw & \multigate{1}{U} & \qw \\
+ & \qw & \targ & \ctrlo{2} \qw & \ctrl{1} & \ghost{U} & \qw\\
+ & \control \qw & \ctrl{1} & \qw & \meter & \controlo \cw \cwx &\\
+ & \qw & \control \qw & \gate{H} & \meter & \control \cw \cwx
+}\]
+
+{\small \begin{verbatim}\Qcircuit @C=1em @R=.7em {
+ & \ctrl{2} & \ctrlo{1} & \ctrl{1}
+ & \qw & \multigate{1}{U} & \qw \\
+ & \qw & \targ & \ctrlo{2} \qw
+ & \ctrl{1} & \ghost{U} & \qw \\
+ & \control \qw & \ctrl{1} & \qw
+ & \meter & \controlo \cw \cwx \\
+ & \qw & \control \qw & \gate{H}
+ & \meter & \control \cw \cwx
+}\end{verbatim}}
+
+Note that we, the authors, have used a pair of controls connected by a wire to denote the controlled-Z gate. This isn't standard notation, but we feel it is a logically consistent and concise notation, and it illustrates nicely the symmetry of the controlled-Z gate. We hope to encourage the readers to adopt this notation in their own QCDs.
+
+\section{Bells and Whistles: Tweaking Your Diagram to Perfection}
+
+By now, the reader should be able to quickly and easily typeset almost any QCD. Nonetheless, it may occasionally be desirable to decorate or modify a circuit in ways not yet discussed. This section presents additional tricks, options, and commands for putting the final polish on your QCDs.
+
+\subsection{Spacing\label{S:spaces}}
+
+The Q-circuit parameters \verb+@R+ and \verb+@C+ were introduced in \S\ref{S:basics}; they are examples of a family of spacing parameters that can appear between the text \verb=\Qcircuit= and the opening curly brace. A more complete list of available parameters is given in the table below.
+
+{\small \begin{center}
+ \begin{tabular}{l | l }
+ \multicolumn{1}{c}{\itshape Parameter} & \multicolumn{1}{c}{\itshape Effect }\\ \hline
+ \verb+@R=#1+ & Sets the spacing between rows to \verb=#1=.\\
+ \verb+@C=#1+ & Sets the spacing between columns to \verb=#1=.\\
+ \verb+@!R+ & \parbox[t]{6cm}{Sets all rows to the height of the tallest object in the circuit.}\\
+ \verb+@!C+ & \parbox[t]{6cm}{Sets all columns to the width of the widest object in the circuit.}\\
+ \verb+@!+ & \parbox[t]{6cm}{Sets all entries to the size of the largest object in the circuit.}
+ \end{tabular}
+\end{center}}
+
+The \verb=@R= and \verb=@C= parameters adjust the separation between elements, allowing you to dictate the compactness of your QCD. \verb=@!R=, \verb=@!C=, and \verb=@!= force the elements of your circuit to have uniform sizes, this helps to prevent bunching that may occur when a particular row or column contains many small elements. \verb=@!R= is particularly useful for forcing wires to be evenly spaced, as in the following example.
+\[ \Qcircuit @C=.7em @R=.3em @!R {
+ & \qswap & \qw & \qswap & \qw\\
+ & \qswap \qwx & \ctrl{1} & \qswap \qwx & \qw \\
+ & \qw & \gate{T^\dag} & \qw & \qw
+}\]
+
+{\small \begin{verbatim}\Qcircuit @C=.7em @R=.3em @!R {
+ & \qswap & \qw & \qswap & \qw\\
+ & \qswap \qwx & \ctrl{1} & \qswap \qwx & \qw \\
+ & \qw & \gate{T^\dag} & \qw & \qw
+}\end{verbatim}}
+
+\subsection{Labelling \label{S:labels2}}
+
+A label can be placed anywhere that a gate command might normally appear. Unlike gates, however, Q-circuit treats labels as having zero size when determining the layout of a QCD. This prevents large labels from bending your circuit out of whack, but it also means that labels can overlap with other components.
+
+Normally an element whose size is set to zero is drawn centered on it's entry. This is what happens when you insert text directly using curly brackets (see \S\ref{S:inserts}). For most labelling, however, it is more useful to have one edge of the label fixed in the center of an entry. For this reason Q-circuit provides a set of label commands, \verb=\lstick=, \verb=\rstick=, \verb=\ustick=, and \verb=\dstick=. The stick commands each cause their contents to ``stick out" from the center of an entry in a different direction. \verb=\lstick=, \verb=\rstick=, \verb=\ustick=, and \verb=\dstick= produce labels that project out to the left, right, top, and bottom respectively.
+
+Proper usage of \verb=\lstick= and \verb=\rstick= was demonstrated in \S\ref{S:labels}, so the following example focuses on \verb=\ustick= and \verb=\dstick=.
+\[ \Qcircuit @C=.7em @R=.3em {
+ & \ustick{a} \qw & \qw & \qw & \qw & \meter \\
+ & \ustick{b} \qw & \qw & \qw & \meter \\
+ & & & & \dstick{B} \cwx & \dstick{A} \cwx[-2]
+}\]
+\\
+{\small \begin{verbatim}\Qcircuit @C=.7em @R=.3em {
+ & \ustick{a} \qw & \qw & \qw & \qw & \meter \\
+ & \ustick{b} \qw & \qw & \qw & \meter \\
+ & & & & \dstick{B} \cwx & \dstick{A} \cwx[-2]
+}\end{verbatim}}
+
+\subsection{Grouping}
+
+It is sometimes useful to box off sections of a circuit to indicate a subcircuit, as in the following example.
+\[ \Qcircuit @C=1em @R=1em {
+ & \ctrl{2} & \qw & \gate{H} & \ctrl{1} & \gate{H} & \qw \\
+ & \qw & \ctrl{1} & \gate{H} & \targ & \gate{H} & \qw \\
+ & \targ & \targ & \gate{Z} & \qw & \ctrl{-1} & \qw \gategroup{1}{4}{2}{6}{.7em}{--}
+}\]
+which was typeset using
+{\small \begin{verbatim}\Qcircuit @C=1em @R=1em {
+ & \ctrl{2} & \qw & \gate{H} & \ctrl{1} &
+ \gate{H} & \qw \\
+ & \qw & \ctrl{1} & \gate{H} & \targ &
+ \gate{H} & \qw \\
+ & \targ & \targ & \gate{Z} & \qw & \ctrl{-1} &
+ \qw \gategroup{1}{4}{2}{6}{.7em}{--}
+}\end{verbatim}}
+The command that made the dashed box is in the last line of code and is called \verb=\gategroup=. The \verb=\gategroup= command can be placed following any non-empty entry, but, for clarity, it is perhaps best to put it at the end.
+
+Because it takes six arguments, \verb=\gategroup= looks intimidating, but it is actually relatively easy to use. \verb=\gategroup{#1}{#2}{#3}{#4}{#5}{#6}= highlights the entries between rows \verb=#1= and \verb=#3= and columns \verb=#2= and \verb=#4= by adding a box or a bracket. Argument \verb=#6= selects between various highlights, with the available options being:
+\begin{center} {\small \verb=-- . _\} ^\} \{ \} _) ^) ( )=} \end{center}
+These options produce a dashed box, a dotted box, a curly brace on the bottom, top, left, or right, and a normal brace on the bottom, top, left, or right. Argument \verb=#5= is twice the spacing from the nearest gate to the box.
+
+\verb=\gategroup= only checks that the gates at the four corners of the requested region are properly enclosed. As a result, gates along the boundary that are bigger than the corner gates will tend to stick out. This is especially unsightly when the corner entries are wires, though in that case the problem can be fixed by inserting an invisible prop of the desired height (see \S\ref{S:inserts}).
+
+\section{Acknowledgments}
+
+The authors would like to thank Aaron Smith, Joe Renes, and Andrew Silberfarb for useful discussions, ideas, and debugging. Thanks to Carl Caves and Michael Nielsen for encouragement on this project. An extra thanks to Michael Nielsen for suggesting some useful \LaTeX \ resources.
+
+The development of Q-circuit was supported in part by the National Security Agency (NSA) and the Advanced Research and Developement Activity (ARDA) under the Army Research Office (ARO) contract numbers DAAD19-01-1-0648 and W911NF-04-1-0242.
+
+\appendix
+\section{Positioning Q-circuit diagrams in \LaTeX}
+Q-circuit produces \TeX\ graphics objects. In theory these objects should act like any symbol or character. Thus, they can be placed in equation environments, arrays, and figures. In practice there are a few, largely unexplained, complications.
+
+One of these is vertical centering in a line of text. To center the top line of a circuit, it is sufficient to invoke it in inline math mode using \verb=$=. To center the entire circuit, place it inside an array.
+
+Horizontal centering within figures is also problematic. Typically this can be corrected by placing the \verb=\Qcircuit= command inside a \verb=\centerline= command, an \verb=\mbox= command, or an equation environment. For some \LaTeX\ distributions the commands \verb=\leavevmode= and \verb=\centering= must be added to center a figure.
+
+Finally, circuits using large labels often appear a bit off center. This is because labels are not included when calculating the size of a circuit. The best solution is probably to add white space (see \S\ref{S:inserts}) until the labels all fit within the boundaries of the circuit.
+
+\section{Bugs and Future Work}
+
+\begin{enumerate}
+\item Wires often end just short of curved surfaces.
+\item \verb=\gategroup= needs to check all the boundary gates when determining the highlighted area.
+\item Targets look poor when the font size is set to small.
+\item It would be nice if the \verb=\ghost= command could read the argument of the \verb=\multigate= command automatically.
+\item Larger issues of centering within \LaTeX\ need to be addressed.
+\end{enumerate}
+
+\section{Code for the Introduction\label{S:code}}
+The first QCD depicts a way of decomposing doubly controlled unitaries.
+It was typeset with
+{\small \begin{verbatim}\Qcircuit @C=.5em @R=0em @!R {
+ & \ctrl{1} & \qw & & & \qw & \ctrl{1} & \qw &
+ \ctrl{1} & \ctrl{2} & \qw\\
+ & \ctrl{1} & \qw &
+ \push{\rule{.3em}{0em}=\rule{.3em}{0em}} & &
+ \ctrl{1} & \targ & \ctrl{1} & \targ & \qw &
+ \qw\\
+ & \gate{U} & \qw & & & \gate{V} & \qw &
+ \gate{V^\dag} & \qw & \gate{V} & \qw
+}
+\end{verbatim}}
+
+The second QCD depicts quantum teleportation and was typeset with
+{\small \begin{verbatim}\Qcircuit @C=.7em @R=.4em @! {
+ \lstick{\ket{\psi}} & \qw & \qw & \ctrl{1} &
+ \gate{H} & \meter & \control \cw\\
+ \lstick{\ket{0}} & \qw & \targ & \targ & \qw &
+ \meter & \cwx\\
+ \lstick{\ket{0}} & \gate{H} & \ctrl{-1} & \qw &
+ \qw & \gate{X} \cwx & \gate{Z} \cwx &
+ \rstick{\ket{\psi}} \qw
+}
+\end{verbatim}}
+
+The third QCD depicts quantum error correction on the bit flip code. It was typeset with
+{\small \begin{verbatim}\Qcircuit @C=1.3em @R=.6em {
+ & & & & & & \mbox{Syndrome Measurement} & & & &
+ \mbox{Recovery}\\
+ & \qw & \qw & \ctrl{3} & \qw & \qw & \qw &
+ \ctrl{5} & \qw & \qw &
+ \multigate{2}{\ \mathcal{R}\ } & \qw\\
+ & \qw & \qw & \qw & \ctrl{2} & \ctrl{3} & \qw &
+ \qw & \qw & \qw & \ghost{\ \mathcal{R}\ } \qw &
+ \qw\\
+ & \qw & \qw & \qw & \qw & \qw & \ctrl{2} & \qw &
+ \ctrl{3} & \qw & \ghost{\ \mathcal{R}\ } \qw &
+ \qw\\
+ & & \lstick{\ket{0}} & \targ \qw & \targ \qw &
+ \qw & \qw & \qw & \qw & \measure{M_a} &
+ \control \cw \cwx\\
+ & & \lstick{\ket{0}} & \qw & \qw & \targ \qw &
+ \targ \qw & \qw & \qw & \measure{M_b} &
+ \control \cw \cwx\\
+ & & \lstick{\ket{0}} & \qw & \qw & \qw & \qw &
+ \targ \qw & \targ \qw & \measure{M_c}
+ \gategroup{2}{2}{7}{10}{.8em}{--} &
+ \control \cw \cwx
+}
+\end{verbatim}}
+
+\pagebreak
+
+\section{Table of Commands}
+
+The following table is grouped according to the effect of each command.\\
+
+{\small \begin{center}
+ \begin{tabular}{l | l }
+ \multicolumn{1}{c}{\itshape Subject} & \multicolumn{1}{c}{\itshape Command }\\ \hline
+ Loading Q-circuit \hspace{.5em} & \verb=\input{Qcircuit}= \\
+ Making Circuits & \verb=\Qcircuit= \\
+ Spacing & \parbox[t]{6cm}{\tt
+ @C=\#1 \\
+ @R=\#1 \\
+ @!R \\
+ @!C \\
+ @! \\
+ \char92 push\{\#1\}} \\
+ Wires & \parbox[t]{6cm}{\tt
+ \char92 qw[\#1] \\
+ \char92 qwx[\#1] \\
+ \char92 cw[\#1] \\
+ \char92 cwx[\#1] }\\
+ Gates & \parbox[t]{6cm}{\tt
+ \char92 gate\{\#1\} \\
+ \char92 targ \\
+ \char92 qswap \\
+ \char92 multigate\{\#1\}\{\#2\} \\
+ \char92 ghost\{\#1\} }\\
+ Controls & \parbox[t]{6cm}{\tt
+ \char92 ctrl\{\#1\} \\
+ \char92 ctrlo\{\#1\} \\
+ \char92 control \\
+ \char92 controlo } \\
+ Measurements & \parbox[t]{6cm}{\tt
+ \char92 meter \\
+ \char92 measure\{\#1\} \\
+ \char92 measureD\{\#1\} \\
+ \char92 measuretab\{\#1\} \\
+ \char92 multimeasure\{\#1\}\{\#2\} \\
+ \char92 multimeasureD\{\#1\}\{\#2\} } \\
+ Labels & \parbox[t]{6cm}{\tt
+ \char92 lstick\{\#1\} \\
+ \char92 rstick\{\#1\} \\
+ \char92 ustick\{\#1\} \\
+ \char92 dstick\{\#1\} \\
+ \char92 bra\{\#1\} \\
+ \char92 ket\{\#1\} \\
+ \char92 gategroup\{\#1\}\{\#2\}\{\#3\}\{\#4\}\{\#5\}\{\#6\} }
+ \end{tabular}
+\end{center}}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/qcircuit/README b/Master/texmf-dist/doc/latex/qcircuit/README
new file mode 100644
index 00000000000..7d18a25f94d
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/qcircuit/README
@@ -0,0 +1,49 @@
+qcircuit 2.0
+============
+qcircuit is a list of macros that greatly simplifies the construction of quantum circuit diagrams (QCDs) in LaTeX with the help of the Xy-pic package.
+
+The original website for this project may be found at http://physics.unm.edu/CQuIC/Qcircuit/ through the Center for Quantum Information and Control.
+A newer page is available through https://github.com/CQuIC-GitHub/qcircuit/tree/master.
+
+Installation
+========
+**Dependencies**
+
+qcircuit depends on the xy-pic (http://www.tug.org/applications/Xy-pic/) and ifpdf (http://www.ctan.org/pkg/ifpdf) packages.
+
+**Simple Install**
+
+The simplest way to use qcircuit is to download the file qcircuit.sty and put that file in the same folder as the tex document you are compiling. Within the document preamble, use \usepackage[options]{qcircuit} to enable TeX to compile the circuit. See the Use section of this README file for more information.
+
+**More Complicated (but more helpful) Way**
+
+A slightly more complicated way involves putting qcircuit in your TeX tree so that every time you compile your file TeX sees the qcircuit.sty file. This avoids the hassle of copying the file all over the place.
+
+To do so, first locate the tex/latex subdirectory of your TeX tree. For Mac OS X users, this is located at users/user_name/Library/texmf/tex/latex/Qcircuit, where user_name is the user name you use for your login. For Windows users, this folder is located at C:\Program Files\texmf\tex\latex\Qcircuit. To update the tree, run initexmf --update-fndb from your command line.
+
+For Linux users, one needs to locate the root TeX directory. Use the command locate:texmf to find all directories with a texmf folder. Then, after finding an appropriate folder into which qcircuit.sty can be put, execute the texhash command to update the tree.
+
+Use
+======
+Upon successful installation, one simply calls \usepackage[options]{qcircuit} to enable circuit-drawing functionality. Currently, we have support for two options:
+
+* `braket`: This option provides the standard Dirac bras `\bra{A}` and kets `\ket{A}`
+* `qm`: This options provides an inner product `\ip{A}{B}`, an outer product `\op{A}{B}`, a matrix element `{j}{M}{k}`, and an expectation value `\expval{M}`.
+
+By default, none of these options are enabled, meaning if you want access to these commands, you must explicity provide them in your package call. This way, we avoid clashes with user-defined commands.
+
+Tutorial
+=========
+A simple way to check you successfully installed qcircuit is to download the Qtutorial.tex file and run it in your favorite TeX compiler. Should the document compile correctly, you are ready to use qcircuit in your own documents! (Note: By default, we enabled our predefined commands within the document preamble for this file.) By inspecting the figures produced and comparing with the source code, you should obtain an understanding of how to typset your own circuits.
+
+Help
+=======
+
+As the installation instructions indicate, qcircuit must be manually inserted into a users' TeX tree. This presents complications insofar as trees may vary in structure and location across different operating systems. We will be working on making qcircuit a LaTeX package hosted on CTAN such that one simply downloads the package with their favorite package manager, and calls `\usepackage[options]{qcircuit}` to enable functionality. In the meantime, one is simply forced to hack one's way into having this functionality.
+
+A general FAQ can be found at http://physics.unm.edu/CQuIC/Qcircuit/QcircuitFAQ.html.
+
+License
+========
+This software is licensed under a GPLv2 license, available at https://www.gnu.org/licenses/gpl-2.0.html. See the corresponding documentation for a description your rights and obligations.
+
diff --git a/Master/texmf-dist/tex/latex/qcircuit/qcircuit.sty b/Master/texmf-dist/tex/latex/qcircuit/qcircuit.sty
new file mode 100644
index 00000000000..bf946def860
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/qcircuit/qcircuit.sty
@@ -0,0 +1,144 @@
+% Q-circuit version 2.0
+% Contributors: Steve Flammia, Bryan Eastin, Travis Scholten
+% This program is free software; you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation; either version 2 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software
+% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+% Thanks to the Xy-pic guys, Kristoffer H Rose, Ross Moore, and Daniel Müllner,
+% for their help in making Qcircuit work with Xy-pic version 3.8.
+% Thanks also to Dave Clader, Andrew Childs, Rafael Possignolo, Tyson Williams,
+% Sergio Boixo, Cris Moore, Jonas Anderson, and Stephan Mertens for helping us test
+% and/or develop the new version.
+\ProvidesPackage{qcircuit}[2014/06/29]
+\RequirePackage{xy}
+
+\DeclareOption{braket}{
+ \newcommand{\bra}[1]{\ensuremath{\left\langle{#1}\right\vert}}
+ \newcommand{\ket}[1]{\ensuremath{\left\vert{#1}\right\rangle}}
+}
+
+\DeclareOption{qm}{
+ \newcommand{\ip}[2]{\ensuremath{\left\langle{#1}\right\vert{#2}\rangle}}
+ \newcommand{\melem}[3]{\ensuremath{\left\langle{#1}\right\vert{#2}\vert{#3}\rangle}}
+ \newcommand{\expval}[1]{\ensuremath{\left\langle #1 \right\rangle}}
+ \newcommand{\op}[2]{\ensuremath{\vert{#1}\rangle\langle{#2}\vert}}
+}
+
+\ProcessOptions\relax
+
+\xyoption{matrix}
+\xyoption{frame}
+\xyoption{arrow}
+\xyoption{arc}
+
+\usepackage{ifpdf}
+\ifpdf
+\else
+\PackageWarningNoLine{Qcircuit}{qcircuit is loading in Postscript mode. The Xy-pic options ps and dvips will be loaded. If you wish to use other Postscript drivers for Xy-pic, you must modify the code in qcircuit.sty}
+% The following options load the drivers most commonly required to
+% get proper Postscript output from Xy-pic. Should these fail to work,
+% try replacing the following two lines with some of the other options
+% given in the Xy-pic reference manual.
+\xyoption{ps}
+\xyoption{dvips}
+\fi
+
+% The following resets Xy-pic matrix alignment to the pre-3.8 default, as
+% required by Qcircuit.
+\entrymodifiers={!C\entrybox}
+
+\newcommand{\qw}[1][-1]{\ar @{-} [0,#1]}
+ % Defines a wire that connects horizontally. By default it connects to the object on the left of the current object.
+ % WARNING: Wire commands must appear after the gate in any given entry.
+\newcommand{\qwx}[1][-1]{\ar @{-} [#1,0]}
+ % Defines a wire that connects vertically. By default it connects to the object above the current object.
+ % WARNING: Wire commands must appear after the gate in any given entry.
+\newcommand{\cw}[1][-1]{\ar @{=} [0,#1]}
+ % Defines a classical wire that connects horizontally. By default it connects to the object on the left of the current object.
+ % WARNING: Wire commands must appear after the gate in any given entry.
+\newcommand{\cwx}[1][-1]{\ar @{=} [#1,0]}
+ % Defines a classical wire that connects vertically. By default it connects to the object above the current object.
+ % WARNING: Wire commands must appear after the gate in any given entry.
+\newcommand{\gate}[1]{*+<.6em>{#1} \POS ="i","i"+UR;"i"+UL **\dir{-};"i"+DL **\dir{-};"i"+DR **\dir{-};"i"+UR **\dir{-},"i" \qw}
+ % Boxes the argument, making a gate.
+\newcommand{\meter}{*=<1.8em,1.4em>{\xy ="j","j"-<.778em,.322em>;{"j"+<.778em,-.322em> \ellipse ur,_{}},"j"-<0em,.4em>;p+<.5em,.9em> **\dir{-},"j"+<2.2em,2.2em>*{},"j"-<2.2em,2.2em>*{} \endxy} \POS ="i","i"+UR;"i"+UL **\dir{-};"i"+DL **\dir{-};"i"+DR **\dir{-};"i"+UR **\dir{-},"i" \qw}
+ % Inserts a measurement meter.
+ % In case you're wondering, the constants .778em and .322em specify
+ % one quarter of a circle with radius 1.1em.
+ % The points added at + and - <2.2em,2.2em> are there to strech the
+ % canvas, ensuring that the size is unaffected by erratic spacing issues
+ % with the arc.
+\newcommand{\measure}[1]{*+[F-:<.9em>]{#1} \qw}
+ % Inserts a measurement bubble with user defined text.
+\newcommand{\measuretab}[1]{*{\xy*+<.6em>{#1}="e";"e"+UL;"e"+UR **\dir{-};"e"+DR **\dir{-};"e"+DL **\dir{-};"e"+LC-<.5em,0em> **\dir{-};"e"+UL **\dir{-} \endxy} \qw}
+ % Inserts a measurement tab with user defined text.
+\newcommand{\measureD}[1]{*{\xy*+=<0em,.1em>{#1}="e";"e"+UR+<0em,.25em>;"e"+UL+<-.5em,.25em> **\dir{-};"e"+DL+<-.5em,-.25em> **\dir{-};"e"+DR+<0em,-.25em> **\dir{-};{"e"+UR+<0em,.25em>\ellipse^{}};"e"+C:,+(0,1)*{} \endxy} \qw}
+ % Inserts a D-shaped measurement gate with user defined text.
+\newcommand{\multimeasure}[2]{*+<1em,.9em>{\hphantom{#2}} \qw \POS[0,0].[#1,0];p !C *{#2},p \drop\frm<.9em>{-}}
+ % Draws a multiple qubit measurement bubble 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{\multimeasureD}[2]{*+<1em,.9em>{\hphantom{#2}} \POS [0,0]="i",[0,0].[#1,0]="e",!C *{#2},"e"+UR-<.8em,0em>;"e"+UL **\dir{-};"e"+DL **\dir{-};"e"+DR+<-.8em,0em> **\dir{-};{"e"+DR+<0em,.8em>\ellipse^{}};"e"+UR+<0em,-.8em> **\dir{-};{"e"+UR-<.8em,0em>\ellipse^{}},"i" \qw}
+ % Draws a multiple qubit D-shaped measurement 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{\control}{*!<0em,.025em>-=-<.2em>{\bullet}}
+ % Inserts an unconnected control.
+\newcommand{\controlo}{*+<.01em>{\xy -<.095em>*\xycircle<.19em>{} \endxy}}
+ % Inserts a unconnected control-on-0.
+\newcommand{\ctrl}[1]{\control \qwx[#1] \qw}
+ % Inserts a control and connects it to the object #1 wires below.
+\newcommand{\ctrlo}[1]{\controlo \qwx[#1] \qw}
+ % Inserts a control-on-0 and connects it to the object #1 wires below.
+\newcommand{\targ}{*+<.02em,.02em>{\xy ="i","i"-<.39em,0em>;"i"+<.39em,0em> **\dir{-}, "i"-<0em,.39em>;"i"+<0em,.39em> **\dir{-},"i"*\xycircle<.4em>{} \endxy} \qw}
+ % Inserts a CNOT target.
+\newcommand{\qswap}{*=<0em>{\times} \qw}
+ % 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.
+ % #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}
+ % Leaves space for \multigate on wires other than the one on which \multigate appears. Without this command wires will cross your gate.
+ % #1 should match the second argument in the corresponding \multigate.
+\newcommand{\push}[1]{*{#1}}
+ % Inserts #1, overriding the default that causes entries to have zero size. This command takes the place of a gate.
+ % Like a gate, it must precede any wire commands.
+ % \push is useful for forcing columns apart.
+ % NOTE: It might be useful to know that a gate is about 1.3 times the height of its contents. I.e. \gate{M} is 1.3em tall.
+ % WARNING: \push must appear before any wire commands and may not appear in an entry with a gate or label.
+\newcommand{\gategroup}[6]{\POS"#1,#2"."#3,#2"."#1,#4"."#3,#4"!C*+<#5>\frm{#6}}
+ % Constructs a box or bracket enclosing the square block spanning rows #1-#3 and columns=#2-#4.
+ % The block is given a margin #5/2, so #5 should be a valid length.
+ % #6 can take the following arguments -- or . or _\} or ^\} or \{ or \} or _) or ^) or ( or ) where the first two options yield dashed and
+ % dotted boxes respectively, and the last eight options yield bottom, top, left, and right braces of the curly or normal variety. See the Xy-pic reference manual for more options.
+ % \gategroup can appear at the end of any gate entry, but it's good form to pick either the last entry or one of the corner gates.
+ % BUG: \gategroup uses the four corner gates to determine the size of the bounding box. Other gates may stick out of that box. See \prop.
+
+\newcommand{\rstick}[1]{*!L!<-.5em,0em>=<0em>{#1}}
+ % Centers the left side of #1 in the cell. Intended for lining up wire labels. Note that non-gates have default size zero.
+\newcommand{\lstick}[1]{*!R!<.5em,0em>=<0em>{#1}}
+ % Centers the right side of #1 in the cell. Intended for lining up wire labels. Note that non-gates have default size zero.
+\newcommand{\ustick}[1]{*!D!<0em,-.5em>=<0em>{#1}}
+ % Centers the bottom of #1 in the cell. Intended for lining up wire labels. Note that non-gates have default size zero.
+\newcommand{\dstick}[1]{*!U!<0em,.5em>=<0em>{#1}}
+ % Centers the top of #1 in the cell. Intended for lining up wire labels. Note that non-gates have default size zero.
+\newcommand{\Qcircuit}{\xymatrix @*=<0em>}
+ % Defines \Qcircuit as an \xymatrix with entries of default size 0em.
+\newcommand{\link}[2]{\ar @{-} [#1,#2]}
+ % Draws a wire or connecting line to the element #1 rows down and #2 columns forward.
+\newcommand{\pureghost}[1]{*+<1em,.9em>{\hphantom{#1}}}
+ % Same as \ghost except it omits the wire leading to the left.
+
+\endinput
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 144f8bce61c..fedfe34b05c 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -413,7 +413,8 @@ my @TLP_working = qw(
psu-thesis ptex2pdf ptext ptptex punk punk-latex punknova purifyeps pxbase
pxchfon pxcjkcat pxfonts pxgreeks pxjahyper
pxpgfmark pxrubrica pxtxalfa python pythontex
- quattrocento qcm qobitree quoting qstest qsymbols qtree quotchap quotmark
+ quattrocento qcircuit qcm
+ qobitree qstest qsymbols qtree quotchap quoting quotmark
r_und_s raleway ran_toks randbild randomwalk randtext
rccol rcs rcs-multi rcsinfo
readarray realboxes realscripts rec-thy recipe recipecard recycle rectopma
diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
index def1b30395e..9d0893794d1 100644
--- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
@@ -83,6 +83,7 @@ depend pmgraph
depend prerex
depend productbox
depend pxpgfmark
+depend qcircuit
depend randbild
depend randomwalk
depend reotex
diff --git a/Master/tlpkg/tlpsrc/qcircuit.tlpsrc b/Master/tlpkg/tlpsrc/qcircuit.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/qcircuit.tlpsrc