summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2021-04-03 23:54:49 +0000
committerNorbert Preining <preining@logic.at>2021-04-03 23:54:49 +0000
commit32f9a397a899dfac82a4f4d80670f48b675da246 (patch)
tree4d4429493606d826f06de7ae1401bf3a3b667bcc /Master/texmf-dist/tex/latex/yquant/yquant-config.tex
parent8687c318c8de471be301f160ad143242f1a88e68 (diff)
yquant (4apr21)
git-svn-id: svn://tug.org/texlive/trunk@58712 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/yquant/yquant-config.tex')
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-config.tex395
1 files changed, 188 insertions, 207 deletions
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
index a6765d14850..d5844480ee0 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
@@ -13,21 +13,53 @@
\decoration{\pgfkeysvalueof{/pgf/decoration/post}}%
}%
}
+
+% BEGIN_FOLD Circuit layout
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ register/minimum height/.code=%
+ {\dimdef\yquant@config@register@minimum@height{.5\dimexpr#1\relax}%
+ \let\yquant@config@register@minimum@depth=\yquant@config@register@minimum@height}%
+ }
+\else%
+ \pgfqkeys{/yquant}{%
+ register/minimum height/.code=%
+ {\dimdef\yquant@config@register@minimum@height{#1}},%
+ register/minimum depth/.code=%
+ {\dimdef\yquant@config@register@minimum@depth{#1}}%
+ }
+\fi
\pgfqkeys{/yquant}{%
- 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,%
- register/minimum height/.code=%
- {\dimdef\yquant@config@register@minimum@height{#1}},%
register/separation/.code=%
{\dimdef\yquant@config@register@sep{#1}},%
- % register label style
- every label/.style=%
- {shape=yquant-text, anchor=center, align=right},%
+ operator/minimum width/.code=%
+ {\dimdef\yquant@config@operator@minimum@width{#1}},%
+ operator/separation/.code=%
+ {\dimdef\yquant@config@operator@sep{#1}},%
+ operator/multi warning/.is if=%
+ yquant@config@operator@multi@warn%
+}%
+% END_FOLD
+% BEGIN_FOLD Register creation
+\pgfqkeys{/yquant}{%
+ register/default name/.store in=%
+ \yquant@config@register@default@name%
+}
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ every label/.style=%
+ {shape=yquant-init, anchor=center, align=right, outer xsep=2pt},%
+ every multi label/.style=%
+ {draw, decoration={gapped brace, mirror, raise=2pt}, decorate}%
+ }
+\else
+ \pgfqkeys{/yquant}{%
+ every label/.style=%
+ {shape=yquant-init, anchor=center, align=right, outer xsep=2pt,%
+ /yquant/operator/if multi={draw, decoration={gapped brace, mirror, raise=2pt}, decorate}}%
+ }
+\fi
+\pgfqkeys{/yquant}{
every initial label/.style=%
{anchor=east},%
every qubit label/.style=%
@@ -35,25 +67,51 @@
every cbit label/.style=%
{},%
every qubits label/.style=%
- {},%
- every multi label/.style=%
- {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}},%
- every input label/.style=%
- {},%
- % output label styles
- every output/.style=%
- {shape=yquant-text, anchor=west, align=left},%
+ {}%
+}
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ every input label/.style=%
+ {}%
+ }%
+\fi%
+% END_FOLD
+% BEGIN_FOLD Register outputs
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ every output/.style=%
+ {shape=yquant-output, anchor=west, align=left, outer xsep=2pt},%
+ every multi output/.style=%
+ {draw, decoration={gapped brace, raise=2pt}, decorate}%
+ }
+\else
+ \pgfqkeys{/yquant}{%
+ every output/.style=%
+ {shape=yquant-output, anchor=west, align=left, outer xsep=2pt,%
+ /yquant/operator/if multi={draw, decoration={gapped brace, raise=2pt}, decorate}}%
+ }
+\fi
+\pgfqkeys{/yquant}{%
every qubit output/.style=%
{},%
every cbit output/.style=%
{},%
every qubits output/.style=%
- {},%
- every multi output/.style=%
- {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
+ {}%
+}
+% END_FOLD
+% BEGIN_FOLD General styling
+\pgfqkeys{/yquant}{%
+ every circuit/.style={%
+ every node/.prefix style={transform shape}
+ }%
+}
+\@ifpackagelater{pgf}{2020/09/31}\relax{
+ \pgfkeys{/yquant/every circuit/.append style={%
+ every label/.prefix style={transform shape=false}%
+ }}
+}
+\pgfqkeys{/yquant}{%
every wire/.style=%
{draw},%
every qubit wire/.style=%
@@ -62,14 +120,6 @@
{},%
every qubits wire/.style=%
{},%
- % operator settings
- operator/separation/.code=%
- {\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=%
@@ -78,16 +128,10 @@
{fill=black},%
every negative control/.style=%
{draw},%
- % operator style: main part
every operator/.style=%
{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=%
{},%
this control/.style=%
@@ -101,9 +145,66 @@
{/yquant/this operator/.append style={#1},%
/yquant/every control line/.append style={#1},%
/yquant/this control/.append style={#1}},%
- % different operator appearances
+ operator/multi as single/.style=%
+ {/yquant/every multi line/.style=/yquant/every control line},%
+ operator/if multi/.code=%
+ {\ifyquant@config@operator@multi\pgfkeysalso{#1}\fi},%
+ circuit/seamless/.is if=yquant@config@circuit@seamless,%
+ every post measurement control/.is choice,
+ every post measurement control/indirect/.code={%
+ \undef\yquant@lang@attr@directcontrol%
+ },%
+ every post measurement control/direct/.code={%
+ \let\yquant@lang@attr@directcontrol=\relax%
+ }%
+}
+% END_FOLD
+% BEGIN_FOLD Styles for operators
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ operators/every barrier/.style=%
+ {shape=yquant-line, dashed, draw}%
+ }
+\else
+ \pgfqkeys{/yquant}{%
+ operators/every barrier/.style=%
+ {shape=yquant-line, dashed, draw, shorten <= -1mm, shorten >= -1mm}
+ }
+\fi
+\pgfqkeys{/yquant}{%
operators/every box/.style=%
{shape=yquant-rectangle, draw, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm},%
+}
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ operators/every custom gate/.style=%
+ {/yquant/operators/subcircuit/frameless, /yquant/register/default name=}%
+ }
+\else
+ \pgfqkeys{/yquant}{%
+ operators/every custom gate/.style=%
+ {/yquant/operators/subcircuit/seamless}%
+ }
+\fi
+\pgfqkeys{/yquant}{%
+ operators/every dmeter/.style=%
+ {shape=yquant-dmeter, x radius=2mm, y radius=2mm, draw},
+ % every h is implicitly defined during gate declaration
+ operators/every inspect/.style=%
+ {shape=yquant-output, align=left, outer xsep=.3333em, y radius=2.47mm,%
+ /yquant/operator/if multi={draw, decoration={gapped brace, raise=2pt}, decorate}},%
+ operators/every measure/.style=%
+ {shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw},%
+ operators/every measure meter/.style=%
+ {draw, -{Latex[length=2.5pt]}},%
+ operators/every not/.style=%
+ {shape=yquant-oplus, radius=1.3mm, draw},%
+ operators/every pauli/.style=%
+ {/yquant/operators/every box},%
+ operators/every phase/.style=%
+ {shape=yquant-circle, radius=.5mm, fill},%
+ operators/every slash/.style=%
+ {shape=yquant-slash, x radius=.5mm, y radius=.7mm, draw},%
operators/every subcircuit/.style=%
{},%
operators/every subcircuit box/.style=%
@@ -114,181 +215,61 @@
{},%
this subcircuit box style/.style=%
{/yquant/operators/this subcircuit box/.append style={#1}},%
- operators/every custom gate/.style=%
- {/yquant/operators/this subcircuit box/.append style={draw=none, inner sep=0pt},%
- /yquant/register/default name=},
- % every h, every x, every y, every z are implicitly defined during gate declaration
- operators/every pauli/.style=%
- {/yquant/operators/every box},%
- operators/every phase/.style=%
- {shape=yquant-circle, radius=.5mm, fill},%
- operators/every zz/.style=%
- {shape=yquant-circle, radius=.5mm, fill},%
- operators/every xx/.style=%
- {shape=yquant-rectangle, radius=.75mm, draw},%
- operators/every slash/.style=%
- {shape=yquant-slash, x radius=.5mm, y radius=.7mm, draw},%
+ operators/subcircuit/frameless/.style=
+ {/yquant/operators/this subcircuit box/.append style={draw=none, inner sep=0pt}},%
+ operators/subcircuit/seamless/.code=%
+ {\pgfkeysalso{/yquant/operators/subcircuit/frameless, /yquant/register/default name=}%
+ \letcs\yquant@prevseamless{\yquant@prefix seamless}%
+ \yquant@config@circuit@seamlesstrue},
operators/every swap/.style=%
{shape=yquant-swap, radius=.75mm, draw},%
- operators/every not/.style=%
- {shape=yquant-oplus, radius=1.3mm, draw},%
- operators/every measure/.style=%
- {shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw},%
- operators/every measure meter/.style=%
- {draw, -{Latex[length=2.5pt]}},%
- operators/every dmeter/.style=%
- {shape=yquant-dmeter, x radius=2mm, y radius=2mm, draw},%
- operators/every barrier/.style=%
- {shape=yquant-line, dashed, draw},%
operators/every wave/.style=%
+ {shape=yquant-circle, radius=.5mm, fill}%
+ % every x is implicitly defined during gate declaration
+ operators/every xx/.style=%
+ {shape=yquant-rectangle, radius=.75mm, draw},%
+ % every y is implicitly defined during gate declaration
+ % every z is implicitly defined during gate declaration
+ operators/every zz/.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%
- },%
}
+% END_FOLD
+% BEGIN_FOLD Internal styles (undocument, do not use!)
+\pgfqkeys{/yquant}{%
+ internal/move label/.code=%
+ {\yquant@config@operator@position@rightaligntrue},
+ internal/no advance/.code=%
+ {\unless\ifyquantmeasuring% We don't draw subcircuits during measuring time, but we need their advancement
+ \yquant@config@operator@position@advancefalse%
+ \fi},
+ internal/multi main/.is if=%
+ yquant@config@internal@multi@main,%
+}
+\ifnum\yquant@compat<2 %
+ \pgfqkeys{/yquant}{%
+ internal/squeeze slash/.code=%
+ {\dimdef\yquant@config@operator@sep{.5\dimexpr\yquant@config@operator@sep-\pgflinewidth\relax}%
+ \yquant@config@operator@position@advancefalse},%
+ }
+\else%
+ \pgfqkeys{/yquant}{%
+ internal/squeeze slash/.code={}%
+ }
+\fi
+% END_FOLD
\def\yquant@config@register@default@name{\regidx}
-\def\yquant@config@register@minimum@height{3mm}
+\def\yquant@config@register@minimum@height{1.5mm}
+\def\yquant@config@register@minimum@depth{1.5mm}
\def\yquant@config@register@sep{1mm}
\def\yquant@config@operator@sep{1mm}
\def\yquant@config@operator@minimum@width{5mm}
-\newif\ifyquant@config@operator@multi@main%
-\yquant@config@operator@multi@maintrue
+\newif\ifyquant@config@internal@multi@main%
+\yquant@config@internal@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
+\newif\ifyquant@config@operator@position@rightalign
+\newif\ifyquant@config@operator@position@advance
+\yquant@config@operator@position@advancetrue
+\newif\ifyquant@config@circuit@seamless
+\newif\ifyquant@config@operator@multi \ No newline at end of file