summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/yquant
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-04-14 21:06:44 +0000
committerKarl Berry <karl@freefriends.org>2020-04-14 21:06:44 +0000
commitbbe9e3a2874a81d4559603fc57aa37a0f53ae4bb (patch)
tree3b44a4b917247d46f8b79043e2a2774a9e118d3c /Master/texmf-dist/tex/latex/yquant
parent70ceb95a32e274762041dec44d43760f70c2dd31 (diff)
yquant (14apr20)
git-svn-id: svn://tug.org/texlive/trunk@54737 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/yquant')
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex304
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-config.tex188
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-draw.tex410
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-env.tex8
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-lang.tex151
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex16
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-registers.tex365
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex610
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-tools.tex41
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant.sty8
10 files changed, 1347 insertions, 754 deletions
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex b/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
index 993455cbebb..2117e7f4407 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
@@ -1,221 +1,145 @@
% BEGIN_FOLD Drawing wires
-% extends the wire of register #1. Assumes a node called yquantbox is set up, and it is a node with appropriate projections.
-\protected\def\yquant@circuit@extendwire#1{%
- \begingroup%
- \edef\wiretype{\yquant@register@get@type{#1}}%
- \dimdef\wireypos{\yquant@register@get@y{#1}}%
- \tikzset{/yquant/every wire}%
- \unless\ifnum\wiretype=\yquant@register@type@none{%
- \csname yquant@circuit@extendwire@\wiretype\endcsname{#1}%
- }\fi%
- % set the wire style to have the correct \pgflinewidth available (we don't allow individual line widths for different types of wires
- \tikzset{/yquant/every wire}%
- \pgfpointanchor{yquantbox}{east}%
- \@tempdima=\pgf@x%
- \pgfpointshapexproj{yquantbox}%
- {\pgfqpoint{\@tempdima}
- {\dimexpr\wireypos+2\pgflinewidth\relax}}%
- \edef\tmp{{(\the\pgf@x,\the\pgf@y)}}%
- % For multi-qubit registers, the east anchor is not necessarily accurate.
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\@tempdima}{\wireypos}}%
- \edef\tmp{\tmp{(\the\pgf@x,\the\pgf@y)}}%
- \pgfpointshapexproj{yquantbox}
- {\pgfqpoint{\@tempdima}%
- {\dimexpr\wireypos-2\pgflinewidth\relax}}%
- \yquant@register@set@lastwire{#1}{\tmp{(\the\pgf@x,\the\pgf@y)}}%
- \endgroup%
-}
-
-% finishes the wire of register #1 until x position \yquant@env@end@xpos
-\protected\def\yquant@circuit@endwire#1{%
- \begingroup%
- \edef\wiretype{\yquant@register@get@type{#1}}%
- \unless\ifnum\wiretype=\yquant@register@type@none\relax%
- % we don't have a yquantbox node but still want to extend the line; so just install a dummy projection
- \let\pgfpointshapexproj=\yquant@circuit@endwire@xproj%
- \dimdef\wireypos{\yquant@register@get@y{#1}}%
- \tikzset{/yquant/every wire}%
- \csname yquant@circuit@extendwire@\wiretype\endcsname{#1}%
- \fi%
- \endgroup%
-}
-
-\protected\def\yquant@circuit@endwire@xproj#1#2{%
- \pgf@process{%
- #2%
- \pgf@x=\yquant@env@end@xpos%
- }%
-}
-
-\def\yquant@circuit@extendwire@@extract(#1,#2){%
- #1%
-}
-
% a bit faster than nested \@firstoftwo/\@secondoftwo
% note \@thirdofthree is defined in the latex kernel already.
\long\def\@firstofthree#1#2#3{#1}%
\long\def\@secondofthree#1#2#3{#2}%
+\long\def\@firstoffour#1#2#3#4{#1}%
+\long\def\@secondoffour#1#2#3#4{#2}%
+\long\def\@thirdoffour#1#2#3#4{#3}%
+\long\def\@fourthoffour#1#2#3#4{#4}%
+\long\def\@thirdandfourthoffour#1#2#3#4{#3#4}%
-% quantum wire
-\protected\csdef{yquant@circuit@extendwire@1}#1{%
- \edef\tmp{\yquant@register@get@lastwire{#1}}%
- \edef\tmp{\expandafter\@secondofthree\tmp}%
- \edef\lastx{\expandafter\yquant@circuit@extendwire@@extract\tmp}%
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastx}{\wireypos}}%
- \ifdim\lastx<\pgf@x%
- \edef\cmd{%
- \noexpand\path [/yquant/every wire, /yquant/every qubit wire]
- \tmp -- (\the\pgf@x,\the\pgf@y);%
- }%
- \cmd%
- \fi%
+% extends the wire of register #1. Assumes a node called yquantbox is set up, and the \pgfshapeclippathhorzresult was set up appropriately for this node.
+\protected\def\yquant@circuit@extendwire#1{%
+ \begingroup%
+ \pgfpointanchor{yquantbox}{center}%
+ \edef\wirexpos{\the\pgf@x}%
+ \yquant@register@get@typeywire{#1}\wiretype\wireypos\wirelast%
+ \edef\wirexprevpos{\expandafter\@firstoffour\wirelast}%
+ \ifnum\wiretype=\yquant@register@type@none%
+ % the clippings of the previous operator will for sure not be needed, but the type might be turned into an active one, so we need the last clipping.
+ \yquant@register@set@lastwire{#1}{%
+ {\wirexprevpos}{\wirexpos}{}%
+ {\unexpanded\expandafter{\pgfshapeclippathhorzresult}}%
+ }%
+ \else%
+ % append the previous `last' clipping to the old list and insert the new one
+ \yquant@register@set@lastwire{#1}{%
+ {\wirexprevpos}{\wirexpos}%
+ {\unexpanded\expandafter\expandafter\expandafter{%
+ \expandafter\@thirdandfourthoffour\wirelast%
+ }%
+ }
+ {\unexpanded\expandafter{\pgfshapeclippathhorzresult}}%
+ }%
+ \fi%
+ \endgroup%
}
-% classical wire
-\protected\csdef{yquant@circuit@extendwire@2}#1{%
- \edef\tmp{\yquant@register@get@lastwire{#1}}%
- \edef\tmpa{\expandafter\@firstofthree\tmp}%
- \edef\lastxa{\expandafter\yquant@circuit@extendwire@@extract\tmpa}%
- \edef\tmpb{\expandafter\@thirdofthree\tmp}%
- \edef\lastxb{\expandafter\yquant@circuit@extendwire@@extract\tmpb}%
- \let\cmd=\empty%
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxa}%
- {\dimexpr\wireypos+2\pgflinewidth\relax}}%
- \ifdim\lastxa<\pgf@x%
- \edef\cmd{%
- \tmpa -- (\the\pgf@x,\the\pgf@y)%
- }%
- \fi%
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxb}%
- {\dimexpr\wireypos-2\pgflinewidth\relax}}%
- \ifdim\lastxb<\pgf@x%
- \eappto\cmd{%
- \tmpb -- (\the\pgf@x,\the\pgf@y)%
- }%
- \fi%
- \unless\ifx\cmd\empty%
- \edef\cmd{\noexpand\path [/yquant/every wire, /yquant/every cbit wire] \cmd;}%
- \cmd%
- \fi%
+% finishes the wire of registers 1 to #1 until x position \yquant@env@end@xpos
+\protected\def\yquant@circuit@endwires#1{%
+ \yquant@for \yquant@circuit@endwires@i := 1 to #1 {
+ \yquant@draw@wire\yquant@circuit@endwires@i\yquant@env@end@xpos%
+ }%
}
-% quantum-bundle
-\protected\csdef{yquant@circuit@extendwire@3}#1{%
- \edef\tmp{\yquant@register@get@lastwire{#1}}%
- \edef\tmpa{\expandafter\@firstofthree\tmp}%
- \edef\lastxa{\expandafter\yquant@circuit@extendwire@@extract\tmpa}%
- \edef\tmpb{\expandafter\@secondofthree\tmp}%
- \edef\lastxb{\expandafter\yquant@circuit@extendwire@@extract\tmpb}%
- \edef\tmpc{\expandafter\@thirdofthree\tmp}%
- \edef\lastxc{\expandafter\yquant@circuit@extendwire@@extract\tmpc}%
- \let\cmd=\empty%
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxa}%
- {\dimexpr\wireypos+2\pgflinewidth\relax}}%
- \ifdim\lastxa<\pgf@x%
- \edef\cmd{%
- \tmpa -- (\the\pgf@x,\the\pgf@y)%
- }%
- \fi%
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxb}{\wireypos}}%
- \ifdim\lastxb<\pgf@x%
- \eappto\cmd{%
- \tmpb -- (\the\pgf@x,\the\pgf@y)%
- }%
- \fi%
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxc}%
- {\dimexpr\wireypos-2\pgflinewidth\relax}}%
- \ifdim\lastxc<\pgf@x%
- \eappto\cmd{%
- \tmpc -- (\the\pgf@x,\the\pgf@y)%
+% outputs the wire according to its previous instructions and prepares for a change in the wire style
+\protected\def\yquant@circuit@flushwire#1{%
+ \yquant@draw@wire{#1}{}%
+ \begingroup%
+ \yquant@register@get@lastwire{#1}\wirelast%
+ \yquant@register@set@lastwire{#1}{%
+ {\expandafter\@secondoffour\wirelast}{\expandafter\@secondoffour\wirelast}{}%
+ {\unexpanded\expandafter\expandafter\expandafter{%
+ \expandafter\@fourthoffour\wirelast%
+ }}%
}%
- \fi%
- \unless\ifx\cmd\empty%
- \edef\cmd{\noexpand\path [/yquant/every wire, /yquant/every qubits wire] \cmd;}%
- \cmd%
- \fi%
+ \endgroup%
}
% END_FOLD
% BEGIN_FOLD Drawing control lines
-% populates a drawing macro with the current control line with style #1 at position #2. Assumes a node called yquantbox is set up, and it is a node with appropriate projections. At the first call, \yquant@circuit@extendcontrolline@cmd must be \let to \empty and \yquant@circuit@extendcontrolline@prev to \relax.
+% populates a drawing macro with the current control line with style #1 at position #2. Assumes a node called yquantbox is set up, and the \pgfshapeclippathvertresult was set up appropriately for this node. At the first call, \yquant@circuit@extendcontrolline@cmd must be \let to \empty and \yquant@circuit@extendcontrolline@prev to \relax.
\protected\def\yquant@circuit@extendcontrolline#1#2{%
\begingroup%
\tikzset{/yquant/every control line}%
\expandafter%
\endgroup%
+ \eappto\yquant@circuit@extendcontrolline@clip{%
+ \unexpanded\expandafter{\pgfshapeclippathvertresult}%
+ }%
\expandafter\@tempdima\the\pgflinewidth%
\ifcase#1%
% no control (or to a discarded target, which we don't do)
\or%
% qubit
+ \pgfpointanchor{yquantbox}{center}%
\unless\ifx\yquant@circuit@extendcontrolline@prev\relax%
- \pgfpointanchor{yquantbox}{north}%
- \pgfpointshapeyproj{yquantbox}{\pgf@x=#2\relax}%
\eappto\yquant@circuit@extendcontrolline@cmd{%
\expandafter\@secondofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\pgf@x,\the\pgf@y)%
+ -- (#2,\the\pgf@y)%
}%
\fi%
\yquant@circuit@extendcontrolline@store{#2}%
\or%
% cbit
+ \pgfpointanchor{yquantbox}{center}%
\unless\ifx\yquant@circuit@extendcontrolline@prev\relax%
- \pgfpointanchor{yquantbox}{north}%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#2-2\@tempdima\relax}%
\eappto\yquant@circuit@extendcontrolline@cmd{%
\expandafter\@firstofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\pgf@x,\the\pgf@y)%
- }%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#2+2\@tempdima\relax}%
- \eappto\yquant@circuit@extendcontrolline@cmd{%
+ -- (\the\dimexpr#2-2\@tempdima\relax,\the\pgf@y)%
\expandafter\@thirdofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\pgf@x,\the\pgf@y)%
+ -- (\the\dimexpr#2+2\@tempdima\relax,\the\pgf@y)%
}%
\fi%
\yquant@circuit@extendcontrolline@store{#2}%
\or%
% quantum-bundle (very unusual, but perhaps for transversal operations?)
+ \pgfpointanchor{yquantbox}{center}%
\unless\ifx\yquant@circuit@extendcontrolline@prev\relax%
- \pgfpointanchor{yquantbox}{north}%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#2-2\@tempdima\relax}%
\eappto\yquant@circuit@extendcontrolline@cmd{%
\expandafter\@firstofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\pgf@x,\the\pgf@y)%
- }%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#2\relax}%
- \eappto\yquant@circuit@extendcontrolline@cmd{%
+ -- (\the\dimexpr#2-2\@tempdima\relax,\the\pgf@y)%
\expandafter\@secondofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\pgf@x,\the\pgf@y)%
- }%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#2+2\@tempdima\relax}%
- \eappto\yquant@circuit@extendcontrolline@cmd{%
+ -- (\the\dimexpr#2\relax,\the\pgf@y)%
\expandafter\@thirdofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\pgf@x,\the\pgf@y)%
+ -- (\the\dimexpr#2+2\@tempdima\relax,\the\pgf@y)%
}%
\fi%
\yquant@circuit@extendcontrolline@store{#2}%
\else%
- \PackageError{yquant.sty}{Invalid control line type `\the#1'}%
+ \PackageError{yquant.sty}{Invalid control line type `#1'}%
{yquant encountered an internal error.}%
\fi%
}
\protected\def\yquant@circuit@extendcontrolline@store#1{%
- \pgfpointanchor{yquantbox}{south}%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#1-2\@tempdima\relax}%
- \edef\yquant@circuit@extendcontrolline@prev{{(\the\pgf@x,\the\pgf@y)}}%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=#1\relax}%
- \eappto\yquant@circuit@extendcontrolline@prev{{(\the\pgf@x,\the\pgf@y)}}%
- \pgfpointshapeyproj{yquantbox}%
- {\pgf@x=\dimexpr#1+2\@tempdima\relax}%
- \eappto\yquant@circuit@extendcontrolline@prev{{(\the\pgf@x,\the\pgf@y)}}%
+ \edef\yquant@circuit@extendcontrolline@prev{%
+ {(\the\dimexpr#1-2\@tempdima\relax,\the\pgf@y)}%
+ {(\the\dimexpr#1\relax,\the\pgf@y)}%
+ {(\the\dimexpr#1+2\@tempdima\relax,\the\pgf@y)}%
+ }%
+}
+
+% populates a drawing macro with the multi operation connector at position #2. Assumes a node called yquantbox is set up, and the \pgfshapeclippathvertresult was set up appropriately for this node. At the first call, \yquant@circuit@extendmultiline@cmd must be \let to \empty and \yquant@circuit@extendmultiline@prev to \relax.
+\protected\def\yquant@circuit@extendmultiline#1{%
+ \begingroup%
+ \tikzset{/yquant/every multi line}%
+ \expandafter%
+ \endgroup%
+ \eappto\yquant@circuit@extendmultiline@clip{%
+ \unexpanded\expandafter{\pgfshapeclippathvertresult}%
+ }%
+ \expandafter\@tempdima\the\pgflinewidth%
+ \pgfpointanchor{yquantbox}{center}%
+ \unless\ifx\yquant@circuit@extendmultiline@prev\relax%
+ \eappto\yquant@circuit@extendmultiline@cmd{%
+ \yquant@circuit@extendmultiline@prev -- (#1,\the\pgf@y)%
+ }%
+ \fi%
+ \edef\yquant@circuit@extendmultiline@prev{%
+ (\the\dimexpr#1\relax,\the\pgf@y)%
+ }%
}
% END_FOLD
@@ -364,7 +288,18 @@
% BEGIN_FOLD Helpers for operator callbacks
% turn a wire into a different type
\def\yquant@circuit@settype#1{%
- \yquant@register@set@type{#1}\yquant@circuit@settype@to%
+ \yquant@circuit@flushwire{#1}%
+ \yquant@register@set@type{#1}{\yquant@circuit@settype@to}%
+}
+
+\protected\long\def\yquant@circuit@setstyle#1#2{%
+ \yquant@circuit@flushwire{#1}%
+ \yquant@register@set@style{#1}{#2}%
+}
+
+\protected\long\def\yquant@circuit@addstyle#1#2{%
+ \yquant@circuit@flushwire{#1}%
+ \yquant@register@set@style{#1}{\yquant@register@get@style{#1},#2}%
}
% performs an alignment of all registers specified in the argument; that is, the next operation on any of the listed registers will be after the maximum position of all of them
@@ -393,19 +328,20 @@
\endgroup%
}
-% sets the type of a list of registers
-% #1: arbitrary register list
-% #2: new type
-\protected\def\yquant@circuit@settypes#1#2{%
+% applies an action to wires a list of registers and causes them to be redrawn
+% #1: action
+% #2: arbitrary register list
+% #3: parameter(s)
+\protected\def\yquant@circuit@actonwires#1#2#3{%
\begingroup%
\let\tmp=\empty%
\def\do##1{%
% We do not extend the wire: a register that is discarded somewhere does not make
% sense, only right after some application (which is supposed to already have
% extended the wire appropriately).
- \appto\tmp{\yquant@register@set@type{##1}#2}%
+ \appto\tmp{#1{##1}#3}%
}%
- \dolistloop{#1}%
+ \dolistloop{#2}%
\csxappto{\yquant@prefix draw}{\tmp}%
\endgroup%
}
@@ -434,12 +370,12 @@
{\yquant@circuit@output@do@single{##1}{#3}}%
}%
}%
- % \dolistloop will carry out one \expandafter on the argument; but this expansion step
- % is already done. If #1 starts with \yquant@register@multi, this will be expanded once
- % despite \protected, so insert some expand-to-nothing token first.
\csgappto{\yquant@prefix draw}{%
\yquant@circuit@output@group{#2}%
}
+ % \dolistloop will carry out one \expandafter on the argument; but this expansion step
+ % is already done. If #1 starts with \yquant@register@multi, this will be expanded once
+ % despite \protected, so insert some expand-to-nothing token first.
\dolistloop{\empty#1}%
\csgappto{\yquant@prefix draw}{%
\yquant@circuit@output@endgroup%
@@ -447,7 +383,7 @@
}
\def\yquant@circuit@output@do@multi@@extract#1#2#3#4#5{%
- {#2}{#3}%
+ {#2}{#3}{#5}%
}
\protected\long\def\yquant@circuit@output@group#1{%
@@ -462,15 +398,27 @@
\path
(\yquant@env@end@xpos, \yquant@register@get@y{#1})
node[/yquant/every output,
- /yquant/every \ifcase\yquant@register@get@type{#1} qubit\or cbit\or qubits\fi\space output] {#2};
+ /yquant/every \ifcase\yquant@register@get@type{#1} nobit\or qubit\or cbit\or qubits\fi\space output] {#2};
\numdef\idx{\idx+1}%
}
-\long\def\yquant@circuit@output@do@multi#1#2#3{%
+\long\def\yquant@circuit@output@do@multi#1#2#3#4{%
+ % extremely similar to \yquant@draw@multiinit
+ \@tempdima=-.5\dimexpr\yquant@config@register@sep\relax%
+ \dimdef\yquant@draw@multiinit@@min{\yquant@register@get@y{#1}-\@tempdima}%
+ \dimdef\yquant@draw@multiinit@@max{\yquant@register@get@y{#2}+\@tempdima}%
+ \dimdef\yquant@draw@multiinit@@total{%
+ \yquant@draw@multiinit@@max-\yquant@draw@multiinit@@min%
+ }%
+ \def\pgfdecorationsegmentaspect{0}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@multiinit@contiguous%
+ \let\pgfdecorationsegmentfromto=\empty%
+ #3%
+ \edef\pgfdecorationsegmentfromto{\expandafter\@gobble\pgfdecorationsegmentfromto}%
\path[/yquant/every multi output]
- (\yquant@env@end@xpos, \yquant@register@get@y{#1}) --
- (\yquant@env@end@xpos, \yquant@register@get@y{#2})
- node {#3};%
+ (\yquant@env@end@xpos, \yquant@draw@multiinit@@min) --
+ (\yquant@env@end@xpos, \yquant@draw@multiinit@@max)
+ node {#4};%
\numdef\idx{\idx+1}%
}
% END_FOLD \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
index 2aa1158b05b..c1a74fecb46 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
@@ -1,4 +1,3 @@
-\usetikzlibrary{decorations.pathreplacing}
\pgfdeclaremetadecoration{tikz@internal}{pre}{
\state{pre}[width=\pgfkeysvalueof{/pgf/decoration/pre length}+\pgfkeysvalueof{/pgf/decoration/post length}, next state=main]{
\appto\tikz@dec@shift{\pgftransformxshift{-\pgfkeysvalueof{/pgf/decoration/post length}}}
@@ -15,7 +14,10 @@
}
}
\pgfqkeys{/yquant}{
- every circuit/.style={},
+ every circuit/.style={%
+ every node/.prefix style={transform shape},%
+ every label/.prefix style={transform shape=false}% TODO: no, we don't really want this, but pgf bug #843 requires this if we still want to have `label position` available
+ },
% register settings
register/default name/.store in=%
\yquant@config@register@default@name,
@@ -25,7 +27,7 @@
{\dimdef\yquant@config@register@sep{#1}},
% register label style
every label/.style=%
- {shape=yquant-text, anchor=circuit, align=right},
+ {shape=yquant-text, anchor=center, align=right},
every initial label/.style=%
{anchor=east},
every qubit label/.style=%
@@ -35,8 +37,8 @@
every qubits label/.style=%
{},
every multi label/.style=%
- {shift={(-.075, 0)}, draw, decoration={brace, mirror, pre=moveto, pre length=-1mm, post=moveto, post length=-1mm}, decorate,
- every node/.append style={shape=yquant-text, anchor=east, align=right, midway, shift={(-.025, 0)}}},
+ {shift={(-.075, 0)}, draw, decoration={gapped brace, mirror}, decorate, /yquant/gapped brace/apply shift,
+ every node/.append style={shape=yquant-text, anchor=east, align=right, shift={(-.05, 0)}, pos=-1}},
% output label styles
every output/.style=%
{shape=yquant-text, anchor=west, align=left},
@@ -47,8 +49,8 @@
every qubits output/.style=%
{},
every multi output/.style=%
- {shift={(.075, 0)}, draw, decoration={brace, pre=moveto, pre length=-1mm, post=moveto, post length=-1mm}, decorate,
- every node/.append style={shape=yquant-text, anchor=west, align=left, midway, shift={(.025, 0)}}},
+ {shift={(.075, 0)}, draw, decoration={gapped brace}, decorate, /yquant/gapped brace/apply shift,
+ every node/.append style={shape=yquant-text, anchor=west, align=left, shift={(.05, 0)}, pos=-1}},
% wire style
every wire/.style=%
{draw},
@@ -63,18 +65,26 @@
{\dimdef\yquant@config@operator@sep{#1}},
operator/minimum width/.code=%
{\dimdef\yquant@config@operator@minimum@width{#1}},
+ operator/multi warning/.is if=%
+ yquant@config@operator@multi@warn,
% operator style: control
every control line/.style=%
{draw},
every control/.style=%
- {shape=yquant-circle, anchor=circuit, radius=.5mm},
+ {shape=yquant-circle, anchor=center, radius=.5mm},
every positive control/.style=%
{fill=black},
every negative control/.style=%
{draw},
% operator style: main part
every operator/.style=%
- {anchor=circuit},
+ {anchor=center},
+ operator/multi main/.is if=%
+ yquant@config@operator@multi@main,
+ operator/multi as single/.style=%
+ {/yquant/every multi line/.style=/yquant/every control line},
+ every multi line/.style=%
+ {draw, decoration={snake, amplitude=.25mm, segment length=5pt}, decorate},
% overwriting all styles
this operator/.style=%
{},
@@ -107,17 +117,13 @@
operators/every phase/.style=%
{shape=yquant-circle, radius=.5mm, fill},
operators/every zz/.style=%
- % y radius must be twice as large as x radius (= two circles). And there is no
- % possiblity to distort the circle to an ellipse; x radius is always the defining
- % property!
- {shape=yquant-zz, x radius=.5mm, y radius=1mm, fill, draw},
+ {shape=yquant-circle, radius=.5mm, fill},
operators/every xx/.style=%
- % same as zz
- {shape=yquant-xx, x radius=.75mm, y radius=1.5mm, draw},
+ {shape=yquant-rectangle, radius=.75mm, draw},
operators/every slash/.style=%
{shape=yquant-slash, x radius=.5mm, y radius=.7mm, draw},
operators/every swap/.style=%
- {shape=yquant-swap, x radius=.75mm, y radius=1.5mm, draw},
+ {shape=yquant-swap, radius=.75mm, draw},
operators/every not/.style=%
{shape=yquant-oplus, radius=1.3mm, draw},
operators/every measure/.style=%
@@ -127,8 +133,13 @@
operators/every dmeter/.style=%
{shape=yquant-dmeter, x radius=2mm, y radius=2mm, draw},
operators/every barrier/.style=%
- {shape=yquant-barrier, dashed, draw},
- operators/multi operator line/.is if=\yquant@config@multi@line,
+ {shape=yquant-line, dashed, draw},
+ operators/every wave/.style=%
+ {shape=yquant-circle, radius=.5mm, fill},
+ /pgf/decoration/from to/.store in=\pgfdecorationsegmentfromto,
+ gapped brace/apply shift/.code={%
+ \let\tikz@timer@line=\yquant@gappedbrace@timer%
+ },
}
\def\yquant@config@register@default@name{\regidx}
@@ -136,5 +147,142 @@
\def\yquant@config@register@sep{1mm}
\def\yquant@config@operator@sep{1mm}
\def\yquant@config@operator@minimum@width{5mm}
-\newif\ifyquant@config@multi@line
-\yquant@config@multi@linetrue \ No newline at end of file
+\newif\ifyquant@config@operator@multi@main%
+\yquant@config@operator@multi@maintrue
+\newif\ifyquant@config@operator@multi@warn
+\yquant@config@operator@multi@warntrue
+\def\pgfdecorationsegmentfromto{0-1}%
+
+\protected\def\yquant@gappedbrace@extract#1-#2\yquant@sep{%
+ \dimdef\from{#1\pgfdecoratedremainingdistance}%
+ \dimdef\to{#2\pgfdecoratedremainingdistance}%
+}
+% This function is set to replace the transformation that changes the fraction value specified in the node property pos by a computation of the correct value for the gappedbrace decoration. It thus requires \pgfdecorationsegmentfromto to be already set up properly. Only if the special position -1 is given, these transformations are applied; else, the default behavior is reproduced (\tikz@timer@line).
+\protected\def\yquant@gappedbrace@timer{%
+ \ifdim\tikz@time pt=-1pt %
+ % first set \pgfdecoratedremainingdistance appropriately
+ \pgfpointdiff\tikz@timer@start\tikz@timer@end%
+ \pgfmathsqrt@{\dimexpr\pgf@x*\pgf@x/65536+\pgf@y*\pgf@y/65536\relax\@gobbletwo}
+ \pgfdecoratedremainingdistance=\pgfmathresult pt %
+ % now perform the transformation
+ \pgf@xc=\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance%
+ \expandafter\forcsvlist\expandafter\yquant@gappedbrace@shiftloop%
+ \expandafter{\pgfdecorationsegmentfromto}%
+ % and finally let us return the desired position, just ignoring \tikz@time...
+ \pgftransformlineattime{\pgfdecorationsegmentaspect}{\tikz@timer@start}{\tikz@timer@end}%
+ \else%
+ \pgftransformlineattime{\tikz@time}{\tikz@timer@start}{\tikz@timer@end}%
+ \fi%
+}
+\def\yquant@gappedbrace@shiftloop#1{%
+ \yquant@gappedbrace@extract#1\yquant@sep%
+ \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance<\from %
+ \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance>\to %
+ % be careful about arch positions at the border
+ \ifdim\dimexpr\to-\from\relax<2\pgfdecorationsegmentamplitude %
+ % The arch is larger than the segment. We do not draw a line to it or an end line and place it in the mid of the segment, even if it is too short (this issues one extra \pgfpathmoveto command, but catching this rare case is not worth the effort).
+ \edef\pgfdecorationsegmentaspect{\pgfmath@tonumber{\dimexpr%
+ .5\dimexpr\from+\to\relax*65536/\pgfdecoratedremainingdistance%
+ \relax}}%
+ \else%
+ % The segment is large enough to cover the whole arch. But maybe we are too close at the border?
+ \ifdim\dimexpr\pgf@xc-\pgfdecorationsegmentamplitude\relax<\from %
+ \pgf@xc=\dimexpr\from+\pgfdecorationsegmentamplitude\relax%
+ \fi%
+ \ifdim\dimexpr\pgf@xc+\pgfdecorationsegmentamplitude\relax>\to %
+ \pgf@xc=\dimexpr\to-\pgfdecorationsegmentamplitude\relax%
+ \fi%
+ \edef\pgfdecorationsegmentaspect{\pgfmath@tonumber{\dimexpr%
+ \dimexpr\pgf@xc*65536/\pgfdecoratedremainingdistance%
+ \relax}}%
+ \fi%
+ \expandafter\expandafter\expandafter\listbreak%
+ \fi%
+ \fi%
+}
+\def\yquant@gappedbrace@loop#1{%
+ \yquant@gappedbrace@extract#1\yquant@sep%
+ \unless\ifdim\from=0pt %
+ \pgfpathmoveto{%
+ \pgfqpoint{\from}{.5\pgfdecorationsegmentamplitude}%
+ }%
+ \fi%
+ \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance<\from %
+ \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance>\to %
+ % be careful about arch positions at the border
+ \ifdim\dimexpr\to-\from\relax<2\pgfdecorationsegmentamplitude %
+ % The arch is larger than the segment. We do not draw a line to it or an end line and place it in the mid of the segment, even if it is too short (this issues one extra \pgfpathmoveto command, but catching this rare case is not worth the effort).
+ \pgfpathmoveto{%
+ \pgfqpoint{\dimexpr.5\dimexpr\from+\to\relax-\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }%
+ \edef\to{\the\pgfdecoratedremainingdistance}% to prevent the final line, we do not need "to" any more
+ \else%
+ % The segment is large enough to cover the whole arch. But maybe we are too close at the border?
+ \ifdim\dimexpr\pgf@xc-\pgfdecorationsegmentamplitude\relax<\from %
+ \pgf@xc=\dimexpr\from+\pgfdecorationsegmentamplitude\relax%
+ \fi%
+ \ifdim\dimexpr\pgf@xc+\pgfdecorationsegmentamplitude\relax>\to %
+ \pgf@xc=\dimexpr\to-\pgfdecorationsegmentamplitude\relax%
+ \fi%
+ % Both cases can't occur at the same time in this \else clause.
+ \pgfpathlineto{%
+ \pgfqpoint{\dimexpr\pgf@xc-\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }%
+ \fi%
+ \pgfpathcurveto{%
+ \pgfqpoint{\dimexpr\pgf@xc-.5\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\dimexpr\pgf@xc-.15\pgfdecorationsegmentamplitude\relax}%
+ {.7\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\pgf@xc}{\pgfdecorationsegmentamplitude}%
+ }%
+ \pgfpathcurveto{%
+ \pgfqpoint{\dimexpr\pgf@xc+.15\pgfdecorationsegmentamplitude\relax}%
+ {.7\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\dimexpr\pgf@xc+.5\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\dimexpr\pgf@xc+\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }%
+ \fi%
+ \fi%
+ \unless\ifdim\to=\pgfdecoratedremainingdistance %
+ \pgfpathlineto{%
+ \pgfqpoint{\to}{.5\pgfdecorationsegmentamplitude}%
+ }%
+ \fi%
+}
+% This is a variant of the brace in pathreplacing that allows for holes
+\pgfdeclaredecoration{gapped brace}{final}{%
+ \state{final}{%
+ \pgf@xc=\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance%
+ \pgfpathcurveto{%
+ \pgfqpoint{.15\pgfdecorationsegmentamplitude}{.3\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{.5\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}%
+ }%
+ \expandafter\forcsvlist\expandafter\yquant@gappedbrace@loop%
+ \expandafter{\pgfdecorationsegmentfromto}%
+ \pgfpathlineto{%
+ \pgfqpoint{\dimexpr\pgfdecoratedremainingdistance-\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }%
+ \pgfpathcurveto{%
+ \pgfqpoint{\dimexpr\pgfdecoratedremainingdistance-.5\pgfdecorationsegmentamplitude\relax}%
+ {.5\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\dimexpr\pgfdecoratedremainingdistance-.15\pgfdecorationsegmentamplitude\relax}%
+ {.3\pgfdecorationsegmentamplitude}%
+ }{%
+ \pgfqpoint{\pgfdecoratedremainingdistance}{0pt}%
+ }%
+ }%
+}% \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
index baaac6ac0d2..c89eb3ef984 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
@@ -11,6 +11,8 @@
\fi%
\let\yquant@circuit@extendcontrolline@cmd=\empty%
\let\yquant@circuit@extendcontrolline@prev=\relax%
+ \let\yquant@circuit@extendcontrolline@clip=\empty%
+ \let\yquant@circuit@extendmultiline@total=\empty%
\yquant@langhelper@list@attrs%
% If the quotes library is loaded, activate it. (else, this is by default \relax)
\tikz@enable@node@quotes%
@@ -47,6 +49,7 @@
\yquant@draw@alias@ctrl{#2}p%
\yquant@draw@alias@ctrl{#2}n%
\fi%
+ \yquant@circuit@extendmultiline@total%
\endgroup%
}
@@ -57,86 +60,162 @@
node[/yquant/every operator, \yquant@draw@@style, /yquant/this operator,%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ /yquant/this operator}%
}%
\cmd%
- \ifpgfpointshapexproj{yquantbox}%
- \yquant@circuit@extendwire{#1}%
- \fi%
- \yquant@circuit@extendcontrolline\yquant@draw@@currentcontroltype\yquant@draw@@x%
+ \yquant@circuit@extendwire{#1}%
+ \expandafter\yquant@circuit@extendcontrolline\expandafter%
+ {\the\yquant@draw@@currentcontroltype}\yquant@draw@@x%
% check for empty name parameter
- \if\relax\detokenize{#2}\relax%
- \else%
+ \ifstrempty{#2}\relax{%
\pgfnodealias{\tikz@pp@name{#2}}{yquantbox}%
- \fi%
+ }%
\numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
}
-\protected\long\def\yquant@draw@multi#1#2#3#4#5{%
+\protected\def\yquant@draw@multi#1#2#3#4#5{%
\let\idx=\yquant@draw@@idx@content%
+ \edef\yquant@draw@multi@@name{#5}%
+ \def\yquant@draw@@idx@multipart{0}%
+ \let\yquant@circuit@extendmultiline@cmd=\empty%
+ \let\yquant@circuit@extendmultiline@prev=\relax%
+ \let\yquant@circuit@extendmultiline@clip=\empty%
+ \let\yquant@register@multi@contiguous=\yquant@draw@multi@contiguous%
+ #4%
+ \ifnum\yquant@draw@@idx@multipart>1 %
+ % make sure also the first split part is available via the "-s0" suffix
+ \unless\ifx\yquant@draw@multi@@name\empty%
+ \pgfnodealias{\tikz@pp@name{\yquant@draw@multi@@name-s0}}%
+ {\tikz@pp@name{\yquant@draw@multi@@name}}%
+ \fi%
+ \yquant@draw@mline@prep%
+ \fi%
+ \numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
+}
+
+\protected\def\yquant@draw@multi@contiguous#1#2#3{%
% We need to somehow extract the y radius
\edef\cmd{%
\noexpand\path (\yquant@draw@@x, \the\dimexpr.5\dimexpr%
\yquant@register@get@y{#1}+\yquant@register@get@y{#2}\relax%
\relax)%
node[/yquant/every operator, \yquant@draw@@style, /yquant/this operator,%
+ /yquant/operator/multi main=\ifnum#3=1 true\else false\fi\unless\ifnum#1=#2 ,%
y radius/.expanded=\the\dimexpr.5\dimexpr\yquant@register@get@ydist{#1}{#2}\relax\relax+%
- .5*\noexpand\pgfkeysvalueof{/tikz/y radius},%
+ .5*\noexpand\pgfkeysvalueof{/tikz/y radius}\fi,%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ /yquant/this operator}%
}%
\cmd%
- \ifpgfpointshapexproj{yquantbox}%
- \let\do=\yquant@circuit@extendwire%
- \dolistloop{#4}%
- \fi%
- \yquant@circuit@extendcontrolline\yquant@draw@@currentcontroltype\yquant@draw@@x%
- % check for empty name parameter
- \if\relax\detokenize{#5}\relax%
- \else%
- \pgfnodealias{\tikz@pp@name{#5}}{yquantbox}%
+ \yquant@for \i := #1 to #2 {%
+ \yquant@circuit@extendwire\i%
+ }%
+ \yquant@circuit@extendmultiline\yquant@draw@@x%
+ \expandafter\yquant@circuit@extendcontrolline\expandafter%
+ {\the\yquant@draw@@currentcontroltype}\yquant@draw@@x%
+ \unless\ifx\yquant@draw@multi@@name\empty%
+ \ifnum\yquant@draw@@idx@multipart=0 %
+ \pgfnodealias{\tikz@pp@name{\yquant@draw@multi@@name}}{yquantbox}%
+ \else%
+ \pgfnodealias{\tikz@pp@name{\yquant@draw@multi@@name-s\yquant@draw@@idx@multipart}}{yquantbox}%
+ \fi%
\fi%
- \numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
+ \numdef\yquant@draw@@idx@multipart{\yquant@draw@@idx@multipart+1}%
}
-\protected\long\def\yquant@draw@multiinit#1#2#3#4#5{%
+\protected\def\yquant@draw@multiinit#1#2#3#4#5{%
\let\idx=\yquant@draw@@idx@content%
+ \@tempdima=-.5\dimexpr\yquant@config@register@sep\relax%
+ \dimdef\yquant@draw@multiinit@@min{\yquant@register@get@y{#1}-\@tempdima}%
+ \dimdef\yquant@draw@multiinit@@max{\yquant@register@get@y{#2}+\@tempdima}%
+ \dimdef\yquant@draw@multiinit@@total{%
+ \yquant@draw@multiinit@@max-\yquant@draw@multiinit@@min%
+ }%
+ \def\pgfdecorationsegmentaspect{0}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@multiinit@contiguous%
+ \let\pgfdecorationsegmentfromto=\empty%
+ #4%
+ \edef\pgfdecorationsegmentfromto{\expandafter\@gobble\pgfdecorationsegmentfromto}%
% We need to somehow extract the y radius
\edef\cmd{%
\noexpand\path[/yquant/every operator, \yquant@draw@@style,%
/yquant/every multi label, /yquant/this operator]%
- (\yquant@draw@@x, \yquant@register@get@y{#1}) --%
- (\yquant@draw@@x, \yquant@register@get@y{#2})%
+ (\yquant@draw@@x, \yquant@draw@multiinit@@min) --%
+ (\yquant@draw@@x, \yquant@draw@multiinit@@max)%
node[name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};
}%
\cmd%
- % no wire extension (we are still at the initial position), no control line (init doesn't allow for those, so just save the no-op)
+ % no wire extension (we are still at the initial position), no control line (init doesn't allow for those, so just save the no-op), no multi line
% check for empty name parameter
- \if\relax\detokenize{#5}\relax%
- \else%
+ \ifstrempty{#5}\relax{%
\pgfnodealias{\tikz@pp@name{#5}}{yquantbox}%
- \fi%
+ }%
\numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
}
+\protected\def\yquant@draw@multiinit@contiguous#1#2#3{%
+ \edef\yquant@draw@multiinit@@from{%
+ \pgfmath@tonumber{\dimexpr%
+ \dimexpr\yquant@register@get@y{#1}-\@tempdima-\yquant@draw@multiinit@@min\relax*65536/%
+ \dimexpr\yquant@draw@multiinit@@total\relax%
+ \relax}%
+ }%
+ \edef\yquant@draw@multiinit@@to{%
+ \pgfmath@tonumber{\dimexpr%
+ \dimexpr\yquant@register@get@y{#2}+\@tempdima-\yquant@draw@multiinit@@min\relax*65536/%
+ \dimexpr\yquant@draw@multiinit@@total\relax%
+ \relax}%
+ }%
+ \eappto\pgfdecorationsegmentfromto{,%
+ \yquant@draw@multiinit@@from-\yquant@draw@multiinit@@to%
+ }%
+ % We need to decide where to put the brace arch.
+ \ifdim\yquant@draw@multiinit@@from pt<.5pt %
+ \ifdim\yquant@draw@multiinit@@to pt>.5 pt%
+ % This segment covers the true 1/2 position, take it
+ \def\pgfdecorationsegmentaspect{.5}%
+ \else%
+ % We are not there yet, so the end of this segment is the closest we can get to the mid so far
+ \edef\pgfdecorationsegmentaspect{\yquant@draw@multiinit@@to}%
+ \fi%
+ \else%
+ % We are already beyond the mid...
+ \ifdim\pgfdecorationsegmentaspect pt<.5pt %
+ % ...but we did not find an ideal position yet
+ \ifdim\dimexpr\yquant@draw@multiinit@@from pt-.5pt\relax<%
+ \dimexpr.5pt-\pgfdecorationsegmentaspect pt\relax%
+ % this one is closer to the mid than anything found before
+ \edef\pgfdecorationsegmentaspect{\yquant@draw@multiinit@from}%
+ \fi%
+ \fi%
+ \fi%
+}
+
\protected\def\yquant@draw@control#1#2#3{%
\edef\cmd{%
\noexpand\path (\yquant@draw@@x, \yquant@register@get@y{#2})%
node[/yquant/every control, /yquant/every #1 control, /yquant/this control,%
name prefix=, name suffix=, name=yquantbox]%
{};%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every control, /yquant/every #1 control,%
+ /yquant/this control}%
}%
\cmd%
- \ifpgfpointshapexproj{yquantbox}%
- \yquant@circuit@extendwire{#2}%
- \fi%
+ \yquant@circuit@extendwire{#2}%
\yquant@draw@@currentcontroltype=\yquant@register@get@type{#2}\relax%
- \yquant@circuit@extendcontrolline\yquant@draw@@currentcontroltype\yquant@draw@@x%
+ \expandafter\yquant@circuit@extendcontrolline\expandafter%
+ {\yquant@draw@@currentcontroltype}\yquant@draw@@x%
% check for empty name parameter
- \if\relax\detokenize{#3}\relax%
- \else%
+ \ifstrempty{#3}\relax{%
\pgfnodealias{\tikz@pp@name{#3}}{yquantbox}%
- \fi%
+ }%
}
\protected\def\yquant@draw@pcontrol#1#2{%
@@ -152,11 +231,62 @@
}
\protected\def\yquant@draw@cline{%
- \edef\cmd{%
- \noexpand\path[/yquant/every control line]%
- \yquant@circuit@extendcontrolline@cmd;
+ \pgfscope%
+ % install the clipping
+ \pgfsyssoftpath@setcurrentpath\yquant@circuit@extendcontrolline@clip%
+ % and invert it. It is sufficient to cover the current bounding box, as the wire will be drawn between existing operators.
+ \ifyquantdebug%
+ \pgfsetfillcolor{teal}%
+ \pgfsetfillopacity{.3}%
+ \pgfusepathqfill%
+ \else%
+ \begingroup%
+ \pgftransformreset%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
+ {\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
+ \endgroup%
+ \fi%
+ \edef\cmd{%
+ \noexpand\path[/yquant/every control line]%
+ \yquant@circuit@extendcontrolline@cmd;
+ }%
+ \cmd%
+ \endpgfscope%
+}
+
+\protected\def\yquant@draw@mline@prep{%
+ \eappto\yquant@circuit@extendmultiline@total{%
+ \yquant@draw@mline%
+ {\unexpanded\expandafter{\yquant@circuit@extendmultiline@clip}}%
+ {\yquant@circuit@extendmultiline@cmd}%
}%
- \cmd%
+}
+
+\protected\def\yquant@draw@mline#1#2{%
+ \pgfscope%
+ % install the clipping
+ \def\pgfsyssoftpath@thepath{#1}%
+ \pgfsyssoftpath@setcurrentpath\pgfsyssoftpath@thepath%
+ % and invert it. It is sufficient to cover the current bounding box, as the wire will be drawn between existing operators.
+ \ifyquantdebug%
+ \pgfsetfillcolor{teal}%
+ \pgfsetfillopacity{.3}%
+ \pgfusepathqfill%
+ \else%
+ \begingroup%
+ \pgftransformreset%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
+ {\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
+ \endgroup%
+ \fi%
+ \path[/yquant/every multi line] #2;
+ \endpgfscope%
}
\protected\def\yquant@draw@alias#1{%
@@ -166,6 +296,106 @@
\protected\def\yquant@draw@alias@ctrl#1#2{%
\pgfnodealias{\tikz@pp@name{#1-#2}}{\tikz@pp@name{#1-#20}}%
}
+
+\protected\def\yquant@draw@wire#1#2{%
+ \begingroup%
+ \yquant@register@get@typeywire{#1}\wiretype\wireypos\wirelast%
+ \edef\wirexprevpos{\expandafter\@firstoffour\wirelast}%
+ \ifx\yquant@env@end@xpos#2\relax%
+ \let\wirexpos=\yquant@env@end@xpos%
+ \else%
+ \edef\wirexpos{\expandafter\@secondoffour\wirelast}%
+ \fi%
+ \unless\ifnum\wiretype=\yquant@register@type@none%
+ \ifdim\wirexpos>\wirexprevpos %
+ \edef\wirestyle{\noexpand\tikzset{%
+ /yquant/this wire/.style={%
+ /yquant/every wire,%
+ /yquant/every \ifcase\wiretype\relax nobit\or qubit \or cbit \or qubits \fi wire,%
+ \yquant@register@get@style{#1}%
+ }, /yquant/this wire%
+ }}%
+ \wirestyle%
+ % load all clippings
+ \edef\wireclipping{%
+ \unexpanded\expandafter\expandafter\expandafter{%
+ \expandafter\@thirdandfourthoffour\wirelast%
+ }%
+ }%
+ \pgfscope%
+ % install the clipping
+ \pgfsyssoftpath@setcurrentpath\wireclipping%
+ % invert the clipping
+ \ifyquantdebug%
+ \pgfsetfillcolor{orange}%
+ \pgfsetfillopacity{.3}%
+ \pgfusepathqfill%
+ \else%
+ % We need to access the current bounding box as well as other positions in the local coordinate frame. For this, transform the bounding box to the current frame (though this is expensive). Does this capture rotations correctly?
+ \begingroup%
+ \pgftransforminvert%
+ \pgfpointtransformednonlinear{\pgfqpoint{\pgf@picminx}{\pgf@picminy}}
+ \global\@tempdima=\pgf@y%
+ \pgfpointtransformednonlinear{\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \global\@tempdimb=\pgf@y%
+ \endgroup%
+ % To avoid rendering artifacts at all zoom levels with all renderers, we need to make the clipping region large. Let's try the current bounding box first.
+ % This may be insufficient if there no or a tiny wire label and only registers of a small height. In this case, take at ten times the line width or at least 1cm, but don't let it affect the bounding box.
+ \ifdim\dimexpr\@tempdimb-\@tempdima\relax<10\pgflinewidth %
+ \@tempdima=\dimexpr\wireypos-5\pgflinewidth\relax%
+ \@tempdimb=\dimexpr\wireypos+5\pgflinewidth\relax%
+ \fi%
+ \ifdim\dimexpr\@tempdimb-\@tempdima\relax<1cm %
+ \@tempdima=\dimexpr\wireypos-5mm\relax%
+ \@tempdimb=\dimexpr\wireypos+5mm\relax%
+ \fi%
+ \pgfinterruptboundingbox%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\dimexpr\wirexprevpos-2\pgflinewidth\relax}%
+ {\@tempdima}}%
+ {\pgfqpoint{\dimexpr\wirexpos+2\pgflinewidth\relax}%
+ {\@tempdimb}}%
+ \endpgfinterruptboundingbox%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
+ \fi%
+ % the clip inversion is left to the drawing commands (clip two \pgflinewidth more to avoid renderer artifacts)
+ \csname yquant@draw@wire@\wiretype\endcsname{#1}%
+ \endpgfscope%
+ \fi%
+ \fi%
+ \endgroup%
+}
+
+% quantum wire
+\protected\csdef{yquant@draw@wire@\yquant@register@type@q}#1{%
+ \edef\cmd{%
+ \noexpand\path [/yquant/this wire]
+ (\wirexprevpos,\wireypos) -- (\wirexpos,\wireypos);%
+ }%
+ \cmd%
+}
+
+% classical wire
+\protected\csdef{yquant@draw@wire@\yquant@register@type@c}#1{%
+ \edef\cmd{%
+ \noexpand\path [/yquant/this wire]
+ (\wirexprevpos,\wireypos+2\pgflinewidth)--(\wirexpos,\wireypos+2\pgflinewidth)%
+ (\wirexprevpos,\wireypos-2\pgflinewidth)--(\wirexpos,\wireypos-2\pgflinewidth);%
+ }%
+ \cmd%
+}
+
+% quantum-bundle
+\protected\csdef{yquant@draw@wire@\yquant@register@type@qs}#1{%
+ \edef\cmd{%
+ \noexpand\path [/yquant/this wire]
+ (\wirexprevpos,\wireypos+2\pgflinewidth)--(\wirexpos,\wireypos+2\pgflinewidth)%
+ (\wirexprevpos,\wireypos)--(\wirexpos,\wireypos)%
+ (\wirexprevpos,\wireypos-2\pgflinewidth)--(\wirexpos,\wireypos-2\pgflinewidth);%
+ }%
+ \cmd%
+}
% END_FOLD
% BEGIN_FOLD Preparation of drawing a generic shape
@@ -274,7 +504,7 @@
\advance \dimen2 by \yquant@circuit@operator@x\relax%
% BEGIN_FOLD shipout
\ifyquant@circuit@operator@hasControls%
- % If we draw a control line, all intermediate registers are affected in their position so that the line is never crossed.
+ % If we draw a control line, all intermediate registers are affected in their position so that the line is never crossed. If the vertical line is instead caused by a multi register, \yquant@draw@finalize@ctrl will be responsible for advancing only the affected positions.
\yquant@for \yquant@i := \yquant@circuit@operator@minctrl to \yquant@circuit@operator@maxctrl {%
\yquant@register@set@x\yquant@i{\the\dimen2}%
}%
@@ -354,14 +584,39 @@
#3%
{\nodename}%
}%
- % Determining the actual height is a problem - where to store its value? We just assume that there is always enough space for such a control, since it anyway already spans multiple registers. (TODO?)
+ % Determining the actual height is a problem - where to store its value? If there are single-register parts, we update the height accordingly; else we just assume that there is always enough space for such a control, since it anyways already spans multiple registers. (TODO?)
\pgfinterruptboundingbox%
\yquant@env@virtualize@path%
- % Here, we just set a dummy height, as we don't know the actual height yet. As the width of most/all shapes should not depend on their height, it does not matter.
- \path%
- (0pt, 0pt)
- node[/yquant/every operator, #2, /yquant/this operator, y radius=1cm,%
- name prefix=, name suffix=0, name=] {#1};
+ \def\yquant@draw@@content{#1}%
+ \def\yquant@draw@@style{#2}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@@multi@contiguous%
+ \@fifthoffive#3%
+ \ifdim\pgf@picmaxy=-16000pt %
+ % if there was no single contiguous part before, determine the width now
+ \path%
+ (0pt, 0pt)
+ node[/yquant/every operator, #2, /yquant/this operator,%
+ name prefix=, name suffix=, name=] {#1};
+ \fi%
+}
+
+\protected\def\yquant@draw@@multi@contiguous#1#2#3{%
+ \ifnum#1=#2 %
+ % we only care about single-register parts
+ \global\pgf@picmaxy=-16000pt %
+ \global\pgf@picminy=16000pt %
+ \edef\cmd{%
+ \noexpand\path (0pt, 0pt)%
+ node[/yquant/every operator, \yquant@draw@@style, /yquant/this operator,%
+ /yquant/operator/multi main=\ifnum#3=1 true\else false\fi,
+ name prefix=, name suffix=, name=]%
+ {\unexpanded\expandafter{\yquant@draw@@content}};
+ }%
+ \cmd%
+ \yquant@register@update@height{#1}{%
+ \the\dimexpr\pgf@picmaxy-\pgf@picminy\relax%
+ }%
+ \fi%
}
\protected\def\yquant@draw@@multiinit#1#2#3{%
@@ -373,11 +628,10 @@
% Determining the actual height is a problem - where to store its value? We just assume that there is always enough space for such a control, since it anyway already spans multiple registers. (TODO?)
\pgfinterruptboundingbox%
\yquant@env@virtualize@path%
- % Here, we just set a dummy height, as we don't know the actual height yet. As the width of most/all shapes should not depend on their height, it does not matter.
\path%
(0pt, 0pt)
- node[/yquant/every operator, #2, /yquant/every multi label, y radius=1cm,%
- name prefix=, name suffix=0, name=] {#1};
+ node[/yquant/every operator, #2, /yquant/every multi label,%
+ name prefix=, name suffix=, name=] {#1};
}
\def\yquant@draw@finalize@ctrl#1{%
@@ -401,6 +655,12 @@
}%
}
+\protected\def\yquant@draw@finalize@ctrl@singleinit#1#2{%
+ \eappto\yquant@draw@append{%
+ \yquant@draw@callback@wire{#1}%
+ }%
+}
+
\protected\def\yquant@draw@finalize@ctrl@multi#1#2#3#4#5{%
\unless\ifyquant@circuit@operator@hasControls{%
% \yquant@for uses \loop...\repeat and hence redefines \body, which would destroy an outer loop.
@@ -410,13 +670,57 @@
}%
}\fi%
% this is called from a do loop itself, so preserve \do (but do not enter grouping)
- \let\yquant@draw@update@x@multi@@olddo=\do%
- \def\do##1{%
- \eappto\yquant@draw@append{%
- \yquant@draw@callback@wire{##1}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@finalize@ctrl@multi@contiguous%
+ \ifyquant@circuit@operator@hasControls%
+ \ifyquant@config@operator@multi@warn%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{0}%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \cslet{\yquant@prefix finalize@ctrl@draw@appto}\empty%
+ #4%
+ \eappto\yquant@draw@append{\csname\yquant@prefix finalize@ctrl@draw@appto\endcsname}%
+ \csgundef{\yquant@prefix finalize@ctrl@draw@appto}%
+}
+
+\protected\def\yquant@draw@finalize@ctrl@multiinit#1#2#3#4#5{%
+ % this is called from a do loop itself, so preserve \do (but do not enter grouping)
+ \let\yquant@register@multi@contiguous=\yquant@draw@finalize@ctrl@multi@contiguous%
+ \ifyquant@circuit@operator@hasControls%
+ \ifyquant@config@operator@multi@warn%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{0}%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \cslet{\yquant@prefix finalize@ctrl@draw@appto}\empty%
+ #4%
+ \eappto\yquant@draw@append{\csname\yquant@prefix finalize@ctrl@draw@appto\endcsname}%
+ \csgundef{\yquant@prefix finalize@ctrl@draw@appto}%
+}
+
+\protected\def\yquant@draw@finalize@ctrl@multi@contiguous#1#2#3{%
+ \ifnum\yquant@draw@finalize@ctrl@multi@contiguous@warn=1 %
+ \PackageWarning{yquant.sty}{Ambiguous operation: multiple discontiguous multi-register operations in combination with controls make it hard to visually determine on which registers the gates act on.}%
+ % switch the warning off for this group (which is a single operation)
+ \yquant@config@operator@multi@warnfalse%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \else%
+ \numdef\yquant@draw@finalize@ctrl@multi@contiguous@warn{%
+ \yquant@draw@finalize@ctrl@multi@contiguous@warn+1%
}%
+ \fi%
+ {% save \body
+ \yquant@for \yquant@i := #1 to #2 {{% let inner loop mess up with macros
+ \csxappto{\yquant@prefix finalize@ctrl@draw@appto}{%
+ \expandafter\yquant@draw@callback@wire\expandafter{\yquant@i}%
+ }%
+ }}%
}%
- \dolistloop{#4}%
- \let\do=\yquant@draw@update@x@multi@@olddo%
}
% END_FOLD \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-env.tex b/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
index 9ba97f5915d..16c3598af38 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
@@ -49,7 +49,6 @@
\let\yquant=\yquant@env@scan%
\yquant@lang@reset@attrs%
\csgdef{\yquant@prefix registers}{0}%
-% \csgdef{\yquant@prefix lasty}{0pt}%
\global\cslet{\yquant@prefix draw}\relax%
\global\cslet{\yquant@prefix outputs}\relax%
\csxdef{\yquant@prefix cleanup}{%
@@ -61,7 +60,7 @@
\ifnum\yquant@env=1 %
\yquant@env@substikz%
\fi%
- \scope[{/yquant/.cd, every circuit, #1}]%
+ \scope[{/yquant/.cd, #1, /tikz/.cd, /yquant/every circuit}]%
}
\newif\ifyquantdebug
\protected\def\yquant@env@end{%
@@ -74,16 +73,13 @@
\def\noexpand\yquant@env@end@xpos{%
\the\dimexpr\yquant@env@end@xpos+\yquant@config@operator@sep\relax%
}%
+ \yquant@circuit@endwires{\yquant@env@end@registers}%
}
% also calculate the true y positions
\dimen0=0pt %
\dimen2=0pt %
\dimen4=\yquant@config@register@sep %
\yquant@for \i := 1 to \yquant@env@end@registers {%
- % add a final wire
- \csxappto{\yquant@prefix draw}{%
- \yquant@circuit@endwire{\i}%
- }%
% we do not care if the wire is present for the y position
\dimen2=.5\dimexpr\yquant@register@get@height\i\relax%
\advance\dimen0 by \dimen2\relax%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex b/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
index b88503beb1a..b250f788276 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
@@ -68,25 +68,25 @@
}
\def\yquant@lang@create@parse@name#1[#2;{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\yquant@lang@create@do#1[1][;%
- \else%
+ }{%
\yquant@lang@create@do#1[#2;%
- \fi%
+ }%
}
\protected\def\yquant@lang@create@do#1[#2]#3[;{%
% parse length
- \if\relax\detokenize{#3}\relax%
+ \ifstrempty{#3}{%
\yquant@langhelper@validate\len\count{#2}%
\ifnum\len<1 %
\PackageError{yquant.sty}{Invalid register length}%
{Valid register lengths are integers greater or equal to one.}%
\fi
- \else%
+ }{%
\PackageError{yquant.sty}{Invalid register name}%
{Register names must not contain `[' apart from register length indication.}%
- \fi%
+ }%
\edef\reg{\trim@spaces{#1}}%
% we allow for scattering, so check whether the register already exists
\ifcsname\yquant@prefix registerhigh@\reg\endcsname%
@@ -157,47 +157,25 @@
\protected\def\yquant@lang@create@draw#1#2#3#4#5{%
\begingroup%
\dimdef\wireypos{\yquant@register@get@y{#1}}%
- \if\relax\detokenize{#4}\relax%
+ \ifstrempty{#4}{%
% For empty labels, we still put the node at the appropriate position as it may needs to be referenced, but we will not let it effect the bounding box (so that the left end is not shifted), and we don't need an inner separation, so that the label is truely just a coordinate.
\path[overlay]
(#2, \wireypos)%
coordinate[name prefix=, name suffix=, name=yquantbox];
- \else%
+ }{%
\path
(#2, \wireypos)%
node[/yquant/every label, /yquant/every initial label,%
/yquant/every #3 label, name prefix=, name suffix=, name=yquantbox]%
{#4};%
- \fi%
+ }%
% set the wire style to have the correct \pgflinewidth available (we don't allow individual line widths for different types of wires)
\tikzset{/yquant/every wire}%
\pgfpointanchor{yquantbox}{east}%
- % Every label shape should implement the projection anchor, else we just guess the values, but this might be inaccurate for non-rectangular shapes
- \ifpgfpointshapexproj{yquantbox}%
- \@tempdima=\pgf@x%
- \pgfpointshapexproj{yquantbox}%
- {\pgfqpoint{\@tempdima}
- {\dimexpr\wireypos+2\pgflinewidth\relax}}%
- \edef\tmp{{(\the\pgf@x,\the\pgf@y)}}%
- % This projection should normally not be necessary, as the east anchor _should_ be accurate - but who knows?
- \pgfpointshapexproj{yquantbox}{\pgfqpoint{\@tempdima}{\wireypos}}%
- \edef\tmp{\tmp{(\the\pgf@x,\the\pgf@y)}}%
- \pgfpointshapexproj{yquantbox}
- {\pgfqpoint{\@tempdima}%
- {\dimexpr\wireypos-2\pgflinewidth\relax}}%
- \yquant@register@set@lastwire{#1}{\tmp{(\the\pgf@x,\the\pgf@y)}}%
- \else%
- % Just guess the values.
- \yquant@register@set@lastwire{#1}{%
- {(\the\pgf@x,\the\dimexpr\wireypos+2\pgflinewidth\relax)}%
- {(\the\pgf@x,\wireypos)}%
- {(\the\pgf@x,\the\dimexpr\wireypos-2\pgflinewidth\relax)}%
- }%
- \fi%
- \if\relax\detokenize{#5}\relax%
- \else%
+ \yquant@register@set@lastwire{#1}{{\the\pgf@x}{\the\pgf@x}{}{}}%
+ \ifstrempty{#5}\relax{%
\pgfnodealias{\tikz@pp@name{#5}}{yquantbox}%
- \fi%
+ }%
\endgroup%
}
% END_FOLD
@@ -289,21 +267,18 @@
% two-qubit controlled x (symmetric notation)
\yquant@langhelper@declare@command{xx}\yquant@lang@@xx
\yquant@langhelper@setup@attrs{xx}{}{}
-\def\yquant@lang@@xx#1#2#3{%
- \yquant@register@get@allowmultitrue%
- \yquant@circuit@operator{#1}{#2}{#3}%
- \ifyquant@circuit@operator@hasControls%
- \yquant@draw@{}{/yquant/operators/every xx, /yquant/operator/multi operator line=false}%
- \else%
- \yquant@draw@{}{/yquant/operators/every xx}%
- \fi%
+\def\yquant@lang@@xx{%
+ \yquant@register@get@multiassingle%
+ \yquant@draw%
+ {}%
+ {/yquant/operators/every xx}%
}
% two-qubit controlled phase (symmetric notation)
\yquant@langhelper@declare@command@uncontrolled{zz}\yquant@lang@@zz
\yquant@langhelper@setup@attrs{zz}{}{}
\def\yquant@lang@@zz{%
- \yquant@register@get@allowmultitrue%
+ \yquant@register@get@multiassingle%
\yquant@draw%
{}%
{/yquant/operators/every zz}%
@@ -333,14 +308,11 @@
% swap
\yquant@langhelper@declare@command{swap}\yquant@lang@@swap
\yquant@langhelper@setup@attrs{swap}{}{}
-\def\yquant@lang@@swap#1#2#3{%
- \yquant@register@get@allowmultitrue%
- \yquant@circuit@operator{#1}{#2}{#3}%
- \ifyquant@circuit@operator@hasControls%
- \yquant@draw@{}{/yquant/operators/every swap, /yquant/operator/multi operator line=false}%
- \else%
- \yquant@draw@{}{/yquant/operators/every swap}%
- \fi%
+\def\yquant@lang@@swap{%
+ \yquant@register@get@multiassingle%
+ \yquant@draw%
+ {}%
+ {/yquant/operators/every swap}%
}
% not
@@ -433,6 +405,18 @@
{}{}
}
+\yquant@langhelper@declare@command@uncontrolled{correlate}\yquant@lang@@correlate
+\yquant@langhelper@setup@attrs{correlate}{}{}
+\def\yquant@lang@@correlate{%
+ % do not call \yquant@register@get@multiassingle, we do not want to install a different multi line style!
+ \yquant@register@get@allowmultitrue%
+ \let\yquant@register@multi@splitparts=\yquant@register@multi@splitparts@sepall%
+ \yquant@draw%
+ {}%
+ {/yquant/operators/every wave}%
+ {}{}%
+}
+
\yquant@langhelper@declare@command@uncontrolled{align}\yquant@lang@@align
\yquant@langhelper@setup@attrs{align}{}{}
\def\yquant@lang@@align#1{%
@@ -452,14 +436,24 @@
\yquant@langhelper@setup@attrs{discard}{}{}
\def\yquant@lang@@discard#1{%
\yquant@register@get@ids{#1}%
- \yquant@circuit@settypes\yquant@register@get@ids@list\yquant@register@type@none%
+ \let\yquant@circuit@settype@to=\yquant@register@type@none%
+ \yquant@circuit@actonwires%
+ \yquant@circuit@settype%
+ \yquant@register@get@ids@list%
+ \yquant@register@type@none%
}
\yquant@langhelper@declare@command@uncontrolled{init}\yquant@lang@@init
\yquant@langhelper@setup@attrs{init}{value}{type}
-\def\yquant@lang@@init@multi@@extract#1#2#3#4#5{%
- #5%
+\protected\def\yquant@lang@@init@multi@@extract#1#2#3{%
+ \yquant@for \yquant@i := #1 to #2 {%
+ \edef\yquant@circuit@settype@to{\yquant@register@get@type\yquant@i}%
+ \unless\ifx\yquant@circuit@settype@to\yquant@register@type@none%
+ \expandafter\yquant@for@break%
+ \fi%
+ }%
}
+\long\def\@fifthoffive#1#2#3#4#5{#5}
\protected\def\yquant@lang@@init#1{%
\yquant@register@get@allowmultitrue%
\yquant@register@get@ids{#1}%
@@ -483,13 +477,9 @@
\let\yquant@circuit@settype@to=\yquant@register@type@none%
\def\do##1{%
\ifyquant@firsttoken\yquant@register@multi{##1}{%
- \def\@do####1{%
- \edef\yquant@circuit@settype@to{\yquant@register@get@type{####1}}%
- \unless\ifx\yquant@circuit@settype@to\yquant@register@type@none%
- \expandafter\listbreak%
- \fi%
- }%
- \forlistloop\@do{\yquant@lang@@init@multi@@extract##1}%
+ \let\yquant@register@multi@contiguous=\yquant@lang@@init@multi@@extract%
+ \@fifthoffive##1%
+ % we should reset multi@contiguous to the original command; but this is really just a placeholder. As long as it is \protected, everything is fine.
}{%
\edef\yquant@circuit@settype@to{\yquant@register@get@type{##1}}%
}%
@@ -518,6 +508,8 @@
% special case: if there were no operations at any affected wire before, we will replace the wire description
\ifdim\yquant@circuit@operator@x=\yquant@config@operator@sep\relax%
\def\yquant@circuit@operator@x{-.5\dimen2}%
+ \let\yquant@draw@finalize@ctrl@single=\yquant@draw@finalize@ctrl@singleinit%
+ \let\yquant@draw@finalize@ctrl@multi=\yquant@draw@finalize@ctrl@multiinit%
\expandafter\yquant@draw@%
\expandafter{\yquant@lang@attr@value}%
{/yquant/every label, /yquant/every initial label, /yquant/every \yquant@lang@attr@type\space label}%
@@ -536,9 +528,9 @@
\expandafter\yquant@circuit@output\expandafter{\yquant@register@get@ids@list}%
}
-\yquant@langhelper@declare@command@uncontrolled{setwire}\yquant@lang@@setwire
-\yquant@langhelper@setup@attrs{setwire}{value}{}
-\protected\def\yquant@lang@@setwire#1{%
+\yquant@langhelper@declare@command@uncontrolled{settype}\yquant@lang@@settype
+\yquant@langhelper@setup@attrs{settype}{value}{}
+\protected\def\yquant@lang@@settype#1{%
\yquant@register@get@ids{#1}%
\expandafter\ifstrequal\expandafter{\yquant@lang@attr@value}{qubit}%
{\let\yquant@circuit@settype@to=\yquant@register@type@q}%
@@ -554,6 +546,35 @@
}%
}%
}%
- \yquant@circuit@settypes\yquant@register@get@ids@list\yquant@circuit@settype@to%
+ \yquant@circuit@actonwires%
+ \yquant@circuit@settype%
+ \yquant@register@get@ids@list%
+ {}%
+}
+
+\def\yquant@lang@setwire{%
+ \PackageWarning{yquant.sty}{`setwire' gate is deprecated as of yquant 0.1.2. Use `settype' instead.}%
+ \yquant@lang@settype%
+}
+\yquant@langhelper@setup@attrs{setwire}{value}{}
+
+\yquant@langhelper@declare@command@uncontrolled{setstyle}\yquant@lang@@setstyle
+\yquant@langhelper@setup@attrs{setstyle}{value}{}
+\protected\def\yquant@lang@@setstyle#1{%
+ \yquant@register@get@ids{#1}%
+ \yquant@circuit@actonwires%
+ \yquant@circuit@setstyle%
+ \yquant@register@get@ids@list%
+ {{\yquant@lang@attr@value}}%
+}
+
+\yquant@langhelper@declare@command@uncontrolled{addstyle}\yquant@lang@@addstyle
+\yquant@langhelper@setup@attrs{addstyle}{value}{}
+\protected\def\yquant@lang@@addstyle#1{%
+ \yquant@register@get@ids{#1}%
+ \yquant@circuit@actonwires%
+ \yquant@circuit@addstyle%
+ \yquant@register@get@ids@list%
+ {{\yquant@lang@attr@value}}%
}
% END_FOLD \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex b/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
index f9a82d1c740..102a8959d90 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
@@ -244,19 +244,19 @@
}
\def\yquant@langhelper@declare@command@@extract@nctrl#1~#2;{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\yquant@langhelper@declare@command@@extract@pctrl#1|~~;%
- \else%
+ }{%
\yquant@langhelper@declare@command@@extract@pctrl#1|~#2;%
- \fi%
+ }%
}
\def\yquant@langhelper@declare@command@@extract@pctrl#1|#2~#3~;{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\yquant@langhelper@declare@command@@exec#1||~#3;%
- \else%
+ }{%
\yquant@langhelper@declare@command@@exec#1|#2~#3;%
- \fi%
+ }%
}
\protected\def\yquant@langhelper@declare@command@@exec#1|#2|~#3;{%
@@ -301,7 +301,7 @@
% if the valid value was not user-delimited by \relax, #1 and #2 are empty
% if the valid value was user-delimited by \relax, #1 is empty and #2 is \relax
\let\ifvalid=\iffalse%
- \if\relax\detokenize{#1}\relax%
+ \ifstrempty{#1}{%
\def\tmp{#2}%
\ifx\empty\tmp%
\csletcs{ifvalid}{iftrue}%
@@ -310,6 +310,6 @@
\csletcs{ifvalid}{iftrue}%
\fi%
\fi%
- \fi%
+ }\relax%
% eat the rest (which should be empty anyway)
} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex b/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
index 7f640fe4996..18a23662d3b 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
@@ -17,7 +17,8 @@
{#1}% type
{#2}% x pos
{\yquant@config@register@minimum@height}% height; at the end, the y position
- {}% wire start positions
+ {{0pt}{0pt}{}{}}% wire start positions and clipping
+ {}% wire style
}%
\global\csletcs{\yquant@prefix registername@#3[#4]}{\yquant@prefix registers}%
\csxdef{\yquant@prefix registerhigh@\reg}{#4}%
@@ -63,34 +64,34 @@
}
\def\yquant@register@get@id@lazycreate@parse#1[#2;{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\yquant@register@get@id@lazycreate@do#1[0][;%
- \else%
+ }{%
\yquant@register@get@id@lazycreate@do#1[#2;%
- \fi%
+ }%
}
\protected\def\yquant@register@get@id@lazycreate@do#1[#2]#3[;{%
- % parse length
- \if\relax\detokenize{#3}\relax%
- \yquant@langhelper@validate\len\count{#2}%
- \numdef\len{\len+1}%
- \else%
- \PackageError{yquant.sty}{Invalid register name}%
- {Register names must not contain `[' apart from register length indication.}%
- \fi%
- \edef\reg{\trim@spaces{#1}}%
- % Was this register already defined?
- \ifcsname\yquant@prefix registerhigh@\reg\endcsname%
- \numdef\idx{\csname\yquant@prefix registerhigh@\reg\endcsname+1}%
- \unless\ifnum\idx<\len\relax%
- \PackageError{yquant.sty}{Internal inconsistency detected}%
- {Tried to create a register on-the-fly that already existed.}%
- \fi%
- \else%
- \def\idx{0}%
- \fi%
\begingroup%
+ % parse length
+ \ifstrempty{#3}{%
+ \yquant@langhelper@validate\len\count{#2}%
+ \numdef\len{\len+1}%
+ }{%
+ \PackageError{yquant.sty}{Invalid register name}%
+ {Register names must not contain `[' apart from register length indication.}%
+ }%
+ \edef\reg{\trim@spaces{#1}}%
+ % Was this register already defined?
+ \ifcsname\yquant@prefix registerhigh@\reg\endcsname%
+ \numdef\idx{\csname\yquant@prefix registerhigh@\reg\endcsname+1}%
+ \unless\ifnum\idx<\len\relax%
+ \PackageError{yquant.sty}{Internal inconsistency detected}%
+ {Tried to create a register on-the-fly that already existed.}%
+ \fi%
+ \else%
+ \def\idx{0}%
+ \fi%
% pre-set y position
\yquant@for \idx := \idx to \numexpr \len -1\relax {%
\yquant@register@define%
@@ -129,6 +130,7 @@
\count4=0 % number of total registers
\ifblank{#1}{}{%
\let\ifinmulti=\iffalse%
+ \let\ifallowmain=\iffalse%
\let\do=\yquant@register@get@ids@outerlist%
\begingroup%
\catcode`[=\active%
@@ -169,9 +171,15 @@
\count0=2147483647 % minimal id
\count2=0 % maximal id
\count4=0 % number of total registers
+ \count6=-1 % index of main register
\let\ifinmulti=\iftrue%
+ \let\ifallowmain=\iftrue%
\let\do=\yquant@register@get@ids@multilist%
\docsvlist{#1}%
+ \ifnum\count6=-1 %
+ \count6=\count0 %
+ \fi%
+ \yquant@register@multi@splitparts%
\edef\process{%
\endgroup%
\noexpand\listadd\noexpand\yquant@register@get@ids@list{%
@@ -195,13 +203,13 @@
}
\def\yquant@register@get@ids@checkrange#1-#2\yquant@sep{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
% the string does not contain a dash
\yquant@register@get@ids@norange{#1}%
- \else%
+ }{%
% this is a range argument
\yquant@register@get@ids@range#1-#2\yquant@sep%
- \fi%
+ }%
}
\def\yquant@register@get@ids@norange#1{%
@@ -214,7 +222,30 @@
\protected\def\yquant@register@get@ids@norange@checkindex#1\yquant@register@get@ids@@index#2\yquant@sep{%
\edef\current{\trim@spaces{#1}}%
- \if\relax\detokenize{#2}\relax%
+ \ifallowmain%
+ \expandafter\ifyquant@firsttoken\expandafter*\expandafter{\current}{%
+ \edef\current{%
+ \expandafter\expandafter\expandafter\trim@spaces%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@gobble\current%
+ }%
+ }%
+ % catch the minimal index
+ \edef\yquant@register@get@ids@norange@checkindex@setmain{%
+ \count6=\count2%
+ \ifnum\count0<\the\count0 %
+ \count0=\the\count0 %
+ \fi%
+ }%
+ \count0=2147483647 %
+ \csletcs{ifallowmain}{iffalse}%
+ }{
+ \let\yquant@register@get@ids@norange@checkindex@setmain=\relax%
+ }%
+ \else%
+ \let\yquant@register@get@ids@norange@checkindex@setmain=\relax%
+ \fi%
+ \ifstrempty{#2}{%
% the string does not contain a sub-index; we add the full register
\yquant@register@get@id\first{\current[0]}%
\letcs\high{\yquant@prefix registerhigh@\current}%
@@ -230,9 +261,10 @@
\yquant@register@get@id\idx{\current[\i]}%
\listeadd\yquant@register@get@ids@list{\idx}%
}%
- \else%
+ }{%
\yquant@register@get@ids@norange@index#2%
- \fi%
+ }%
+ \yquant@register@get@ids@norange@checkindex@setmain%
}
\protected\def\yquant@register@get@ids@norange@index#1\yquant@register@get@ids@@index{%
@@ -269,9 +301,15 @@
\count0=2147483647 % minimal id
\count2=0 % maximal id
\count4=0 % number of total registers
+ \count6=-1 % index of main register
\let\ifinmulti=\iftrue%
+ \let\ifallowmain=\iftrue%
\let\do=\yquant@register@get@ids@subindex@nomulti%
\docsvlist{#1}%
+ \ifnum\count6=-1 %
+ \count6=\count0 %
+ \fi%
+ \yquant@register@multi@splitparts%
\edef\process{%
\endgroup%
\noexpand\listadd\noexpand\yquant@register@get@ids@list{%
@@ -291,17 +329,29 @@
}
\def\yquant@register@get@ids@subindex@checkrange#1-#2\yquant@sep{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
% the string does not contain a dash, this is a single sub-item
- \yquant@register@get@ids@subindex@norange{\trim@spaces{#1}}%
- \else%
+ \edef\idx{\trim@spaces{#1}}%
+ \expandafter\yquant@register@get@ids@subindex@norange\expandafter{\idx}%
+ }{%
% this is a range argument
\yquant@register@get@ids@subindex@range#1-#2\yquant@sep%
- \fi%
+ }%
}
\protected\def\yquant@register@get@ids@subindex@norange#1{%
- \yquant@register@get@id\idx{\current[#1]}%
+ \ifallowmain%%
+ \ifyquant@firsttoken*{#1}{%
+ \edef\idx{\current[\expandafter\trim@spaces\expandafter{\@gobble#1}]}%
+ \expandafter\yquant@register@get@id\expandafter\idx\expandafter{\idx}%
+ \count6=\idx%
+ \csletcs{ifallowmain}{iffalse}%
+ }{
+ \yquant@register@get@id\idx{\current[#1]}%
+ }%
+ \else%
+ \yquant@register@get@id\idx{\current[#1]}%
+ \fi%
\ifnum\idx<\count0 %
\count0=\idx\relax%
\fi%
@@ -313,16 +363,55 @@
}
\protected\def\yquant@register@get@ids@subindex@range#1-#2-\yquant@sep{%
- \ifblank{#1}{%
- \def\first{0}%
- }{%
- \yquant@langhelper@validate\first\count{#1}%
- }%
- \ifblank{#2}{%
- \yquant@register@get@id@high\last\current%
- }{%
- \yquant@langhelper@validate\last\count{#2}%
- }%
+ \ifallowmain%
+ \ifyquant@firsttoken*{#1}{%
+ \expandafter\ifblank\expandafter{\@gobble#1}{%
+ \def\first{0}%
+ }{%
+ \expandafter\yquant@langhelper@validate\expandafter\first\expandafter\count\expandafter{\@gobble#1}%
+ }%
+ \yquant@register@get@id\idx{\current[\first]}%
+ \count6=\idx%
+ \csletcs{ifallowmain}{iffalse}%
+ }{%
+ \ifblank{#1}{%
+ \def\first{0}%
+ }{%
+ \yquant@langhelper@validate\first\count{#1}%
+ }%
+ }%
+ \else%
+ \ifblank{#1}{%
+ \def\first{0}%
+ }{%
+ \yquant@langhelper@validate\first\count{#1}%
+ }%
+ \fi%
+ \ifallowmain%
+ % in #1, all initial spaces are gobbled automatically, but not in #2
+ \expandafter\ifyquant@firsttoken\expandafter*\expandafter{\empty#2}{%
+ \expandafter\ifblank\expandafter{\@gobble#2}{%
+ \yquant@register@get@id@high\last\current%
+ }{%
+ \expandafter\yquant@langhelper@validate\expandafter\last\expandafter\count\expandafter{\@gobble#2}%
+ }%
+ \yquant@register@get@id\idx{\current[\last]}%
+ \count6=\idx%
+ \csletcs{ifallowmain}{iffalse}%
+ }{%
+ \ifblank{#2}{%
+ \yquant@register@get@id@high\last\current%
+ }{%
+ \yquant@langhelper@validate\last\count{#2}%
+ }%
+ }%
+ \else%
+ \ifblank{#2}{%
+ \yquant@register@get@id@high\last\current%
+ }{%
+ \yquant@langhelper@validate\last\count{#2}%
+ }%
+ \fi%
\yquant@for \i := \first to \last {%
\yquant@register@get@ids@subindex@norange\i%
}%
@@ -330,14 +419,33 @@
\protected\def\yquant@register@get@ids@range#1-#2-\yquant@sep{%
% being a range between two registers, those must be uniquely identifiable, i.e. either a single sub-indexed part of a vector register, or no vector specification at all.
- \ifblank{#1}{%
- \def\first{1}%
- }{%
- \yquant@register@get@ids@range@getfirst#1\yquant@register@get@ids@@index\yquant@sep%
- }%
+ \ifallowmain%
+ \ifyquant@firsttoken*{#1}{%
+ \expandafter\ifblank\expandafter{\@gobble#1}{%
+ \def\first{1}%
+ }{%
+ \expandafter\yquant@register@get@ids@range@getfirst\@gobble#1\yquant@register@get@ids@@index\yquant@sep%
+ }%
+ \count6=\first%
+ \csletcs{ifallowmain}{iffalse}%
+ }{%
+ \ifblank{#1}{%
+ \def\first{1}%
+ }{%
+ \yquant@register@get@ids@range@getfirst#1\yquant@register@get@ids@@index\yquant@sep%
+ }%
+ }%
+ \else%
+ \ifblank{#1}{%
+ \def\first{1}%
+ }{%
+ \yquant@register@get@ids@range@getfirst#1\yquant@register@get@ids@@index\yquant@sep%
+ }%
+ \fi%
+ % it does not make sense to allow to set the main part on the second half of the range, since a range over registers (not indices) is automatically visual, so this range will be contiguous.
\ifblank{#2}{%
\letcs\last{\yquant@prefix registers}%
- }{%%
+ }{%
\yquant@register@get@ids@range@getlast#2\yquant@register@get@ids@@index\yquant@sep%
}%
\ifnum\first<\last\relax%
@@ -363,20 +471,20 @@
}
\def\yquant@register@get@ids@range@getfirst#1\yquant@register@get@ids@@index#2\yquant@sep{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\yquant@register@get@id\first{\trim@spaces{#1}[0]}%
- \else%
+ }{%
\yquant@register@get@ids@range@get\first#1\yquant@register@get@ids@@index#2%
- \fi%
+ }%
}
\protected\def\yquant@register@get@ids@range@getlast#1\yquant@register@get@ids@@index#2\yquant@sep{%
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\yquant@register@get@id@high\last{\trim@spaces{#1}}%
\yquant@register@get@id\last{\trim@spaces{#1}[\last]}%
- \else%
+ }{%
\yquant@register@get@ids@range@get\last#1\yquant@register@get@ids@@index#2%
- \fi%
+ }%
}
\def\yquant@register@get@ids@range@get#1#2\yquant@register@get@ids@@index#3\yquant@register@get@ids@@index{%
@@ -384,6 +492,94 @@
}
\let\yquant@register@multi=\empty%
+\protected\def\yquant@register@multi@contiguous{}%
+
+% splits \yquant@register@get@ids@list into a list of contiguous parts
+\protected\def\yquant@register@multi@splitparts{%
+ \begingroup%
+ \let\registers=\yquant@register@get@ids@list%
+ \yquant@sort@list\registers\yquant@sort@ascending%
+ \let\newlist=\empty%
+ \count2=-1 %
+ \def\do##1{%
+ \ifnum\count2=-1 %
+ \count2=##1 %
+ \count4=\count2 %
+ \else%
+ \advance\count2 by 1 %
+ \ifnum##1>\count2 %
+ % this is a discontiguous change (we disallow duplicate entries)
+ \eappto\newlist{%
+ \yquant@register@multi@contiguous%
+ {\the\count4}{\the\numexpr\count2-1\relax}%
+ {\ifnum\count6<\count2 %
+ \ifnum\count4>\count6 %
+ 0%
+ \else%
+ 1%
+ \fi%
+ \else%
+ 0%
+ \fi}%
+ }%
+ \count2=##1 %
+ \count4=\count2 %
+ \fi%
+ \fi%
+ }%
+ \dolistloop\registers%
+ % we disallow empty lists
+ \eappto\newlist{%
+ \yquant@register@multi@contiguous%
+ {\the\count4}{\the\count2}%
+ {\ifnum\count6>\count2 %
+ 0%
+ \else%
+ \ifnum\count4>\count6 %
+ 0%
+ \else%
+ 1%
+ \fi%
+ \fi}%
+ }%
+ \expandafter%
+ \endgroup%
+ \expandafter\def\expandafter\yquant@register@get@ids@list\expandafter{%
+ \newlist%
+ }%
+}
+
+% splits \yquant@register@get@ids@list into a list of discontiguous parts
+\protected\def\yquant@register@multi@splitparts@sepall{%
+ \begingroup%
+ \let\registers=\yquant@register@get@ids@list%
+ \yquant@sort@list\registers\yquant@sort@ascending%
+ \let\newlist=\empty%
+ \def\do##1{%
+ \eappto\newlist{%
+ \yquant@register@multi@contiguous%
+ {##1}{##1}%
+ {\ifnum##1=\count6 %
+ 1%
+ \else%
+ 0%
+ \fi%
+ }%
+ }%
+ }%
+ \dolistloop\registers%
+ \expandafter%
+ \endgroup%
+ \expandafter\def\expandafter\yquant@register@get@ids@list\expandafter{%
+ \newlist%
+ }%
+}
+
+\protected\def\yquant@register@get@multiassingle{%
+ \yquant@register@get@allowmultitrue%
+ \let\yquant@register@multi@splitparts=\yquant@register@multi@splitparts@sepall%
+ \preto\yquant@attrs@remaining{/yquant/operator/multi as single,}%
+}
% END_FOLD
% BEGIN_FOLD Getters: extract the requested information from the register with given id
@@ -392,21 +588,21 @@
\yquant@register@get@type@aux\csname\yquant@prefix register@#1\endcsname%
}
-\def\yquant@register@get@type@aux#1#2#3#4{#1}
+\def\yquant@register@get@type@aux#1#2#3#4#5{#1}
\def\yquant@register@get@x#1{%
\expandafter\expandafter\expandafter%
\yquant@register@get@x@aux\csname\yquant@prefix register@#1\endcsname%
}
-\def\yquant@register@get@x@aux#1#2#3#4{#2}
+\def\yquant@register@get@x@aux#1#2#3#4#5{#2}
\def\yquant@register@get@height#1{%
\expandafter\expandafter\expandafter%
\yquant@register@get@height@aux\csname\yquant@prefix register@#1\endcsname%
}
-\def\yquant@register@get@height@aux#1#2#3#4{#3}
+\def\yquant@register@get@height@aux#1#2#3#4#5{#3}
% The y parameter get macros exist in two forms: The protected one is used during the storage to the draw macro; it should never be executed. The env environment then maps them to their proper expandable forms.
\protected\def\yquant@register@get@@protected{%
@@ -443,7 +639,27 @@
\yquant@register@get@lastwire@aux\csname\yquant@prefix register@#1\endcsname%
}
-\def\yquant@register@get@lastwire@aux#1#2#3#4{#4}
+\protected\def\yquant@register@get@lastwire@aux#1#2#3#4#5#6{%
+ \def#6{#4}%
+}
+
+\def\yquant@register@get@style#1{%
+ \expandafter\expandafter\expandafter%
+ \yquant@register@get@style@aux\csname\yquant@prefix register@#1\endcsname%
+}
+
+\def\yquant@register@get@style@aux#1#2#3#4#5{#5}
+
+\def\yquant@register@get@typeywire#1{%
+ \expandafter\expandafter\expandafter%
+ \yquant@register@get@typeywire@aux\csname\yquant@prefix register@#1\endcsname%
+}
+
+\protected\def\yquant@register@get@typeywire@aux#1#2#3#4#5#6#7#8{%
+ \def#6{#1}%
+ \def#7{#3}%
+ \def#8{#4}%
+}%
% Set #1 to the maximum x value found between #2 and #3
\protected\def\yquant@register@get@maxxrange#1#2#3{%
@@ -487,8 +703,8 @@
\csname\yquant@prefix register@#1\endcsname\yquant@register@set@type@aux%
}
-\long\def\yquant@register@set@type@aux#1#2#3#4#5{%
- {#5}{#2}{#3}{#4}%
+\long\def\yquant@register@set@type@aux#1#2#3#4#5#6{%
+ {#6}\unexpanded{{#2}{#3}{#4}{#5}}%
}
\protected\def\yquant@register@set@x#1{%
@@ -496,8 +712,8 @@
\csname\yquant@prefix register@#1\endcsname\yquant@register@set@x@aux%
}
-\long\def\yquant@register@set@x@aux#1#2#3#4#5{%
- {#1}{#5}{#3}{#4}%
+\long\def\yquant@register@set@x@aux#1#2#3#4#5#6{%
+ \unexpanded{{#1}}{#6}\unexpanded{{#3}{#4}{#5}}%
}
\protected\def\yquant@register@update@height#1#2{%
@@ -513,12 +729,8 @@
}
% Set the currently used register
-\protected\def\yquant@register@use#1{%
- \edef\yquant@register@y{\yquant@register@get@y{#1}}%
-}
-
-\long\def\yquant@register@set@height@aux#1#2#3#4#5{%
- {#1}{#2}{#5}{#4}%
+\long\def\yquant@register@set@height@aux#1#2#3#4#5#6{%
+ \unexpanded{{#1}{#2}}{#6}\unexpanded{{#4}{#5}}%
}
\protected\def\yquant@register@set@lastwire#1{%
@@ -526,7 +738,16 @@
\csname\yquant@prefix register@#1\endcsname\yquant@register@set@lastwire@aux%
}
-\long\def\yquant@register@set@lastwire@aux#1#2#3#4#5{%
- {#1}{#2}{#3}{#5}%
+\long\def\yquant@register@set@lastwire@aux#1#2#3#4#5#6{%
+ \unexpanded{{#1}{#2}{#3}}{#6}\unexpanded{{#5}}%
+}
+
+\protected\def\yquant@register@set@style#1{%
+ \expandafter\yquant@register@set@@aux%
+ \csname\yquant@prefix register@#1\endcsname\yquant@register@set@style@aux%
+}
+
+\long\def\yquant@register@set@style@aux#1#2#3#4#5#6{%
+ \unexpanded{{#1}{#2}{#3}{#4}}{#6}%
}
% END_FOLD \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex b/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
index 0f88ed63450..3a03985ca5a 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
@@ -1,97 +1,63 @@
-% To draw the wires, we need to determine border angles. However, pgf's approach for this (giving the border point that lies on a line from the center to a desired probe point) is not suitable for this. Instead, we need to give a point that is projected perpendicularly onto the shape.
-\def\pgf@sh@anchorxproj#1{%
- \csgdef{pgf@anchor@\pgf@sm@shape@name @xproj}##1{\pgf@process{##1}#1}%
-}%
-\def\pgf@sh@inheritanchorxproj[from=#1]{%
- \global\csletcs{pgf@anchor@\pgf@sm@shape@name @xproj}{pgf@anchor@#1@xproj}%
-}%
-\def\pgf@sh@anchoryproj#1{%
- \csgdef{pgf@anchor@\pgf@sm@shape@name @yproj}##1{\pgf@process{##1}#1}%
-}%
-\def\pgf@sh@inheritanchoryproj[from=#1]{%
- \global\csletcs{pgf@anchor@\pgf@sm@shape@name @yproj}{pgf@anchor@#1@yproj}%
-}%
+\long\def\pgf@sh@clippathhorz#1{%
+ \csgdef{pgf@sh@cliphorz@\pgf@sm@shape@name}{#1}%
+}
+\let\pgf@sh@clippath=\pgf@sh@clippathhorz%
+\long\def\pgf@sh@clippathvert#1{%
+ \csgdef{pgf@sh@clipvert@\pgf@sm@shape@name}{#1}%
+}
+\def\pgf@sh@inheritclippath[from=#1]{%
+ \global\csletcs{pgf@sh@cliphorz@\pgf@sm@shape@name}{pgf@sh@cliphorz@#1}%
+ \global\csletcs{pgf@sh@clipvert@\pgf@sm@shape@name}{pgf@sh@clipvert@#1}%
+}
\patchcmd%
\pgfdeclareshape%
{\let\anchorborder=\pgf@sh@anchorborder}%
{\let\anchorborder=\pgf@sh@anchorborder%
- \let\anchorxproj=\pgf@sh@anchorxproj%
- \let\inheritanchorxproj=\pgf@sh@inheritanchorxproj
- \let\anchoryproj=\pgf@sh@anchoryproj%
- \let\inheritanchoryproj=\pgf@sh@inheritanchoryproj}%
+ \let\clippathhorz=\pgf@sh@clippathhorz%
+ \let\clippathvert=\pgf@sh@clippathvert%
+ \let\clippath=\pgf@sh@clippath%
+ \let\inheritclippath=\pgf@sh@inheritclippath}%
{}%
{\PackageError{yquant.sty}%
{Failed to patch \string\pgfdeclareshape}%
{yquant could not provide a necessary extension to pgf.}}%
-% This is mostly a copy of \pgfpointshapeborder, but we do not perform the center-anchor shift.
-\def\pgfpointshapexproj#1#2{%
+% Every shape additionally provides information about how it should clip the wires. The clipping softpath instructions of shape #1 are stored into \pgfshapeclippathresult. The path is drawn with the tikz options #2 in place.
+\protected\def\pgfshapeclippath#1#2{%
% Ok, check whether #1 is known!
\ifcsname pgf@sh@ns@#1\endcsname%
- \pgf@process{%
+ \begin{pgfinterruptpath}%
\edef\pgfreferencednodename{#1}% for use inside of anchors.
+ % install the given style and extract whether we draw a line.
+ \let\tikz@mode=\pgfutil@empty%
+ \tikzset{every path/.try,#2}%
+ \edef\oldpgflinewidth{\the\pgflinewidth}%
+ \tikz@mode@drawfalse%
+ \tikz@mode%
+ \unless\iftikz@mode@draw%
+ \pgflinewidth=0pt %
+ \fi%
% MW install special macros
\csname pgf@sh@ma@#1\endcsname% MW
% install special coordinates
\csname pgf@sh@np@#1\endcsname%
- \pgf@process{%
- \pgf@process{\pgfpointtransformed{#2}}%
- \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}%
- \pgftransforminvert%
- \pgf@pos@transform@glob%
- \pgf@xa=\pgf@x%
- \pgf@ya=\pgf@y%
- \csname pgf@anchor@\csname pgf@sh@ns@#1\endcsname @xproj\endcsname{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
- \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}%
- \pgf@pos@transform@glob%
- }%
- % Add inter picture transformation
- \pgf@shape@interpictureshift{#1}%
- % Undo current transformation
- \pgftransforminvert%
- \pgf@pos@transform@glob%
- }%
+ \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}%
+ \csname pgf@sh@cliphorz@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ \pgfsyssoftpath@getcurrentpath\pgfshapeclippathresult%
+ \pgfprocessround{\pgfshapeclippathresult}{\pgfshapeclippathresult}%
+ \global\let\pgfshapeclippathhorzresult=\pgfshapeclippathresult%
+ \ifcsname pgf@sh@clipvert@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ % different clipping in vertical direction
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ \csname pgf@sh@clipvert@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ \pgfsyssoftpath@getcurrentpath\pgfshapeclippathresult%
+ \pgfprocessround{\pgfshapeclippathresult}{\pgfshapeclippathresult}%
+ \fi%
+ \global\let\pgfshapeclippathvertresult=\pgfshapeclippathresult%
+ \end{pgfinterruptpath}%
\else%
\pgferror{No shape named #1 is known}%
\pgfpointorigin%
\fi%
-}%
-\def\ifpgfpointshapexproj#1{%
- \pgfutil@ifundefined{pgf@sh@ns@#1}%
- {\pgferror{No shape named #1 is known}}%
- {\ifcsname pgf@anchor@\csname pgf@sh@ns@#1\endcsname @xproj\endcsname}%
-}
-\let\pgfpointshapeyproj=\pgfpointshapexproj%
-\patchcmd%
- \pgfpointshapeyproj%
- {xproj}{yproj}%
- {}{\PackageError{yquant.sty}{Failed to provide \string\pgfpointshapeyproj}{}}%
-\def\ifpgfpointshapeyproj#1{%
- \pgfutil@ifundefined{pgf@sh@ns@#1}%
- {\pgferror{No shape named #1 is known}}%
- {\ifcsname pgf@anchor@\csname pgf@sh@ns@#1\endcsname @yproj\endcsname}%
-}
-
-% Calculate the intersection of an ellipse centered at the origin with radii #1 and #2 with a horizontal line at position #3. Result goes to \pgf@xa, and it is the right intersection point.
-\protected\def\yquant@shape@ellipse@xfromy#1#2#3{%
- \ifdim#3>#2\relax%
- \global\pgf@xa=0pt %
- \else%
- \ifdim-\dimexpr#3\relax>#2\relax%
- \global\pgf@xa=0pt %
- \else%
- \begingroup%
- % Here, we essentially do #1*sqrt(1-(#3/#2)^2)
- \dimen2=#2\relax%
- \dimen3=#3\relax%
- % if we divide by a dimension, it is internally converted to sp, so we divide by its pt-value and again by 65536. Same for multiplication. etex fuses muldiv to 64bit, so we don't get overflows.
- % calculate the sqrt; but \pgfmathsqrt@ expects a real number without dimension suffix. It internally does \expandafter\pgfmath@x#1pt\relax, so just gobble the additional pt.
- % TODO: is there a better way, exploiting perhaps a representation in sp?
- \pgfmathsqrt@{\the\dimexpr1pt-\dimen3*\dimen3/\dimen2*65536/\dimen2\relax%
- \@gobbletwo}%
- \global\pgf@xa=\pgfmathresult\dimexpr#1\relax%
- \endgroup%
- \fi%
- \fi%
}
\pgfdeclareshape{yquant-text}{%
@@ -99,39 +65,28 @@
\foreach \anc in {center, mid, base, north, south, west, mid west, base west, north west, south west, east, mid east, base east, north east, south east} {%
\inheritanchor[from=rectangle]{\anc}%
}%
- \global\cslet{pgf@anchor@yquant-text@circuit}\pgf@anchor@rectangle@center%
\inheritanchorborder[from=rectangle]%
\inheritbackgroundpath[from=rectangle]%
- \anchorxproj{%
- \pgf@xa=\pgf@x%
- \pgf@ya=\pgf@y%
- % The origin is at the left baseline of the text, i.e. to the left we have the inner + outer xsep, the the right there's the text + inner + outer xsep.
- \northeast%
- \pgf@xb=.5\pgf@x%
- \southwest%
- \advance \pgf@xb by .5\pgf@x%
- \ifdim\pgf@xa>\pgf@xb%
- % to the right
- \northeast%
- % else we already called \southwest
- \fi%
- \pgf@y=\pgf@ya%
- }%
- \anchoryproj{%
- \pgf@xa=\pgf@x%
- \pgf@ya=\pgf@y%
- % The origin is at the left baseline of the text, i.e. to the top we have the text height + inner + outer ysep, the the bottom there's the text depth + inner + outer ysep.
- \northeast%
- \pgf@yb=.5\pgf@y%
- \southwest%
- \advance \pgf@yb by .5\pgf@y%
- \ifdim\pgf@ya>\pgf@yb%
- % to the top
- \northeast%
- % else we already called \southwest
- \fi%
- \pgf@x=\pgf@xa%
- }
+ \clippath{%
+ % all pgf temporaries may be overwritten by \pgfpathrectanglecorners
+ \begingroup%
+ % the outer sep may depend on the line width (though there may not be any line)
+ \pgflinewidth=\oldpgflinewidth%
+ \global\@tempdima=\pgfkeysvalueof{/pgf/outer xsep} %
+ \global\@tempdimb=\pgfkeysvalueof{/pgf/outer ysep} %
+ \endgroup%
+ \advance\@tempdima by -.5\pgflinewidth%
+ \advance\@tempdimb by -.5\pgflinewidth%
+ \pgfpathrectanglecorners%
+ {\southwest%
+ \advance\pgf@x by \@tempdima%
+ \advance\pgf@y by \@tempdimb%
+ }
+ {\northeast%
+ \advance\pgf@x by -\@tempdima%
+ \advance\pgf@y by -\@tempdimb%
+ }%
+ }%
}
\pgfdeclareshape{yquant-rectangle}{%
@@ -198,28 +153,6 @@
\pgfpointborderrectangle{\pgfqpoint{\@tempdima}{\@tempdimb}}%
{\pgfqpoint{\xradius}{\yradius}}%
}%
- \anchorxproj{%
- \ifdim\pgf@x>0pt %
- % to the right
- \pgf@x=\xradius\relax%
- \else%
- % to the left
- \pgf@x=-\xradius\relax%
- \fi%
- }%
- \anchoryproj{%
- \ifdim\pgf@y>0pt %
- % to the top
- \pgf@y=\yradius\relax%
- \else%
- % to the bottom
- \pgf@y=-\yradius\relax%
- \fi%
- }%
- % END_FOLD
- % BEGIN_FOLD Circuit-related anchors
- \global\csletcs{pgf@anchor@yquant-rectangle@circuit}%
- {pgf@anchor@yquant-rectangle@center}%
% END_FOLD
% BEGIN_FOLD Path
\backgroundpath{%
@@ -227,12 +160,19 @@
{\pgfqpoint{-\xradius}{\yradius}}%
{\pgfqpoint{\xradius}{-\yradius}}%
}%
+ \clippath{%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ {\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {-\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ }%
% END_FOLD
}
\pgfdeclareshape{yquant-circle}{%
\inheritsavedanchors[from=yquant-rectangle]%
- \foreach \anc in {center, north, east, south, west, circuit, text} {%
+ \foreach \anc in {center, north, east, south, west, text} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
\anchor{north east}%
@@ -254,123 +194,26 @@
{\pgfqpoint{.707107\dimexpr\xradius\relax}%
{.707107\dimexpr\yradius\relax}}%
}%
- \anchorxproj{%
- \yquant@shape@ellipse@xfromy\xradius\yradius\pgf@y%
- \ifdim\pgf@x>0pt %
- % to the right
- \pgf@x=\pgf@xa%
- \else%
- % to the left
- \pgf@x=-\pgf@xa%
- \fi%
- }%
- \anchoryproj{%
- \yquant@shape@ellipse@xfromy\yradius\xradius\pgf@x%
- \ifdim\pgf@y>0pt %
- % to the top
- \pgf@y=\pgf@xa%
- \else%
- % to the bottom
- \pgf@y=-\pgf@xa%
- \fi%
- }%
- \foregroundpath{%
+ \backgroundpath{%
\pgfpathellipse{\pgfpointorigin}%
{\pgfqpoint{\xradius}{0pt}}%
{\pgfqpoint{0pt}{\yradius}}%
}%
+ \clippath{%
+ \pgfpathellipse{\pgfpointorigin}%
+ {\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth}{0pt}}%
+ {\pgfqpoint{0pt}{\dimexpr\yradius+.5\pgflinewidth}}%
+ }%
}
-\pgfdeclareshape{yquant-zz}{%
- % Here, the radii have a special meaning, we don't put text into the shape
+\pgfdeclareshape{yquant-slash}{%
\saveddimen\xradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/x radius}}%
}%
\saveddimen\yradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/y radius}}%
}%
- \foreach \anc in {center, north, east, south, west, circuit} {%
- \inheritanchor[from=yquant-circle]{\anc}%
- }%
- \anchor{north east}%
- {\pgfqpoint{.707107\dimexpr\xradius\relax}%
- {\dimexpr\yradius-.292893\dimexpr\xradius\relax\relax}}%
- \anchor{south east}%
- {\pgfqpoint{.707107\dimexpr\xradius\relax}%
- {\dimexpr-\yradius+.292893\dimexpr\xradius\relax\relax}}%
- \anchor{south west}%
- {\pgfqpoint{-.707107\dimexpr\xradius\relax}%
- {\dimexpr-\yradius+.292893\dimexpr\xradius\relax\relax}}%
- \anchor{north west}%
- {\pgfqpoint{-.707107\dimexpr\xradius\relax}%
- {\dimexpr\yradius-.292893\dimexpr\xradius\relax\relax}}%
- % TODO: this is not really the correct border anchor
- \inheritanchorborder[from=yquant-rectangle]%
- \anchorxproj{%
- \ifdim\pgf@y<0pt %
- \pgf@ya=\dimexpr\pgf@y+\yradius-\xradius\relax%
- \else%
- \pgf@ya=\dimexpr\pgf@y-\yradius+\xradius\relax%
- \fi%
- \yquant@shape@ellipse@xfromy\xradius\xradius\pgf@ya%
- \ifdim\pgf@x>0pt %
- % to the right
- \pgf@x=\pgf@xa%
- \else%
- % to the left
- \pgf@x=-\pgf@xa%
- \fi%
- }%
- \anchoryproj{%
- \yquant@shape@ellipse@xfromy\xradius\xradius\pgf@xa%
- \ifdim\pgf@y>0pt %
- % to the top
- \pgf@y=\dimexpr\yradius-\xradius+\pgf@xa\relax%
- \else%
- % to the bottom
- \pgf@y=-\dimexpr\yradius-\xradius+\pgf@xa\relax%
- \fi%
- }%
- \backgroundpath{%
- \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- \pgfpathlineto{\pgfqpoint{0pt}{-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- \pgfpathcircle{\pgfqpoint{0pt}{\dimexpr\yradius-\xradius\relax}}%
- {\xradius}%
- \pgfpathcircle{\pgfqpoint{0pt}{\dimexpr\xradius-\yradius\relax}}%
- {\xradius}%
- }%
-}
-
-\pgfdeclareshape{yquant-xx}{%
- \inheritsavedanchors[from=yquant-zz]%
- \savedmacro\ifconnector{%
- \let\ifconnector=\ifyquant@config@multi@line%
- }%
- \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
- \inheritanchor[from=yquant-rectangle]{\anc}%
- }%
- % TODO: this is not really the correct border anchor
- \inheritanchorborder[from=yquant-rectangle]%
- \inheritanchorxproj[from=yquant-rectangle]%
- \inheritanchoryproj[from=yquant-rectangle]%
- % Draw the operator itself
- \backgroundpath{%
- \ifconnector%
- \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- \pgfpathlineto{\pgfqpoint{0pt}{-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- \fi%
- \pgfpathrectanglecorners%
- {\pgfqpoint{-\xradius}{\dimexpr\yradius\relax}}%
- {\pgfqpoint{\xradius}{\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- \pgfpathrectanglecorners%
- {\pgfqpoint{-\xradius}{-\yradius}}%
- {\pgfqpoint{\xradius}{-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- }%
-}
-
-\pgfdeclareshape{yquant-slash}{%
- \inheritsavedanchors[from=yquant-zz]%
- \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+ \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
\inheritanchorborder[from=yquant-rectangle]%
@@ -378,46 +221,148 @@
\pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
\pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
}%
+ \clippath{%
+ % we need to clip to the line; but this is not possible, we can only clip to the inner of a path. For this reason, calculate the rectangle that represents the line.
+ % TODO: for round line endings, this is not a rectangle. Only a problem if the yradius is so short that the slash ends within a wire.
+ \ifcsname yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth\endcsname%
+ \letcs\tmp{yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+ \dimen2=\expandafter\@firstoftwo\tmp%
+ \dimen4=\expandafter\@secondoftwo\tmp%
+ \else%
+ % cos(arctan(x)) = 1/sqrt(1+x^2)
+ % sin(arctan(x)) = x/sqrt(1+x^2)
+ \dimen2=\xradius %
+ \dimen4=\yradius %
+ % if we divide by a dimension, it is internally converted to sp, so we divide by its pt-value and again by 65536. Same for multiplication. etex fuses muldiv to 64bit, so we don't get overflows.
+ \dimen0=\dimexpr\dimen4*\dimen4/\dimen2*65536/\dimen2\relax%
+ % calculate the sqrt; but \pgfmathsqrt@ expects a real number without dimension suffix. It internally does \expandafter\pgfmath@x#1pt\relax, so just gobble the additional pt.
+ \pgfmathsqrt@{\the\dimexpr1pt+\dimen0\relax\@gobbletwo}%
+ \pgfmathreciprocal@\pgfmathresult%
+ \dimen2=\dimexpr.5\pgflinewidth*\dimexpr\pgfmathresult pt\relax/65536\relax%
+ \dimen4=\dimexpr\dimexpr\yradius\relax*\dimen2/\dimexpr\xradius\relax\relax%
+ \csxdef{yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+ {{\the\dimen2}{\the\dimen4}}%
+ \fi%
+ \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+ {-\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+ {\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+ {\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+ {-\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathclose%
+ }%
}
\pgfdeclareshape{yquant-swap}{%
- \inheritsavedanchors[from=yquant-xx]%
- \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+ \inheritsavedanchors[from=yquant-slash]%
+ \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
\inheritanchorborder[from=yquant-rectangle]%
- \inheritanchoryproj[from=yquant-rectangle]%
\backgroundpath{%
- % Connector
- \ifconnector%
- \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\yradius-\xradius\relax}}%
- \pgfpathlineto{\pgfqpoint{0pt}{-\dimexpr\yradius-\xradius\relax}}%
- \fi%
- % Upper cross
\pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
- \pgfpathlineto{\pgfqpoint{\xradius}%
- {\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
- \pgfpathlineto{\pgfqpoint{-\xradius}
- {\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
- % Lower cross
- \pgfpathmoveto{\pgfqpoint{-\xradius}%
- {-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
\pgfpathlineto{\pgfqpoint{\xradius}{-\yradius}}%
- \pgfpathmoveto{\pgfqpoint{\xradius}%
- {-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+ \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
\pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
}%
+ \clippathhorz{%
+ % we need to clip to the line; but this is not possible, we can only clip to the inner of a path. For this reason, calculate the rectangle that represents the line.
+ % TODO: for round line endings, this is not a rectangle. Only a problem if the yradius is so short that the slash ends within a wire.
+ \ifcsname yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth\endcsname%
+ \letcs\tmp{yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+ \dimen2=\expandafter\@firstoftwo\tmp%
+ \dimen4=\expandafter\@secondoftwo\tmp%
+ \else%
+ % cos(arctan(x)) = 1/sqrt(1+x^2)
+ % sin(arctan(x)) = x/sqrt(1+x^2)
+ \dimen2=\xradius %
+ \dimen4=\yradius %
+ % if we divide by a dimension, it is internally converted to sp, so we divide by its pt-value and again by 65536. Same for multiplication. etex fuses muldiv to 64bit, so we don't get overflows.
+ \dimen0=\dimexpr\dimen4*\dimen4/\dimen2*65536/\dimen2\relax%
+ % calculate the sqrt; but \pgfmathsqrt@ expects a real number without dimension suffix. It internally does \expandafter\pgfmath@x#1pt\relax, so just gobble the additional pt.
+ \pgfmathsqrt@{\the\dimexpr1pt+\dimen0\relax\@gobbletwo}%
+ \pgfmathreciprocal@\pgfmathresult%
+ \dimen2=\dimexpr.5\pgflinewidth*\dimexpr\pgfmathresult pt\relax/65536\relax%
+ \dimen4=\dimexpr\dimexpr\yradius\relax*\dimen2/\dimexpr\xradius\relax\relax%
+ \csxdef{yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+ {{\the\dimen2}{\the\dimen4}}%
+ \fi%
+ \dimen6=\dimexpr\dimen2*\dimexpr\xradius\relax/\dimexpr\yradius\relax+%
+ \dimen2*\dimexpr\yradius\relax/\dimexpr\xradius\relax\relax%
+ \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+ {\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+ {\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+ {\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+ {\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimen6}{0pt}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+ {-\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+ {-\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+ {-\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+ {-\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimen6}{0pt}}%
+ \pgfpathclose%
+ }%
+ \clippathvert{%
+ % we need to clip to the line; but this is not possible, we can only clip to the inner of a path. For this reason, calculate the rectangle that represents the line.
+ % TODO: for round line endings, this is not a rectangle. Only a problem if the yradius is so short that the slash ends within a wire.
+ \ifcsname yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth\endcsname%
+ \letcs\tmp{yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+ \dimen2=\expandafter\@firstoftwo\tmp%
+ \dimen4=\expandafter\@secondoftwo\tmp%
+ \else%
+ % cos(arctan(x)) = 1/sqrt(1+x^2)
+ % sin(arctan(x)) = x/sqrt(1+x^2)
+ \dimen2=\xradius %
+ \dimen4=\yradius %
+ % if we divide by a dimension, it is internally converted to sp, so we divide by its pt-value and again by 65536. Same for multiplication. etex fuses muldiv to 64bit, so we don't get overflows.
+ \dimen0=\dimexpr\dimen4*\dimen4/\dimen2*65536/\dimen2\relax%
+ % calculate the sqrt; but \pgfmathsqrt@ expects a real number without dimension suffix. It internally does \expandafter\pgfmath@x#1pt\relax, so just gobble the additional pt.
+ \pgfmathsqrt@{\the\dimexpr1pt+\dimen0\relax\@gobbletwo}%
+ \pgfmathreciprocal@\pgfmathresult%
+ \dimen2=\dimexpr.5\pgflinewidth*\dimexpr\pgfmathresult pt\relax/65536\relax%
+ \dimen4=\dimexpr\dimexpr\yradius\relax*\dimen2/\dimexpr\xradius\relax\relax%
+ \csxdef{yquant@math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+ {{\the\dimen2}{\the\dimen4}}%
+ \fi%
+ \dimen6=\dimexpr\dimen4*\dimexpr\xradius\relax/\dimexpr\yradius\relax+%
+ \dimen4*\dimexpr\yradius\relax/\dimexpr\xradius\relax\relax%
+ \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+ {\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+ {\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{0pt}{\dimen6}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+ {\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+ {\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+ {-\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+ {-\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{0pt}{-\dimen6}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+ {-\dimexpr\yradius+\dimen2\relax}}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+ {-\dimexpr\yradius-\dimen2\relax}}%
+ \pgfpathclose%
+ }%
}
\pgfdeclareshape{yquant-oplus}{%
- \inheritsavedanchors[from=yquant-zz]%
- \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+ \inheritsavedanchors[from=yquant-slash]%
+ \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-circle]{\anc}%
}%
\inheritanchorborder[from=yquant-circle]%
- \inheritanchorxproj[from=yquant-circle]%
- \inheritanchoryproj[from=yquant-circle]%
\backgroundpath{%
\pgfpathmoveto{\pgfqpoint{0pt}{\yradius}}%
\pgfpathlineto{\pgfqpoint{0pt}{-\yradius}}%
@@ -427,6 +372,7 @@
{\pgfqpoint{\xradius}{0pt}}%
{\pgfqpoint{0pt}{\yradius}}%
}%
+ \inheritclippath[from=yquant-circle]%
}
\pgfdeclareshape{yquant-measure}{%
@@ -443,52 +389,73 @@
\pgf@x=1.25mm %
\fi%
\else%
- % We need the 2.3mm for the meter sign, the height of the text plus a minimum separation of 2pt
- \pgf@y=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox+2.3mm+4pt\relax%
+ \pgf@y=\dimexpr.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox+2pt\relax%
+ \ifyquant@config@operator@multi@main%
+ \advance\pgf@y by 1.25mm %
+ \fi%
\ifdim\pgf@x<\pgf@y%
\pgf@x=\pgf@y%
\fi%
\fi%
}%
\savedanchor\stext{%
- \pgfqpoint%
- {-.5\wd\pgfnodeparttextbox}%
- {\dp\pgfnodeparttextbox}%
+ \ifyquant@config@operator@multi@main%
+ \pgfqpoint%
+ {-.5\wd\pgfnodeparttextbox}%
+ {\dp\pgfnodeparttextbox}%
+ \else%
+ \pgfqpoint%
+ {-.5\wd\pgfnodeparttextbox}%
+ {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
+ \fi%
}%
\saveddimen\textheight{%
\pgf@x=\ht\pgfnodeparttextbox%
- }
- \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+ }%
+ \savedmacro\main{%
+ \ifyquant@config@operator@multi@main%
+ \def\main{\noexpand\yquant@config@operator@multi@maintrue}%
+ \else%
+ \ifdim\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax=0pt%
+ \def\main{\noexpand\yquant@config@operator@multi@maintrue}%
+ \else%
+ \def\main{\noexpand\yquant@config@operator@multi@mainfalse}%
+ \fi%
+ \fi%
+ }%
+ \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
\anchor{text}{%
\stext%
- \pgf@y=\dimexpr-\yradius+1pt+\pgf@y\relax%
+ \main%
+ \ifyquant@config@operator@multi@main%
+ \pgf@y=\dimexpr-\yradius+1pt+\pgf@y\relax%
+ \fi%
}%
\inheritanchorborder[from=yquant-rectangle]%
- \inheritanchorxproj[from=yquant-rectangle]%
- \inheritanchoryproj[from=yquant-rectangle]%
- \backgroundpath{%
- \pgfpathrectanglecorners%
- {\pgfqpoint{-\xradius}{\yradius}}%
- {\pgfqpoint{\xradius}{-\yradius}}%
- }
+ \inheritbackgroundpath[from=yquant-rectangle]%
+ \inheritclippath[from=yquant-rectangle]%
\beforebackgroundpath{%
- % Make sure the meter does not extend beyond the box (we are in a scope here)
- \path [clip]
- (-\xradius, \yradius) rectangle (\xradius, -\yradius);%
- % The position of the meter symbol depends on the presence of the text. If there is no text, we just vertically center. If there is some text, we shift the symbol upwards from the text until there is no overlap any more.
- \csname pgf@anchor@yquant-measure@text\endcsname%
- \advance\pgf@y by \textheight\relax%
- \ifdim\pgf@y<-1.15mm %
- \@tempdima=-1.15mm %
- \else%
- \@tempdima=\dimexpr\pgf@y+2pt\relax%
+ \main%
+ % we only draw the meter symbol if this is the main part of a multi-register (or there is no text)
+ \ifyquant@config@operator@multi@main%
+ % Make sure the meter does not extend beyond the box (we are in a scope here)
+ \path [clip]
+ (-\xradius, \yradius) rectangle (\xradius, -\yradius);%
+ % The position of the meter symbol depends on the presence of the text. If there is no text, we just vertically center. If there is some text, we shift the symbol upwards from the text until there is no overlap any more.
+ \csname pgf@anchor@yquant-measure@text\endcsname%
+ \advance\pgf@y by \textheight\relax%
+ \ifdim\pgf@y<-1.15mm %
+ \@tempdima=-1.15mm %
+ \else%
+ \@tempdima=\dimexpr\pgf@y+2pt\relax%
+ \fi%
+ \path [/yquant/operators/every measure meter]
+ (-2.25mm, \@tempdima) arc[start angle=160, end angle=20,%
+ x radius=2.25mm, y radius=1.4mm]
+ (0, \@tempdima) -- ++(1.6mm, 2.3mm);
\fi%
- \path [/yquant/operators/every measure meter]
- (-2.25mm, \@tempdima) arc[start angle=160, end angle=20,%
- x radius=2.25mm, y radius=1.4mm]
- (0, \@tempdima) -- ++(1.6mm, 2.3mm);
}%
}
@@ -521,16 +488,12 @@
{-\dimexpr.5\wd\pgfnodeparttextbox+1mm\relax}%
{-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
}%
- \foreach \anc in {center, north, south, south west, west, north west, circuit, text} {%
+ \foreach \anc in {center, north, south, south west, west, north west, text} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
\foreach \anc in {north east, east, south east} {%
\inheritanchor[from=yquant-circle]{\anc}%
}%
-% \anchor{text}{%
-% \stext%
-% \pgf@x=-.5\dimexpr\xradius-\pgf@x\relax%
-% }%
\anchorborder{%
\@tempdima=\pgf@x%
\@tempdimb=\pgf@y%
@@ -545,40 +508,6 @@
{\pgfqpoint{\xradius}{\yradius}}%
\fi%
}%
- \anchorxproj{%
- \ifdim\pgf@x>\dimexpr\xradius-3mm\relax%
- % to the right
- \advance\pgf@x by -\dimexpr\xradius-3mm\relax%
- \yquant@shape@ellipse@xfromy{3mm}\yradius\pgf@y%
- \pgf@x=\dimexpr\pgf@xa+\xradius-3mm\relax%
- \else%
- % to the left
- \pgf@x=-\xradius\relax%
- \fi%
- }%
- \anchoryproj{%
- \ifdim\pgf@x>\dimexpr\xradius-3mm\relax%
- % to the right
- \advance\pgf@x by -\dimexpr\xradius-3mm\relax%
- \yquant@shape@ellipse@xfromy\yradius{3mm}\pgf@x%
- \advance\pgf@x by \dimexpr\xradius-3mm\relax%
- \ifdim\pgf@y>0pt %
- % to the top
- \pgf@y=\pgf@xa%
- \else%
- % to the bottom
- \pgf@y=-\pgf@xa%
- \fi%
- \else%
- % to the left
- \ifdim\pgf@y>0pt %
- % to the top
- \pgf@y=\yradius\relax%
- \else%
- \pgf@y=-\yradius\relax%
- \fi%
- \fi%
- }%
\backgroundpath{%
\pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
\pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}{\yradius}}%
@@ -586,29 +515,46 @@
\pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
\pgfpathclose%
}%
+ \clippath{%
+ \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \pgfpatharc{90}{-90}{3mm+.5\pgflinewidth and \yradius+.5\pgflinewidth}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {-\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \pgfpathclose%
+ }%
}
-\pgfdeclareshape{yquant-barrier}{%
- % Here, the radii have a special meaning, we don't put text into the shape
- \saveddimen\xradius{%
- \pgf@x=.5\pgflinewidth%
- }%
+\pgfdeclareshape{yquant-line}{%
\savedanchor\shorten{%
\pgfqpoint\pgf@shorten@end@additional\pgf@shorten@start@additional%
}%
+ \saveddimen\xradius{%
+ % we only need this for the border anchor; the value is automatically correct in the paths.
+ \pgf@x=.5\pgflinewidth%
+ }%
\saveddimen\yradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/y radius}+.5*\yquant@config@register@sep}%
}%
- \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+ \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
\inheritanchorborder[from=yquant-rectangle]%
\backgroundpath{%
- \pgfsetlinewidth{\xradius}%
\shorten%
\pgf@xa=\dimexpr\yradius+\pgf@x\relax%
\pgf@ya=\dimexpr\yradius+\pgf@y\relax%
\pgfpathmoveto{\pgfqpoint{0pt}{\pgf@xa}}%
\pgfpathlineto{\pgfqpoint{0pt}{-\pgf@ya}}%
}%
+ \clippath{%
+ \shorten%
+ \@tempdima=\dimexpr\yradius+\pgf@x\relax%
+ \@tempdimb=\dimexpr\yradius+\pgf@y\relax%
+ \pgfpathrectanglecorners
+ {\pgfqpoint{-.5\pgflinewidth}{\@tempdima}}%
+ {\pgfqpoint{.5\pgflinewidth}{-\@tempdimb}}%
+ }%
} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex b/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
index 15d3c328aad..fe1efecbf47 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
@@ -45,6 +45,11 @@
\repeat%
}
+\def\yquant@for@break{%
+ \fi%
+ \iffalse%
+}
+
% Def #1 to be the minimum of #2, ... until \relax
\protected\def\yquant@min#1{%
\def#1{2147483647}%
@@ -92,11 +97,11 @@
% Executes #3 if #1 (single token!) is equal (\ifx) to the first token of #2, and #4 else.
\def\ifyquant@firsttoken#1#2{%
% First check whether #2 is present at all...
- \if\relax\detokenize{#2}\relax%
+ \ifstrempty{#2}{%
\expandafter\@secondoftwo%
- \else%
+ }{%
\ifyquant@firsttoken@aux#1#2\yquant@sep%
- \fi%
+ }%
}
\def\ifyquant@firsttoken@aux#1#2#3\yquant@sep{%
@@ -110,11 +115,7 @@
% Executes #3 if #1 begins with #2, and #4 else - non-expandable
\protected\def\ifyquant@beginswith#1#2{%
\def\ifyquant@beginswith@##1#2##2\yquant@end{%
- \if\relax\detokenize{##1}\relax%
- \expandafter\@firstoftwo%
- \else%
- \expandafter\@secondoftwo%
- \fi%
+ \ifstrempty{##1}%
}%
\ifyquant@beginswith@#1#2\yquant@end%
}
@@ -148,6 +149,14 @@
\expandafter\yquant@sort@aux\expandafter0\expandafter{\the\numexpr\yquant@sort@count-1\relax}%
}
+\def\yquant@sort@ascending#1#2{%
+ \ifnum#2>#1 %
+ \expandafter\@firstoftwo%
+ \else%
+ \expandafter\@secondoftwo%
+ \fi%
+}
+
\protected\def\yquant@sort@aux#1#2{%
\ifnum#1<#2\relax%
\yquant@sort@divide{#1}{#2}%
@@ -159,6 +168,8 @@
\fi%
}
+\def\iftrue@hidden{\iftrue}%
+\def\iffalse@hidden{\iffalse}%
\protected\def\yquant@sort@divide#1#2{%
\count0=#1\relax% i
\count2=#2\relax% j
@@ -167,7 +178,6 @@
\loop%
% search an item from the left that is larger or equal to the pivot
{% protect the outer loop from finding \repeat
- \csletcs{next}{iftrue}%
\loop%
\ifnum\count0<#2\relax%
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\yquant@sort@cmp%
@@ -177,21 +187,20 @@
\expandafter\expandafter\expandafter{%
\csname yquant@sort@item\the\count0\endcsname%
}{%
- \csletcs{next}{iffalse}%
+ \expandafter\iffalse@hidden%
}{%
\advance\count0 by 1 %
+ \expandafter\iftrue@hidden%
}%
\else%
- \csletcs{next}{iffalse}%
+ \expandafter\iffalse@hidden%
\fi%
- \next%
\repeat%
\expandafter%
}%
\expandafter\count\expandafter0\expandafter=\the\count0\relax%
% search an item from the right that is small than the pivot
{% protect the outer loop from finding \repeat
- \csletcs{next}{iftrue}%
\loop%
\ifnum\count2>#1\relax%
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\yquant@sort@cmp%
@@ -202,13 +211,13 @@
\csname yquant@sort@item\the\count2\endcsname%
}{%
\advance\count2 by -1 %
+ \expandafter\iftrue@hidden%
}{%
- \csletcs{next}{iffalse}%
+ \expandafter\iffalse@hidden%
}%
\else%
- \csletcs{next}{iffalse}%
+ \expandafter\iffalse@hidden%
\fi%
- \next%
\repeat%
\expandafter
}%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant.sty b/Master/texmf-dist/tex/latex/yquant/yquant.sty
index 25c0873b70e..c402c6342c4 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant.sty
+++ b/Master/texmf-dist/tex/latex/yquant/yquant.sty
@@ -4,23 +4,23 @@
% Copyright 2019-2020 Benjamin Desef
%
% This work may be distributed and/or modified under the conditions of the LaTeX Project
-% Public License, either version 1.3 of this license or (at your option) any later
+% Public License, either version 1.3c of this license or (at your option) any later
% version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or
+% and version 1.3c or later is part of all distributions of LaTeX version 2005/12/01 or
% later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Benjamin Desef.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{yquant}[2020/03/22 v0.1.1 Yet another quantum circuit library for LaTeX]
+\ProvidesPackage{yquant}[2020/04/11 v0.1.2 Yet another quantum circuit library for LaTeX]
\RequirePackage{etoolbox}[2018/02/11]
\RequirePackage{tikz}[2015/08/29]
\RequirePackage{trimspaces}[2009/09/17]
-\usetikzlibrary{arrows.meta}
+\usetikzlibrary{arrows.meta,decorations.pathreplacing,decorations.pathmorphing}
\input yquant-config.tex
\input yquant-tools.tex