From 893b65e5d4c0b7cb8ebbfca9ee6b090b9a4a182c Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 14 Jun 2020 03:02:26 +0000 Subject: CTAN sync 202006140302 --- graphics/pgf/contrib/yquant/README.md | 4 +- graphics/pgf/contrib/yquant/doc/qasm/test1.qasm | 12 + graphics/pgf/contrib/yquant/doc/qasm/test10.qasm | 16 + graphics/pgf/contrib/yquant/doc/qasm/test11.qasm | 20 + graphics/pgf/contrib/yquant/doc/qasm/test12.qasm | 20 + graphics/pgf/contrib/yquant/doc/qasm/test13.qasm | 42 ++ graphics/pgf/contrib/yquant/doc/qasm/test14.qasm | 49 ++ graphics/pgf/contrib/yquant/doc/qasm/test15.qasm | 17 + graphics/pgf/contrib/yquant/doc/qasm/test16.qasm | 22 + graphics/pgf/contrib/yquant/doc/qasm/test17.qasm | 22 + graphics/pgf/contrib/yquant/doc/qasm/test18.qasm | 20 + graphics/pgf/contrib/yquant/doc/qasm/test2.qasm | 20 + graphics/pgf/contrib/yquant/doc/qasm/test3.qasm | 13 + graphics/pgf/contrib/yquant/doc/qasm/test4.qasm | 23 + graphics/pgf/contrib/yquant/doc/qasm/test5.qasm | 15 + graphics/pgf/contrib/yquant/doc/qasm/test6.qasm | 20 + graphics/pgf/contrib/yquant/doc/qasm/test7.qasm | 21 + graphics/pgf/contrib/yquant/doc/qasm/test8.qasm | 23 + graphics/pgf/contrib/yquant/doc/qasm/test9.qasm | 20 + graphics/pgf/contrib/yquant/doc/yquant-doc.pdf | Bin 512339 -> 600284 bytes graphics/pgf/contrib/yquant/doc/yquant-doc.tex | 380 ++++++++++-- graphics/pgf/contrib/yquant/tex/yquant-circuit.tex | 286 ++++----- graphics/pgf/contrib/yquant/tex/yquant-config.tex | 168 ++--- graphics/pgf/contrib/yquant/tex/yquant-draw.tex | 482 ++++++++++++--- graphics/pgf/contrib/yquant/tex/yquant-env.tex | 319 ++++++++-- graphics/pgf/contrib/yquant/tex/yquant-lang.tex | 467 +++++++++----- .../pgf/contrib/yquant/tex/yquant-langhelper.tex | 10 +- .../pgf/contrib/yquant/tex/yquant-registers.tex | 355 +++++++++-- graphics/pgf/contrib/yquant/tex/yquant-shapes.tex | 17 +- graphics/pgf/contrib/yquant/tex/yquant-tools.tex | 326 +++++++++- graphics/pgf/contrib/yquant/tex/yquant.sty | 9 +- .../pgf/contrib/yquant/tex/yquantlanguage-qasm.sty | 681 +++++++++++++++++++++ 32 files changed, 3233 insertions(+), 666 deletions(-) create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test1.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test10.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test11.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test12.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test13.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test14.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test15.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test16.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test17.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test18.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test2.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test3.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test4.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test5.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test6.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test7.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test8.qasm create mode 100644 graphics/pgf/contrib/yquant/doc/qasm/test9.qasm create mode 100644 graphics/pgf/contrib/yquant/tex/yquantlanguage-qasm.sty (limited to 'graphics/pgf/contrib') diff --git a/graphics/pgf/contrib/yquant/README.md b/graphics/pgf/contrib/yquant/README.md index 56a8428524..d8d8e1afaa 100644 --- a/graphics/pgf/contrib/yquant/README.md +++ b/graphics/pgf/contrib/yquant/README.md @@ -7,8 +7,10 @@ It builds on and interacts with TiKZ, which brings an enourmous flexibility for A detailed reference with lots of examples is provided in the PDF version of this Readme. We will sketch some basic usage. +Now yquant also understands circuits written in the qasm language! + ## License -This material is subject to the LaTeX Project Public License 1.3. +This material is subject to the LaTeX Project Public License 1.3c. ## Examples Many more examples and explanations can be found in the [PDF version](https://github.com/projekter/yquant/raw/master/doc/latex/yquant/yquant-doc.pdf) of this Readme. diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test1.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test1.qasm new file mode 100644 index 0000000000..0f8dc1d4fc --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test1.qasm @@ -0,0 +1,12 @@ +# +# File: test1.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - EPR creation +# + qubit q0 + qubit q1 + + h q0 # create EPR pair + cnot q0,q1 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test10.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test10.qasm new file mode 100644 index 0000000000..4f788eb36c --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test10.qasm @@ -0,0 +1,16 @@ +# +# File: test10.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - multi-qubit gates +# also demonstrates use of classical bits + + qubit q0 + cbit c1 + qubit q2 + + h q0 + Utwo q0,c1 + S q2 + Utwo c1,q2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test11.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test11.qasm new file mode 100644 index 0000000000..e668be717f --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test11.qasm @@ -0,0 +1,20 @@ +# +# File: test11.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - user-defined +# multi-qubit ops + + defbox fx,2,0,'U_{f(x)}' + defbox fxy,3,0,'U_{f(x,y)}' + + qubit q0 + qubit q1 + qubit q2 + + h q0 + fx q0,q1 + h q1 + fxy q0,q1,q2 + diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test12.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test12.qasm new file mode 100644 index 0000000000..d9a6a7caed --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test12.qasm @@ -0,0 +1,20 @@ +# +# File: test12.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - multi-qubit controlled +# multi-qubit operations + + defbox CU2,3,1,'U' + defbox CV2,3,1,'V' + + qubit q0 + qubit q1 + qubit q2 + + h q0 + CU2 q0,q1,q2 + h q0 + CV2 q2,q0,q1 + \ No newline at end of file diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test13.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test13.qasm new file mode 100644 index 0000000000..a8def4239c --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test13.qasm @@ -0,0 +1,42 @@ +# +# File: test13.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - three-qubit phase +# estimation circuit with QFT and controlled-U + + defbox CU,3,1,'U' + defbox CU2,3,1,'U^2' + defbox CU4,3,1,'U^4' + def c-S,1,'S' + def c-T,1,'T' + + qubit j0,0 # QFT qubits + qubit j1,0 + qubit j2,0 + qubit s0 # U qubits + qubit s1 + + h j0 # equal superposition + h j1 + h j2 + + CU4 j0,s0,s1 # controlled-U + CU2 j1,s0,s1 + CU j2,s0,s1 + + h j0 # QFT + c-S j0,j1 + h j1 + nop j0 + c-T j0,j2 + c-S j1,j2 + h j2 + nop j0 + nop j0 + nop j1 + + measure j0 # final measurement + measure j1 + measure j2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test14.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test14.qasm new file mode 100644 index 0000000000..ee83a46a4d --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test14.qasm @@ -0,0 +1,49 @@ +# +# File: test14.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - three-qubit FT QEC +# circuit with syndrome measurement + + defbox synd,4,0,'\txt{Process\\Syndrome}' + defbox rop,7,4,'{\symcal R}' + + qubit q0 # code data qubits + qubit q1 + qubit q2 + qubit s0,0 # syndrome measurement qubits + qubit s1,0 + cbit c0,0 # classical bits to store syndromes + cbit c1,0 + + h s0 # create EPR pair for FT meas + cnot s0,s1 + cnot q0,s0 # measure parity of q0,q1 + nop s1 # prevent cnot's from colliding + cnot q1,s1 + cnot s0,s1 # uncreate EPR + h s0 + measure s0 # measure syndrome qubits + nop s1 + measure s1 + cnot s0,c0 # copy to classical bits + nop s1 + cnot s1,c1 + space s0 + + zero s0 + zero s1 + h s0 # create EPR pair for FT meas + cnot s0,s1 + cnot q1,s0 # measure parity of q1,q2 + nop s1 # prevent cnot's from colliding + cnot q2,s1 + cnot s0,s1 # uncreate EPR + h s0 + measure s0 # measure syndrome qubits + nop s1 + measure s1 + + synd s0,s1,c0,c1 + rop s0,s1,c0,c1,q0,q1,q2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test15.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test15.qasm new file mode 100644 index 0000000000..0d7ed35ea5 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test15.qasm @@ -0,0 +1,17 @@ +# +# File: test15.qasm +# Date: 24-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - "D-type" measurement +# requested by Nielsen + + def MeasZ,0,'\dmeterwide{HZ_\theta}{18pt}' + + qubit q0,\psi + qubit q1,+ + + nop q0 + ZZ q0,q1 + nop q0 + MeasZ q0 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test16.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test16.qasm new file mode 100644 index 0000000000..1aa78ddfbf --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test16.qasm @@ -0,0 +1,22 @@ +# +# File: test16.qasm +# Date: 24-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - example from Nielsen +# paper on cluster states + + qubit q0,\psi + qubit q1,\psi + qubit q2,\phi + qubit q3,0 + + nop q0 + nop q0 + slash q0 + nop q1 + ZZ q1,q2 + cnot q2,q3 + nop q2 + discard q2 + dmeter q3 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test17.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test17.qasm new file mode 100644 index 0000000000..e1eefac730 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test17.qasm @@ -0,0 +1,22 @@ +# +# File: test17.qasm +# Date: 24-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - example from Nielsen +# paper on cluster states + + def MeasH,0,'\dmeter{H}' + + qubit q0,\psi + qubit q1,+ + qubit q2,+ + qubit q3,\phi + + nop q0 + nop q2 + ZZ q0,q1 + ZZ q2,q3 + ZZ q1,q2 + MeasH q1 + MeasH q2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test18.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test18.qasm new file mode 100644 index 0000000000..04576ece23 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test18.qasm @@ -0,0 +1,20 @@ +# +# File: test18.qasm +# Date: 25-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - multiple-control bullet op + + def MeasH,0,'\dmeter{H}' + def Z4,3,'bullet' # handled specially + + qubit q0,\psi + qubit q1,+ + qubit q2,+ + qubit q3,\phi + + nop q0 + nop q2 + Z4 q0,q1,q2,q3 + MeasH q1 + MeasH q2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test2.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test2.qasm new file mode 100644 index 0000000000..9b8ae9af10 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test2.qasm @@ -0,0 +1,20 @@ +# +# File: test2.qasm +# Date: 29-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - simple teleportation circuit +# + qubit q0 + qubit q1 + qubit q2 + + h q1 # create EPR pair + cnot q1,q2 + cnot q0,q1 # Bell basis measurement + h q0 + nop q1 + measure q0 + measure q1 + c-x q1,q2 # correction step + c-z q0,q2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test3.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test3.qasm new file mode 100644 index 0000000000..01c8247741 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test3.qasm @@ -0,0 +1,13 @@ +# +# File: test3.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - swap circuit +# + qubit q0 + qubit q1 + + cnot q0,q1 + cnot q1,q0 + cnot q0,q1 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test4.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test4.qasm new file mode 100644 index 0000000000..c4dc61ef21 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test4.qasm @@ -0,0 +1,23 @@ +# +# File: test4.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - quantum +# fourier transform on three qubits + + def c-S,1,'S' + def c-T,1,'T' + + qubit j0 + qubit j1 + qubit j2 + + h j0 + c-S j1,j0 + c-T j2,j0 + nop j1 + h j1 + c-S j2,j1 + h j2 + swap j0,j2 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test5.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test5.qasm new file mode 100644 index 0000000000..0a1a7e511b --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test5.qasm @@ -0,0 +1,15 @@ +# +# File: test5.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - demonstrate arbitray qubit matrix ops + + def c-P,1,'\m{e^{i\alpha} & 0 \cr 0 & e^{-i\alpha}}' + def Ryt,0,'\m{\cos{\theta}&-\sin{\theta}\cr\sin{\theta}&\cos{\theta}}' + + qubit j0 + qubit j1 + + c-P j0,j1 + Ryt j0 \ No newline at end of file diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test6.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test6.qasm new file mode 100644 index 0000000000..88d48c87ab --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test6.qasm @@ -0,0 +1,20 @@ +# +# File: test6.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - demonstrate +# multiple-qubit controlled single-q-gates + + def c-U,3,'U' + + qubit j0 + qubit j1 + qubit j2 + qubit j3 + + toffoli j0,j1,j2 + X j0 + c-U j2,j3,j0,j1 + H j2 + measure j3 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test7.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test7.qasm new file mode 100644 index 0000000000..ffc7227b20 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test7.qasm @@ -0,0 +1,21 @@ +# +# File: test7.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - measurement +# of operator with correction + + def c-U,1,'U' + def c-V,1,'V' + + qubit q0 + qubit q1 + + H q0 + c-U q0,q1 + H q0 + measure q0 + c-V q0,q1 + nop q0 + nop q1 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test8.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test8.qasm new file mode 100644 index 0000000000..ba88ef68b4 --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test8.qasm @@ -0,0 +1,23 @@ +# +# File: test8.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - stage in +# simplification of quantum teleportation + + def c-Z,1,'Z' + + qubit q0,\psi + qubit q1,0 + qubit q2,0 + + H q1 + cnot q0,q1 + cnot q1,q2 + cnot q0,q1 + cnot q1,q2 + H q0 + c-Z q2,q0 + H q0 + H q0 diff --git a/graphics/pgf/contrib/yquant/doc/qasm/test9.qasm b/graphics/pgf/contrib/yquant/doc/qasm/test9.qasm new file mode 100644 index 0000000000..fc1486be8d --- /dev/null +++ b/graphics/pgf/contrib/yquant/doc/qasm/test9.qasm @@ -0,0 +1,20 @@ +# +# File: test9.qasm +# Date: 22-Mar-04 +# Author: I. Chuang +# +# Sample qasm input file - two-qubit gate circuit +# implementation of Toffoli + + def c-X,1,'\sqrt{X}' + def c-Xd,1,'{\sqrt{X}}^\dagger' + + qubit q0 + qubit q1 + qubit q2 + + c-X q1,q2 + cnot q0,q1 + c-Xd q1,q2 + cnot q0,q1 + c-X q0,q2 diff --git a/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf b/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf index 16dca0f393..fb714890d7 100644 Binary files a/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf and b/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf differ diff --git a/graphics/pgf/contrib/yquant/doc/yquant-doc.tex b/graphics/pgf/contrib/yquant/doc/yquant-doc.tex index 6455278430..cf32f913e6 100644 --- a/graphics/pgf/contrib/yquant/doc/yquant-doc.tex +++ b/graphics/pgf/contrib/yquant/doc/yquant-doc.tex @@ -14,8 +14,9 @@ \definecolor{darkblue}{RGB}{5, 10, 122} \usepackage[english]{babel} \usepackage[colorlinks, linkcolor=darkblue, bookmarksdepth=paragraph]{hyperref} -\usepackage{yquant,braket,hyphenat,microtype,hologo,minted} +\usepackage{yquant,braket,hyphenat,microtype,hologo,minted,import} \usetikzlibrary{quotes,fit,shapes.symbols,backgrounds,quantikz} +\useyquantlanguage{qasm} \usepackage{amsmath,adjustbox,cleveref} \usepackage[framemethod=tikz]{mdframed} % END_FOLD @@ -52,16 +53,17 @@ \endgroup\vskip-\parskip% \noindent\ignorespaces% } -\newenvironment{option}[1]{\vskip5mm% +\newenvironment{option*}[2]{\vskip5mm% \noindent\begin{minipage}[t]{\linewidth}% \begingroup% \let\minted@inline@iii=\patched@minted@inline@iii% \raggedleft% \hspace*{-1cm}% - \phantomsection\label{style:/yquant/#1}% - \texttt{\textcolor{gray}{/yquant/}\textcolor{mintgreen}{#1}}\hfill default: % + \phantomsection\label{style:/#1/#2}% + \texttt{\textcolor{gray}{/#1/}\textcolor{mintgreen}{#2}}\hfill default: % \tex}{% \end{minipage}} +\newenvironment{option}{\csname option*\endcsname{yquant}}{\csname endoption*\endcsname} \newsavebox\codeexamplebox \newenvironment{codeexample}{% @@ -196,8 +198,8 @@ \section{Introduction} This document outlines the scope and usage of the \Yquant{} package. It contains both a reference and a huge number of examples. - \Yquant{} is a package that makes typesetting quantum circuits easy; the package is not yet available on CTAN. - This alpha version~0.1.2 \emph{should} be stable and interfaces are not very likely to change in an incompatible way in the future. + \Yquant{} is a package that makes typesetting quantum circuits easy; the package is available on CTAN. + This alpha version~0.3 \emph{should} be stable and interfaces are not very likely to change in an incompatible way in the future. Please do report all issues and desirable additions. \subsection{How to read the manual} @@ -209,7 +211,9 @@ Then, have a look at \cref{sec:tikz} (or \cref{sec:alt}). \subsection{Installation} - At the moment, clone this repository or download a copy and extract the files to a path visible to your \TeX{} compiler. + The recommended way of installation is through CTAN. + A direct installation from this Git repository to obtain the latest additions and features is be possible by just cloning it to a path visible to your \TeX{} compiler. + While the repository may contain new additions, they are not thoroughly tested until they end up on CTAN; features that are not documented in this manual are entirely unreliable. For example, you may put them in the same directory as your document (if you just want to give a try), or you may extract them to \texttt{tex/latex/yquant} in your local \texttt{texmf} (followed by an update of the file name database). \subsection{Purpose of \Yquant, alternatives}\label{sec:alt} @@ -229,6 +233,8 @@ Changes to the output, while possible, will be overwritten if \texttt{qasm2circ} is run again. \pkg{qasm} output often looks sub\hyp optimal do to the fact that, e.g., rectangles are made up of four lines that do not properly connect and give a crumbly general feeling. + Note that since version~0.3, \Yquant{} understands \pkg{qasm} syntax, see \cref{sec:foreign:qasm}. + Maintenance status: last update of \pkg{qasm} in 2005. Also, \pkg{xy} was last updated in 2013, and the script is not compatible out\hyp of\hyp the\hyp box with Python~3, though an automatic conversion should work. \item \pkg{qcircuit} is probably the most\hyp widely used package. It provides commands that make it much easier to create quantum circuits using the \pkg{xy} package. @@ -243,7 +249,7 @@ It also reduces burdens of the \pkg{xy} syntax. However, the disadvantages of the grid\hyp based syntax still remain. - Maintenance status: last update in 2019; the underlying \TikZ{} is actively maintained again by now. + Maintenance status: last update in 2020; the underlying \TikZ{} is actively maintained again by now. \item \pkg{qpic} follows the approach of \pkg{qasm}: It makes use of an external Python program that reads the quantum circuits in an own language and converts them into \TikZ{} commands. The language \pkg{qpic} follows is much more powerful than \pkg{qasm}'s. The disadvantage that modifications in the output code will not remain after running the Python script again is mitigated by the possibility to define own \TeX{} macros. @@ -292,7 +298,7 @@ The optional arguments for the \tex!yquant! environment have to appear \emph{on the same line} as the environment itself. If you want to put the arguments into a new line, it is crucial to mask the line break by putting a comment symbol after the environment: \tex!\begin{yquant}%!. Without this comment, \Yquant{} will detect your line break (this is one of the few places in \TeX{} where line breaks and spaces are different) and assume that the expression in square brackets instead provides arguments for the following operation! \\ - Finally note that in (non\hyp fragile) \texttt{beamer} frames, this discrimination between spaces and new lines does not work; the optional arguments will always be counted for the environment, not for the gate. + Finally note that in (non\hyp fragile) \pkg{beamer} frames, this discrimination between spaces and new lines does not work; the optional arguments will always be counted for the environment, not for the gate. In this case, you can either declare the frame as fragile or (recommended) introduce a blank line between the environment and the options for the first gate. \end{warning} @@ -302,6 +308,7 @@ The starred form additionally supports the use of undeclared registers: it basically declares a registers upon its first usage. This will always be a \texttt{qubit} register; but if you use the corresponding option and the first usage is an \gate{init} command, you may overwrite this. + Subcircuits always use the unstarred form. Additionally, if you refer to the index $i$ of a vector register of length $L < i$, this register will automatically be enlarged to $i \coloneq L$. It is also possible to convert a scalar register into a vector register in this manner. @@ -435,6 +442,8 @@ IndexSingle = ?number? | ( [ ?number? ], "-", [ ?number? ] ); It will draw a \emph{main} part of the gate at the first contiguous slice of registers in the target list---you may select another register for this part by preceding the name or index with a star (which, contrary to the simplified grammar, may only occur \emph{once} in a target specification). All other contiguous slices of target registers will be drawn in a \emph{subordinate style} for this gate. Finally, all slices will be connected by a single vertical line with the style \style{/yquant/every multi line}. + Subcircuits, supported as of version~0.2, will always span the full region from the first to the last register specified in a multi\hyp qubit gate. + This is due to the fact that they may contain arbitrary ancilla registers which may be positioned somewhere in between the parts that actually constitute the subcircuit---so this whole region must not have wires of other registers crossing. \begin{warning}[Discontiguous targets and control lines] A control line extends from the very first to the very last affected register in an operation. A sub\hyp gate line that is used for discontiguous registers will only span the range of a multi\hyp register. @@ -477,6 +486,97 @@ IndexSingle = ?number? | ( [ ?number? ], "-", [ ?number? ] ); If there are no positive controls, the list may be empty or, together with the pipe, omitted. Preceded by a tilde (``\yquant!~!''), the list of negative controls then follows; this mimics the syntax of many programming languages that denote logical negation by a tilde. If there are no negative controls, the list may be empty or, together with the pipe, omitted. + + \clearpage + \subsection{Importing circuits from files}\label{sec:import} + Since version~0.2, \Yquant{} provides a simple way to import circuits that are stored in external files. + The macro \tex!\yquantimport! can be used in three different contexts: + \begin{itemize} + \item Outside of a \TikZ{} picture environment. \\ + In this case, \tex!\yquantimport[]{}! will be equivalent to + \begin{minted}{tex} +\begin{tikzpicture} + \begin{yquant}[] + % the content of goes here + \end{yquant} +\end{tikzpicture} + \end{minted} + The starred form, \tex!\yquantimport*[]{}!, instead inserts the starred \Yquant{} environment. + Note that the options are always \Yquant{} options; if you want to pass \TikZ{} options, you will have to create the picture environment by yourself or change the option path to the correct one (\texttt{/tikz/.cd}). + \item Inside a \TikZ{} picture environment, but outside of a \Yquant{} environment. \\ + This is the same as before, just that no extra picture environment will be added. + \item Inside both a \TikZ{} picture environment and a \Yquant{} environment. \\ + The file will be inserted directly into the environment. + \Yquant's parser is automatically restarted after this. + The content will always be put in a \TeX{} group; if additional options are provided, \Yquant{} also inserts a \TikZ{} \tex!scope! and executes \tex!\yquantset{}! directly after the scope. + If \tex!\yquantimport! is used, the content will be read as if the containing environment was an unstarred one; if \tex!\yquantimport*! is used, the content will be read as if the containing environment was a starred one. + \end{itemize} + Note that \Yquant{} internally uses plain \TeX's \tex!\import! command (i.e., \tex!\@@import! in \LaTeX). + However, when the \pkg{import} package is loaded, it uses \\ \tex!\subimport{\yquantimportpath}{}!, where \tex!\yquantimportpath! defaults to \texttt{./}---so by changing this, files from other folders may be imported which by themselves again include other files, and the relative path resolution will work. + + Note that you may in particular import the content of a \gate{subcircuit}. + + \subsection{Defining own gates} + \begin{warning}[Scope] + All gate declarations are always global. + \end{warning} + + Since version~0.2.1, if you want to define a gate that corresponds to a single \gate{box} gate with a certain pre\hyp defined content, you may use the macro\\ + \tex!\yquantdefinebox{}[