Debian Codegraph @

texmf-dist/source/latex/phfqit/phfqit.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2016 by Philippe Faist, [email protected]
4 % -------------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.3 or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % \fi
17 %
18 % \iffalse
19 %<*driver>
20 \ProvidesFile{phfqit.dtx}
21 %</driver>
22 %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
23 %<package>\ProvidesPackage{phfqit}
24 %<*package>
25 [2021/10/08 v4.1 phfqit package]
26 %</package>
27 %
28 %<*driver>
29 \documentclass{ltxdoc}
30 \usepackage{xcolor}
31 \makeatletter
32 \providecommand\phfnote@pkgdoc@setupmainfont{
33 \renewcommand{\rmdefault}{futs}% only rm font, not math
34 }\makeatother
35 \usepackage[preset=xpkgdoc]{phfnote}
36 \usepackage{phfqit}
37 \usepackage{needspace}
38 \EnableCrossrefs
39 \CodelineIndex
40 \RecordChanges
41 \begin{document}
42 \DocInput{phfqit.dtx}
43 \end{document}
44 %</driver>
45 % \fi
46 %
47 % \CheckSum{0}
48 %
49 % \CharacterTable
50 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
51 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
52 % Digits \0\1\2\3\4\5\6\7\8\9
53 % Exclamation \! Double quote \" Hash (number) \#
54 % Dollar \$ Percent \% Ampersand \&
55 % Acute accent \' Left paren \( Right paren \)
56 % Asterisk \* Plus \+ Comma \,
57 % Minus \- Point \. Solidus \/
58 % Colon \: Semicolon \; Less than \<
59 % Equals \= Greater than \> Question mark \?
60 % Commercial at \@ Left bracket \[ Backslash \\
61 % Right bracket \] Circumflex \^ Underscore \_
62 % Grave accent \` Left brace \{ Vertical bar \|
63 % Right brace \} Tilde \~}
64 %
65 %
66 % \changes{v1.0}{2016/04/20}{Initial version}
67 %
68 % \GetFileInfo{phfqit.dtx}
69 %
70 % \DoNotIndex{\newcommand,\newenvironment,\let,\def,\gdef,\edef,\xdef,\if,\else,\fi,\ifx,\cslet,\csdef,\begingroup,\endgroup,\expandafter,\csname,\endcsname,\appto,\hspace,\mathrm,\notblank,\the,\RequirePackage}
71 %
72 % \title{\phfqitltxPkgTitle{phfqit}}
73 % \author{Philippe Faist\quad\email{[email protected]}}
74 % \date{\pkgfmtdate\filedate}
75 % \maketitle
76 %
77 % \begin{abstract}
78 % \pkgname{phfqit}---Utilities to typeset stuff in Quantum Information Theory,
79 % in particular general mathematical symbols, operators, and shorthands for
80 % entropy measures.
81 % \end{abstract}
82 %
83 % \inlinetoc
84 %
85 % \section{Introduction}
86 %
87 % This package provides some useful definitions, mainly for notation of
88 % mathematical expressions which are used in quantum information theory (at
89 % least by me).
90 %
91 % Are included utilities for:
92 % \begin{itemize}
93 % \item General symbols and mathematical expressions (identity operator,
94 % trace, rank, diagonal, \ldots) (\autoref{sec:symbols})
95 % \item Formatting of bits and bit strings (\autoref{sec:bits})
96 % \item Formatting of names of logical gates (\autoref{sec:gates})
97 % \item Typesetting the names of Lie groups and algebras, for example $\su(N)$
98 % (\autoref{sec:Lie-groups-algebras})
99 % \item Bra-ket notation, and delimited expressions such as average, norm,
100 % \ldots (\autoref{sec:delimited})
101 % \item Double bra-ket notation for operators (\autoref{sec:delimited})
102 % \item Typesetting entropy measures, including the Shannon/von Neumann entropy,
103 % the smooth entropies, relative entropies, as well as my coherent relative
104 % entropy
105 % \end{itemize}
106 %
107 %
108 % \section{Basic Usage}
109 %
110 % \label{sec:pkg-options}
111 %
112 % This package is straightforward to use:
113 % \begin{verbatim}
114 % \usepackage{phfqit}
115 % \end{verbatim}
116 %
117 % A single package option controls which entropy measures are defined for you.
118 %
119 % \begin{pkgoptions}
120 % \item[qitobjdef=\meta{\phfverb{stdset} $\mid$ \phfverb{none}}] Load
121 % the predefined set of ``qit objects, '' i.e., entropy measures. The entropy
122 % measures documented below (and specified as such) will be loaded unless you
123 % set \pkgoptionfmt{qitobjdef=none}.
124 % \item[newReIm=\metatruefalsearg] Do not override \LaTeX{}'s default
125 % {\makeatletter $\phfqit@Re$ and $\phfqit@Im$} symbols by $\Re$ and $\Im$.
126 % See \autoref{sec:description-newReIm}.
127 % \item[llanglefrommnsymbolfonts=\metatruefalsearg] In order to define the
128 % operator-kets and operator-bra symbols, we need to have double-angle bracket
129 % symbol delimiters loaded as |\llangle| and |\rrangle|. Unlike |\langle| and
130 % |\rangle|, they are not provided by default by \pkgname{latex},
131 % \pkgname{amsmath} or \pkgname{amssymb}. What we do is that we load the
132 % |\llangle| and |\rrangle| symbols from the MnSymbol fonts in order to define
133 % |\oket| and friends. If you would like to provide your own definitions for
134 % |\llangle| and |\rrangle|, or if you have problems loading the MnSymbol
135 % fonts and don't need the operator-ket symbols, then you can specify
136 % |llanglefrommnsymbolfonts=false| and we won't bother loading the MnSymbol
137 % fonts. (Note that if you provide your own definitions for |\llangle| and
138 % |\rrangle|, they have to be valid delimiters, such that for example the
139 % syntax |\left\llangle| is valid.)
140 % \end{pkgoptions}
141 %
142 % \changed[v2.0-pkg-opt-qitobjdef]{v2.0}{2017/08/16}{Added the
143 % \phfverb{qitobjdef} package option}
144 % \changed[v2.0-pkg-opt-newReIm]{v2.0}{2017/08/16}{Added the \phfverb{newReIm}
145 % package option}
146 %
147 % \subsection{Semantic vs. Syntactic Notation}
148 %
149 % The macros in this package are meant to represent a \emph{mathematical
150 % quantity}, independently of its final \emph{notation}. For example, |\Hmaxf|
151 % indicates corresponds to the ``new-style'' max-entropy defined with the
152 % fidelity,\footnote{see Marco Tomamichel, Ph. D., ETH Zurich (2012)
153 % \href{https://arxiv.org/abs/1203.2142}{arXiv:1203.2142}} independently of the
154 % notation. Then, if the default notation ``$\Hmaxf{}$'' doesn't suit your
155 % taste, you may then simply redefine this command to display whatever you like
156 % (see for example instructions in \autoref{sec:entropy-measures}). This allows
157 % to keep better distinction between different measures which may share the same
158 % notation in different works of literature. It also allows to switch notation
159 % easily, even in documents which use several quantities whose notation may be
160 % potentially conflicting.
161 %
162 %
163 % \subsection{Size Specification}
164 % \label{topic:size-specification-backtick}
165 %
166 % Many of the macros in this package allow their delimiters to be sized
167 % according to your taste. For example, if there is a large symbol in an
168 % entropy measure, say
169 % \begin{align}
170 % \Hmin{\displaystyle\bigotimes_i A_i}[B]\ ,
171 % \end{align}
172 % then it may be necessary to tune the size of the parenthesis delimiters.
173 %
174 % This is done with the optional size specification \meta{size-spec}. The
175 % \meta{size-spec}, whenever it is accepted, is always optional.
176 %
177 % The \meta{size-spec} starts with the backtick character ``|`|'', and is
178 % followed by a single token which may be a star |*| or a size modifier macro
179 % such as |\big|, |\Big|, |\bigg| and |\Bigg|. If the star is specified, then
180 % the delimiters are sized with |\left| and |\right|; otherwise the
181 % corresponding size modifier is used. When no size specification is present,
182 % then the normal character size is used.
183 %
184 % For example:
185 % \begin{center}
186 % \begin{tabular}{ll}
187 % |\Hmin{\bigotimes_i A_i}[B]| & gives\quad $\Hmin{\displaystyle\bigotimes_i A_i}[B]$, \\[1.5em]
188 % |\Hmin`\Big{\bigotimes_i A_i}[B]| & gives\quad $\Hmin`\Big{\displaystyle\bigotimes_i A_i}[B]$,~~and \\[1.5em]
189 % |\Hmin`*{\bigotimes_i A_i}[B]| & gives\quad $\Hmin`*{\displaystyle\bigotimes_i A_i}[B]$. \\
190 % \end{tabular}
191 % \end{center}
192 %
193 %
194 %
195 % \section{General Symbols and Math Operators}
196 % \label{sec:symbols}
197 %
198 % \DescribeMacro{\Hs}
199 % Hilbert space = $\Hs$.
200 %
201 % \DescribeMacro{\Ident}
202 % Identity operator = $\Ident$.
203 %
204 % \DescribeMacro{\IdentProc}
205 % Identity process. Possible usage syntax is:
206 % \begin{center}
207 % \begin{tabular}{lc}
208 % |\IdentProc[A][A']{\rho}| & $\IdentProc[A][A']{\rho}$ \\
209 % |\IdentProc[A]{\rho}| & $\IdentProc[A]{\rho}$ \\
210 % |\IdentProc[A][A']{}| & $\IdentProc[A][A']{}$ \\
211 % |\IdentProc[A]{}| & $\IdentProc[A]{}$ \\
212 % |\IdentProc{}| & $\IdentProc{}$ \\
213 % |\IdentProc{\rho}| & $\IdentProc{\rho}$ \\
214 % |\IdentProc`\big[A]{\rho}| & $\IdentProc`\big[A]{\rho}$ \\
215 % \end{tabular}
216 % \end{center}
217 % This macro accepts a size specification with the backtick (`|`|'), see
218 % \autoref{topic:size-specification-backtick}.
219 %
220 % \begingroup\catcode`\^=12\relax
221 % \DescribeMacro{\ee^X}\endgroup A macro for the exponential. Type the \LaTeX{}
222 % code as if |\ee| were just the symbol, i.e.\@ as |\ee^{<ARGUMENT>}|. The
223 % ideas is that this macro may be redefined to change the appearance of the $e$
224 % symbol, or even to change the notation to |\exp{<ARGUMENT>}| if needed for
225 % inline math.
226 %
227 % \DescribeMacro{\phfqitExpPowerExpression}
228 % To change the appearance of whatever you typed as |\ee^{XYZ}|, you can
229 % redefine |\phfqitExpPowerExpression|; for instance, to use an upright
230 % ``$\mathrm{e}$'' symbol, you could type:
231 % \begin{verbatim}
232 % \renewcommand\phfqitExpPowerExpression[1]{\mathrm{e}^{#1}}
233 % \end{verbatim}
234 %
235 %
236 % \subsection{Math/Linear Algebra Operators}
237 % \label{sec:math-operators}
238 % \label{sec:description-newReIm}
239 %
240 % \needspace{6\baselineskip}
241 % \DescribeMacro{\tr} \DescribeMacro{\supp} \DescribeMacro{\rank}
242 % \DescribeMacro{\linspan} \DescribeMacro{\spec} \DescribeMacro{\diag} Provide
243 % some common math operators. The trace $\tr$, the support $\supp$, the rank
244 % $\rank$, the linear span $\linspan$, the spectrum $\spec$ and the diagonal
245 % matrix $\diag$. (Note that |\span| is already defined by \LaTeX{}, so that we
246 % resort to |\linspan|.) \vspace{1.5cm}
247 %
248 % \DescribeMacro{\Re} \DescribeMacro{\Im} Also, redefine |\Re| and |\Im| (real
249 % and imaginary parts of a complex number), to the more readable $\Re(z)$ and
250 % $\Im(z)$. (The original symbols were {\makeatletter $\phfqit@Re(z)$ and
251 % $\phfqit@Im(z)$}.) Keep the old definitions using the package option
252 % \pkgoptionfmt{newReIm=false}.
253 %
254 % \subsection{Poly symbol}
255 %
256 % \DescribeMacro{\poly} Can be typeset in $\poly(n)$ time.
257 %
258 %
259 % \subsection{Bits and Bit Strings}
260 % \label{sec:bits}
261 %
262 % \DescribeMacro{\bit} Format a bit value, for example |\bit{0}| or |\bit0|
263 % gives $\bit0$ or $\bit1$. This command works both in math mode and text mode.
264 %
265 % \DescribeMacro{\bitstring} Format a bit string. For example
266 % |\bitstring{01100101}| is rendered as \bitstring{01100101}. This command
267 % works both in math mode and text mode.
268 %
269 % \subsection{Logical Gates}
270 % \label{sec:gates}
271 %
272 % \DescribeMacro{\gate} Format a logical gate. Essentially, this command
273 % typesets its argument in small-caps font. For example, with |\gate{C-not}|
274 % you get \gate{C-not}. (The default formatting ignores the given
275 % capitalization, but if you redefine this command you could exploit this,
276 % e.g.\@ by making the ``C'' in ``Cnot'' larger than the ``not''.)
277 %
278 % This command works both in math mode and in text mode.
279 %
280 % \needspace{5\baselineskip}
281 % \DescribeMacro{\AND} \DescribeMacro{\XOR} \DescribeMacro{\CNOT}
282 % \DescribeMacro{\NOT} \DescribeMacro{\NOOP} Some standard gates. These typeset
283 % respectively as \AND, \XOR, \CNOT, \NOT, and \NOOP. \vspace{3\baselineskip}
284 %
285 %
286 % \section{Lie Groups and Algebras}
287 % \label{sec:Lie-groups-algebras}
288 %
289 % \needspace{7\baselineskip}
290 % \DescribeMacro{\uu(N)} \DescribeMacro{\UU(N)} \DescribeMacro{\su(N)}
291 % \DescribeMacro{\SU(N)} \DescribeMacro{\so(N)} \DescribeMacro{\SO(N)}
292 % \DescribeMacro{\slalg(N)} \DescribeMacro{\SL(N)}
293 % \DescribeMacro{\GL(N)} \DescribeMacro{\SN(N)}
294 % Format some common Lie groups and algebras. Note the use of |\slalg| instead
295 % of |\sl| because of name conflict with \TeX's font command {\sl producing
296 % slanted text}.
297 %
298 % |\SN(N)| is the symmetric group of $N$ items, and formats by default as
299 % $\SN(N)$.
300 %
301 % \DescribeMacro{\phfqitLieGroup} \DescribeMacro{\phfqitLieAlgebra}
302 % \DescribeMacro{\phfqitDiscreteGroup}
303 % The macros |\phfqitLieGroup|, |\phfqitLieAlgebra|, and |\phfqitDiscreteGroup|
304 % format the name for a standard Lie group, Lie algebra or discrete group along
305 % with its argument. Redefine these macros with |\renewcommand| to change the
306 % formatting font for Lie groups and algebras for instance. For instance, to
307 % format standard Lie groups/algebras and the permutation group with simple
308 % italic letters, you can use:
309 % \begin{verbatim}
310 % \renewcommand\phfqitLieAlgebra[2]{\mathit{#1}({#2})}
311 % \renewcommand\phfqitLieGroup[2]{\mathit{#1}({#2})}
312 % \renewcommand\phfqitDiscreteGroup[2]{\mathit{#1}_{#2}}
313 % \end{verbatim}
314 %
315 % \verbdef\GLNverbatim=\GL(N)=
316 % \changed[v2.0]{v2.0}{2018/02/28}{Added the macro \GLNverbatim}
317 % \verbdef\SLNverbatim=\slalg(n),\SL(N)=
318 % \changed[v3.0]{v3.0}{2020/07/31}{Added the macros \SLNverbatim, as well
319 % as \phfverb{\phfqitLieAlgebra}, \phfverb{\phfqitLieGroup}, and
320 % \phfverb{\phfqitDiscreteGroup}}
321 %
322 % \iffalse \vspace{3\baselineskip} <-- space for all the \SU(xx) listings in margin \fi
323 %
324 % \section{Bra-Ket Notation and Delimited Expressions}
325 %
326 % \subsection{Bras and kets}
327 % \label{sec:bra-ket}
328 %
329 % All commands here work in math mode only. They all accept a size modifier as
330 % described in \autoref{topic:size-specification-backtick}. (The size may also
331 % be provided as an optional argument; the starred form of the command may also
332 % be used to enclose the delimiters with |\left...\right| and have the size
333 % determined automatically.) Example usage is:
334 % \begin{center}
335 % \begin{tabular}{lc}
336 % |\ket{\psi}| & $\ket{\psi}$ \\[1em]
337 % |\ket`\big{\psi}|~,~~|\ket[\big]{\psi}| & $\ket`\big{\psi}$ \\[1em]
338 % |\ket`\Big{\psi}|~,~~|\ket[\Big]{\psi}| & $\ket`\Big{\psi}$ \\[1em]
339 % |\ket`\bigg{\psi}|~,~~|\ket[\bigg]{\psi}| & $\ket`\bigg{\psi}$ \\[1em]
340 % |\ket`\Bigg{\psi}|~,~~|\ket[\Bigg]{\psi}| & $\ket`\Bigg{\psi}$ \\[1em]
341 % \begin{minipage}{7cm}\relax
342 % \noindent|\ket`*{\displaystyle\sum_k \psi_k}|,\\
343 % \hspace*{2em}|\ket*{\displaystyle\sum_k \psi_k}|
344 % \end{minipage}
345 % & $\ket*{\displaystyle\sum_k \psi_k}$
346 % \end{tabular}
347 % \end{center}
348 %
349 % \DescribeMacro{\ket}
350 % Typeset a quantum mechanical ket. |\ket{\psi}| gives $\ket{\psi}$.
351 %
352 % \DescribeMacro{\bra}
353 % Typeset a bra. |\bra{\psi}| gives $\bra{\psi}$.
354 %
355 % \DescribeMacro{\braket}
356 % Typeset a bra-ket inner product. |\braket{\phi}{\psi}| gives $\braket{\phi}{\psi}$.
357 %
358 % \DescribeMacro{\ketbra}
359 % Typeset a ket-bra outer product. |\ketbra{\phi}{\psi}| gives $\ketbra{\phi}{\psi}$.
360 %
361 % \DescribeMacro{\proj}
362 % Typeset a rank-1 projector determined by a ket. |\proj{\psi}| gives $\proj{\psi}$.
363 %
364 % \DescribeMacro{\matrixel} Typeset a matrix element.
365 % |\matrixel{\phi}{A}{\psi}| gives $\matrixel{\phi}{A}{\psi}$.
366 %
367 % \DescribeMacro{\dmatrixel} Typeset a diagonal matrix element of an operator.
368 % |\dmatrixel{\phi}{A}| gives $\dmatrixel{\phi}{A}$.
369 %
370 % \DescribeMacro{\innerprod} Typeset an inner product using the mathematicians' notation.
371 % |\innerprod{\phi}{\psi}| gives $\innerprod{\phi}{\psi}$.
372 %
373 %
374 % \DescribeMacro{\oket} \DescribeMacro{\obra} \DescribeMacro{\obraket}
375 % \DescribeMacro{\oketbra} \DescribeMacro{\oproj} \DescribeMacro{\omatrixel}
376 % \DescribeMacro{\odmatrixel} This package also provides associated
377 % double-bra-ket commands as is occasionally used to write ``vectors'' in
378 % Hilbert-Schmidt operator space, such as $\oket{A}$, $\obraket{A}{\Ident}$,
379 % $\oketbra{\Ident}{E_k}$, etc. The commands are named |\oket|, |\obra|,
380 % |\obraket|, |\oketbra|, |\oproj|, |\omatrixel|, and |\odmatrixel|.
381 %
382 % The commands |\oket|, |\obra|, |\obraket|, etc.\@ offer the same syntax as
383 % their corresponding |\ket|, |\bra|, etc.\@ counterparts. For instance, you can
384 % type |\obra`\Big{\sum A_i}| to obtain $\obra`\Big{\sum A_i}$.
385 %
386 % \DescribeMacro{\llangle} \DescribeMacro{\rrangle} The \pkgname{phfqit} package
387 % defines the |\llangle| and |\rrangle| delimiters, by taking the relevant
388 % symbols from the \pkgname{MnSymbol} fonts. These double-angle bracket symbols
389 % are used for the double-bra-ket type constructs (|\oket| and friends).
390 %
391 % If you'd like to provide your own definition of |\llangle| and |\rrangle|, or
392 % if for any reason you would not want us to attempt to load the
393 % \pkgname{MnSymbol} fonts at all, then you can set the package option
394 % |llanglefrommnsymbolfonts=false|.
395 %
396 % If you provide your own definition of |\llangle| and |\rrangle|, then make
397 % sure that they are proper \TeX\ delimiters, i.e., constructs of the form
398 % |\left\llangle ... \right\rrangle| or |\bigl\llangle ... \bigr\rrangle| must
399 % work.
400 %
401 % If your document never uses the double-bra-ket macros (i.e., none of the
402 % |\oket|, |\obra|, and friends), then you may safely specifiy
403 % |llanglefrommnsymbolfonts=false| to avoid loading the relevant symbols.
404 %
405 %
406 % \subsection{Delimited expressions: norms, absolute value, etc.}
407 % \label{sec:delimited}
408 %
409 % There are also some commonly used delimited expressions defined for
410 % convenience.
411 %
412 % \DescribeMacro{\abs} The absolute value of an expression. |\abs{A}| gives
413 % $\abs{A}$.
414 %
415 % \DescribeMacro{\avg} The average of an expression. |\avg`\big{\sum_k A_k}|
416 % gives $\avg`\big{\sum_k A_k}$.
417 %
418 % \DescribeMacro{\norm} The norm of an expression. |\norm{A_k}| gives
419 % $\norm{A_k}$. (If you'd like to define customized norms, e.g., to add
420 % subscripts, then check out the |\phfqitDefineNorm| command discussed below.)
421 %
422 % \DescribeMacro{\intervalc} A closed interval. |\intervalc{x}{y}| gives
423 % $\intervalc{x}{y}$.
424 %
425 % \DescribeMacro{\intervalo} An open interval. |\intervalo{x}{y}| gives
426 % $\intervalo{x}{y}$.
427 %
428 % \DescribeMacro{\intervalco} A semi-open interval, closed on the lower bound
429 % and open on the upper bound. |\intervalco{x}{y}| gives $\intervalco{x}{y}$.
430 %
431 % \DescribeMacro{\intervaloc} A semi-open interval, open on the lower bound
432 % and closed on the upper bound. |\intervaloc{x}{y}| gives $\intervaloc{x}{y}$.
433 %
434 %
435 % \DescribeMacro{\phfqitDefineNorm} The handy command |\phfqitDefineNorm| can be
436 % used to define custom norms (e.g. 1-norm, infinity-norm, p/q-norms, etc.).
437 % The syntax is |\phfqitDefineNorm|\meta{command name}\meta{before}\meta{after},
438 % for example:
439 % \begin{verbatim}
440 % \phfqitDefineNorm\onenorm{}{_1}
441 % \phfqitDefineNorm\opnorm{}{_\infty}
442 % \end{verbatim}
443 %
444 % \DescribeMacro{\phfqitDeclarePairedDelimiterXWithAltSizing}
445 % \DescribeMacro{\phfqitDeclarePairedDelimiterXPPWithAltSizing} For defining
446 % more advanced custom delimited expressions, you can use the
447 % |\phfqitDeclarePairedDelimiterXWithAltSizing| and
448 % |\phfqitDeclarePairedDelimiterXPPWithAltSizing| helpers. These macros wrap
449 % the \pkgname{mathtools} package's |\DeclarePairedDelimiterX| and
450 % |\DeclarePairedDelimiterX| macros, by furthermore enabling the newly defined
451 % command to accept the size argument using the backtick syntax described in
452 % \autoref{topic:size-specification-backtick}. These helpers are used
453 % internally to define the commands for kets, bras, norms, etc.
454 %
455 %
456 % \section{Entropy Measures and Other ``Qit Objects''}
457 %
458 % A ``Qit Object'' is any form of quantity which has several parameters and/or
459 % arguments which are put together in some notation. The idea is to use
460 % \LaTeX{} macros to represent an actual quantity and not just some set of
461 % notational symbols. For example, for the ``old'' max-entropy
462 % $H_\mathrm{max,old}(X)_\rho = \log\rank\rho$, you should use |\Hzero|
463 % independently of whether it should be denoted by $H_0$, $H_\mathrm{max}$ or
464 % $H_\mathrm{max,old}$. This allows you to change the notation by redefining
465 % the command |\Hzero|, while making sure that the correct quantity is
466 % addressed. (You might have both ``old''-style and ``new''-style max-entropy
467 % in the same paper. Their meaning should never change, even if you change your
468 % mind on the notation.) The macros |\Hmin|, |\Hzero|, |\Hmaxf| and |\HH| may
469 % be redefined to change the subscript by using the following code (change
470 % ``|\mathrm{max},0|'' to your favorite subscript text):
471 % \begin{verbatim}
472 % \renewcommand{\Hzero}{\Hbase{\HSym}{\mathrm{max},0}}
473 % \end{verbatim}
474 %
475 % The \pkgname{phfqit} package provides a basic infrastructure allowing to
476 % define such ``Qit Object'' implementations. This package provides the
477 % following Qit Objects: entropy measures (|\Hbase|), an entropy function
478 % (|\Hfnbase|), relative entropy measures (|\Dbase|), as well as coherent
479 % relative entropy measures (|\DCohbase|). The more specific commands |\Hmin|,
480 % |\Hzero|, etc.\@ are then defined based on these ``base commands.''
481 %
482 % You may also define your own Qit Object implementations. See
483 % \autoref{sec:QitObjectImpl} for documentation on that.
484 %
485 % The actual entropy measure definitions |\Hmin|, |\Hmaxf|, etc., can be
486 % disabled by specifying the package option \pkgoptionfmt{qitobjdef=none}.
487 %
488 %
489 % \subsection{Entropy, Conditional Entropy}
490 % \label{sec:entropy-measures}
491 %
492 % These entropy measures all share the same syntax. This syntax is only
493 % described for the min-entropy |\Hmin|, but the other entropy measures enjoy
494 % the same features.
495 %
496 % These commands are robust, meaning they can be used for example in figure
497 % captions and section headings.
498 %
499 % \DescribeMacro{\Hmin} Min-entropy. The general syntax is
500 % |\Hmin|\hspace{0pt}\meta{size-spec}\relax
501 % \hspace{0pt}\oarg{state}\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
502 % \marg{target system}\hspace{0pt}\oarg{conditioning system}. For example:
503 % \begin{center}
504 % \begin{tabular}{lc}
505 % |\Hmin{X}| & $\Hmin{X}$ \\
506 % |\Hmin[\rho]{X}| & $\Hmin[\rho]{X}$ \\
507 % |\Hmin[\rho][\epsilon]{X}[Y]| & $\Hmin[\rho][\epsilon]{X}[Y]$ \\
508 % \verb+\Hmin[\rho|\rho][\epsilon]{X}[Y]+
509 % & $\Hmin[\rho\mid\rho][\epsilon]{X}[Y]$ \\
510 % |\Hmin[][\epsilon]{X}[Y]| & $\Hmin[][\epsilon]{X}[Y]$ \\[1ex]
511 % |\Hmin`\Big[\rho]{X}[Y]| & $\Hmin`\Big[\rho][\epsilon]{X}[Y]$ \\[0.5ex]
512 % |\Hmin`*[\rho]{\bigoplus_i X_i}[Y]| &
513 % $\displaystyle\Hmin`*[\rho][\epsilon]{\bigoplus_i X_i}[Y]$
514 % \end{tabular}
515 % \end{center}
516 %
517 % \DescribeMacro{\HH} Shannon/von Neumann entropy. This macro has the same
518 % arguments as for |\Hmin| (even though, of course, there is no real use in
519 % smoothing the Shannon/von Neumann entropy\ldots). For example,
520 % |\HH[\rho]{X}[Y]| gives $\HH[\rho]{X}[Y]$.
521 %
522 % \DescribeMacro{\Hzero} R\'enyi-zero max-entropy. This macro has the same
523 % arguments as for |\Hmin|. For example, |\Hzero[][\epsilon]{X}[Y]| gives
524 % $\Hzero[][\epsilon]{X}[Y]$.
525 %
526 % \DescribeMacro{\Hmaxf} The max-entropy. This macro has the same
527 % arguments as for |\Hmin|. For example, |\Hmaxf[][\epsilon]{X}[Y]| gives
528 % $\Hmaxf[][\epsilon]{X}[Y]$.
529 %
530 % The commands |\Hmin|, |\HH|, |\Hzero|, and |\Hmaxf| are defined only if the
531 % package option \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
532 %
533 % \DescribeMacro{\HSym} You may redefine this macro if you want to change the
534 % ``$H$'' symbol of all entropy measures.
535 % \begingroup \def\HSym{\spadesuit} For example, with
536 % |\renewcommand\HSym{\spadesuit}|, |\Hmin{A}[B]| would give $\Hmin{A}[B]$.
537 % \endgroup
538 %
539 % \paragraph{Appearance and alternative notation.}
540 % You may change the notation of any of the above entropy measures by redefining
541 % the corresponding commands as follows:
542 % \begin{verbatim}
543 % \renewcommand{\Hzero}{\Hbase{\HSym}{\mathrm{max}}}
544 % \end{verbatim}
545 % \begingroup\renewcommand{\Hzero}{\Hbase{\HSym}{\mathrm{max}}}
546 % Then, |\Hzero[\rho]{A}[B]| would produce: $\Hzero[\rho]{A}[B]$.\endgroup
547 %
548 % \paragraph{Base entropy measure macro.}
549 % \DescribeMacro{\Hbase} Base macro entropy for an entropy measure. The general
550 % syntax is:
551 % |\Hbase|\hspace{0pt}\marg{H-symbol}\hspace{0pt}\marg{subscript}\relax
552 % \hspace{0pt}\oarg{state}\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
553 % \marg{target system}\hspace{0pt}\oarg{conditioning system}
554 %
555 % Using this macro it is easy to define custom special-purpose entropy measures,
556 % for instance:
557 % \begin{verbatim}
558 % \newcommand\Hxyz{\Hbase{\tilde\HSym}{\mathrm{xyz}}}
559 % \end{verbatim}
560 % \begingroup\newcommand\Hxyz{\Hbase{\tilde\HSym}{\mathrm{xyz}}}
561 % The above code defines the command |\Hxyz[\rho][\epsilon]{A}[B]| $\to$
562 % \fbox{$\Hxyz[\rho][\epsilon]{A}[B]$}. \endgroup
563 %
564 % See also the implementation documentation below for more specific information
565 % on how to customize parts of the rendering, for instance.
566 %
567 % \subsection{Entropy Function}
568 % \label{sec:entropy-function}
569 %
570 % \DescribeMacro{\Hfn} The entropy, written as a mathematical function. It is
571 % useful to write, e.g., $\Hfn(p_1\rho_1 + p_2\rho_2)$ as \relax
572 % |\Hfn(p_1\rho_1 + p_2\rho_2)|. Sizing specifications also work, e.g.\@
573 % |\Hfn`\big(x)| or |\Hfn`*(x)|.
574 %
575 % Usage is: |\Hfn|\hspace{0pt}\meta{size-spec}\hspace{0pt}|(|\meta{argument}|)|
576 %
577 % This macro doesn't allow for any subscript, any epsilon-like superscript nor
578 % for any conditioning system. Define your own macro on top of |\Hfnbase| if
579 % you need that.
580 %
581 % Note that the \meta{argument} may contain matching parentheses, e.g.,
582 % |\Hfn`\Big( g(x) + h(y) )| $\to$ \fbox{$\Hfn`\Big(g(x)+h(y))$}.
583 %
584 % \DescribeMacro{\Hfunc}
585 % The alias |\Hfunc| is provided for backwards compatibility; same as |\Hfn|.
586 %
587 % The commands |\Hfn| and |\Hfunc| are defined only if the package option
588 % \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
589 %
590 % \DescribeMacro{\Hfnbase} There is also a base macro for this kind of Qit
591 % Object, |\Hfnbase|. It allows you to specify an arbitrary symbol to use for
592 % ``$H$'', as well as custom subscripts and superscripts. The syntax is:
593 %
594 % |\Hfnbase|\marg{H-symbol}\hspace{0pt}\marg{sub}\hspace{0pt}\relax
595 % \marg{sup}\hspace{0pt}\relax
596 % \meta{size-spec}\hspace{0pt}|(|\meta{argument}|)|.
597 %
598 %
599 % \subsection{Relative Entropy}
600 % \label{sec:relative-entropies}
601 %
602 % Relative entropies also have a corresponding set of commands.
603 %
604 % The syntax varies from command to command, but all relative entropies accept
605 % the final arguments \meta{size-spec}\marg{state}\marg{relative-to-state}. The
606 % size-spec is as always given using the backtick syntax described in
607 % \autoref{topic:size-specification-backtick}.
608 %
609 % \DescribeMacro{\DD}
610 % Generic relative entropy. The syntax of this command is either of the following:
611 % \par
612 % |\DD|\hspace{0pt}\meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state},\\
613 % |\DD_|\marg{subscript}\hspace{0pt}\meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state},\\
614 % |\DD_|\marg{subscript}|^|\marg{superscript}\hspace{0pt}\meta{size-spec}\relax
615 % \hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state},\\
616 % |\DD^|\marg{superscript}\hspace{0pt}\meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state}.
617 %
618 % In all cases, the argument is typeset as:
619 % $\bigl(\meta{state}\big\Vert\meta{relative-to state}\bigr)$. The size of the
620 % delimiters can be set with a size specification using the standard backtick
621 % syntax as described in \autoref{topic:size-specification-backtick} (as for the
622 % other entropy measures).
623 %
624 % Examples:
625 % \begin{center}
626 % \begin{tabular}{lc}
627 % |\DD{\rho}{\sigma}| & $\DD{\rho}{\sigma}$ \\[1ex]
628 % |\DD`*{M_1^\dagger M_1}{\sigma}| & $\DD`*{M_1^\dagger M_1}{\sigma}$ \\[1ex]
629 % |\DD`\Big{\rho}{\sigma}| & $\DD`\Big{\rho}{\sigma}$ \\
630 % \end{tabular}
631 % \end{center}
632 %
633 % You can also play around with subscripts and superscripts, but it is
634 % recommended to use the macros |\Dminf|, |\Dminz| and |\Dmax| directly.
635 % Specifying the subscripts and superscripts to |\DD| should only be done within
636 % new custom macros to define new relative entropy measures.
637 % \begin{center}
638 % \begin{tabular}{lc}
639 % |\DD_{\mathrm{Rob}}^{\epsilon}{\rho}{\sigma}| & $\DD_{\mathrm{Rob}}^{\epsilon}{\rho}{\sigma}$ \\
640 % |\DD^{sup}{\rho}{\sigma}| & $\DD^{sup}{\rho}{\sigma}$ \\
641 % \end{tabular}
642 % \end{center}
643 %
644 % \DescribeMacro{\Dmax} The max-relative entropy. The syntax is
645 % |\Dmax|\hspace{0pt}\oarg{epsilon}\hspace{0pt}\meta{size-spec}\relax
646 % \hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state}
647 %
648 % For example |\Dmax[\epsilon]{\rho}{\sigma}| gives
649 % $\Dmax[\epsilon]{\rho}{\sigma}$ and |\Dmax[\epsilon]`\big{\rho}{\sigma}| gives
650 % $\Dmax[\epsilon]`\big{\rho}{\sigma}$.
651 %
652 % \DescribeMacro{\Dminz} The ``old'' min-relative entropy, based on the
653 % R\'enyi-zero relative entropy. The syntax is the same as for
654 % |\Dmax|.
655 %
656 % \DescribeMacro{\Dminf} The ``new'' min-relative entropy, defined using the
657 % fidelity. The syntax is the same as for |\Dmax|.
658 %
659 % \DescribeMacro{\Dr} The Rob-relative entropy. The syntax is the same as for
660 % |\Dmax|.
661 %
662 % \DescribeMacro{\DHyp} \DescribeMacro{\Dhyp} The hypothesis testing relative
663 % entropy (two possible variants). The syntax is the same as for |\Dmax|,
664 % except that by default the optional argument is |\eta|. The symbols
665 % `$\mathrm{H}$' and `$\mathrm{h}$' are used as subscripts, respectively, for
666 % |\DHyp| and |\Dhyp|. Examples: The code |\DHyp{\rho}{\sigma}| gives
667 % $\DHyp{\rho}{\sigma}$ and |\Dhyp[\eta']{\rho}{\sigma}| gives
668 % $\Dhyp[\eta']{\rho}{\sigma}$. (This is because this quantity is directly
669 % defined with a $\eta$ (or $\epsilon$) built in, and it is not a zero-error
670 % quantity which is smoothed with the purified distance.)
671 %
672 % The commands |\DD|, |\Dmax|, |\Dminz|, |\Dminf|, |\Dr|, |\DHyp| and |\Dhyp|
673 % are defined only if the package option \pkgoptionfmt{qitobjdef=stdset} is set
674 % (which is the default).
675 %
676 % \changedreftext{v3.1-added-Dhyp-qitobjdef-stdset}
677 %
678 % \DescribeMacro{\DSym} The symbol to use to denote a relative entropy. You
679 % may redefine this command to change the symbol. (This works like |\HSym|
680 % above.)
681 %
682 % \paragraph{Appearance and alternative notation}
683 % You may change the notation of any of the above relative entropy measures by
684 % redefining the corresponding commands as follows:
685 % \begin{verbatim}
686 % \renewcommand{\Dminz}[1][]{\Dbase{\DSym}_{\mathrm{MIN}}^{#1}}
687 % \end{verbatim}
688 % \begingroup\renewcommand{\Dminz}[1][]{\Dbase{\DSym}_{\mathrm{MIN}}^{#1}}
689 % The above command produces: |\Dminz[\epsilon]{\rho}{\sigma}| $\to$
690 % \fbox{$\Dminz[\epsilon]{\rho}{\sigma}$}.\endgroup
691 %
692 %
693 % \paragraph{Base relative entropy command}
694 % As for the $H$-type entropy measures, there is a ``base relative entropy
695 % command'' |\Dbase|. Its syntax is:
696 % \par |\Dbase|\marg{D-symbol}\hspace{0pt}\relax
697 % [|_|\marg{subscript}][|^|\marg{superscript}]\hspace{0pt}\meta{size-spec}\relax
698 % \hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state}
699 %
700 % Example: |\Dbase{\hat\DSym}_{0}^{\eta'}`\Big{\rho}{\sigma}| $\to$
701 % \fbox{$\Dbase{\hat\DSym}_{0}^{\eta'}`\Big{\rho}{\sigma}$}
702 %
703 % The ``|_|\marg{subscript}'' and ``|^|\marg{superscript}'' parts are optional
704 % and may be specified in any order.
705 %
706 % See also the implementation documentation below for more specific information
707 % on how to customize parts of the rendering, for instance.
708 %
709 %
710 % \subsection{Coherent Relative Entropy}
711 % \label{sec:coh-rel-entr}
712 %
713 % A macro for the coherent relative entropy is also available.
714 %
715 % \DescribeMacro{\DCohx} Typeset a coherent relative entropy using an
716 % alternative form for the reference system. The syntax is:
717 %
718 % |\DCohx|\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
719 % \meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
720 % \marg{X}\hspace{0pt}\marg{X'}\hspace{0pt}\relax
721 % \marg{$\Gamma_X$}\hspace{0pt}\marg{$\Gamma_{X'}$}
722 %
723 % For example, |\DCohx[\epsilon]{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}| gives
724 % $\DCohx[\epsilon]{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}$.
725 %
726 % The subscript $X'R_X$ (or whatever the system names) is automatically added to
727 % the \meta{rho} argument. The `$R$' symbol is used by default for designating
728 % the reference system; you may change that by redefining |\DCohxRefSystemName|
729 % (see below). If no subscript should be added to the \meta{rho} argument, then
730 % begin the \meta{rho} argument with a star. For example,
731 % |\DCoh{*\sigma_R\otimes\rho_{X'}}{X}{X'}{\Gamma_X}{\Gamma_{X'}}| gives
732 % $\DCoh{*\sigma_R\otimes\rho_{X'}}{X}{X'}{\Gamma_X}{\Gamma_{X'}}$.
733 %
734 % The \meta{size-spec} is of course optional and follows the same syntax as
735 % everywhere else (\autoref{topic:size-specification-backtick}).
736 %
737 % The command |\DCohx| is defined only if the package option
738 % \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
739 %
740 % \DescribeMacro{\emptysystem} Use the |\emptysystem| macro to denote a trivial
741 % system. For example, |\DCoh{\rho}{X}{\emptysystem}{\Gamma}{1}| gives
742 % $\DCoh{\rho}{X}{\emptysystem}{\Gamma}{1}$.
743 %
744 % \DescribeMacro{\DCohxRefSystemName} When using |\DCohx|, the macro
745 % |\DCohxRefSystemName| is invoked to produce the reference system name
746 % corresponding to the input system name. By default, this is a $R_\cdot$
747 % symbol with subscript the input system name. You may redefine this macro if
748 % you prefer another reference system name:
749 % \begin{verbatim}
750 % \renewcommand\DCohxRefSystemName[1]{E_{#1}}
751 % \end{verbatim}
752 % \begin{flushleft}
753 % \begingroup\renewcommand\DCohxRefSystemName[1]{E_{#1}}
754 % Then: |\DCohx{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}| $\to$
755 % $\DCohx{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}$
756 % \endgroup
757 % \end{flushleft}
758 %
759 % \DescribeMacro{\DCSym} The symbol to use to denote a coherent relative
760 % entropy. You may redefine this command to change the symbol. (This works
761 % like |\HSym| and |\DSym| above.)
762 %
763 % \DescribeMacro{\DCoh}
764 % Typeset a coherent relative entropy using the old notation. The syntax is:
765 %
766 % |\DCoh|\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
767 % \meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
768 % \marg{R}\hspace{0pt}\marg{X'}\hspace{0pt}\relax
769 % \marg{$\Gamma_R$}\hspace{0pt}\marg{$\Gamma_{X'}$}
770 %
771 % For example, |\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}| gives
772 % $\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}$.
773 %
774 % The subscript $X'R$ (or whatever the system names) is automatically added to
775 % the \meta{rho} argument. If this is not desired, then begin the \meta{rho}
776 % argument with a star. For example,
777 % |\DCoh{*\sigma_R\otimes\rho_{X'}}{R}{X'}{\Gamma_R}{\Gamma_{X'}}| gives
778 % $\DCoh{*\sigma_R\otimes\rho_{X'}}{R}{X'}{\Gamma_R}{\Gamma_{X'}}$.
779 %
780 % The \meta{size-spec} is of course optional and follows the same syntax as
781 % everywhere else (\autoref{topic:size-specification-backtick}).
782 %
783 % The command |\DCoh| is defined only if the package option
784 % \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
785 %
786 %
787 % \paragraph{Appearance and alternative notation}
788 % You may change the notation of any of the above relative entropy measures by
789 % redefining the corresponding commands as follows:
790 % \begin{verbatim}
791 % \renewcommand{\DCoh}{\DCohbase{\tilde\DSym}}
792 % \end{verbatim}
793 % \begingroup\renewcommand{\DCoh}{\DCohbase{\tilde\DSym}}
794 % Then: |\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}| $\to$
795 % \fbox{$\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}$}.\endgroup
796 %
797 %
798 % \paragraph{Base relative entropy command}
799 % As for the other entropy measures, there is a ``base coherent relative entropy
800 % command'' |\DCohbase|. Its syntax is:
801 % \par |\DCohbase|\marg{D-symbol}\hspace{0pt}\relax
802 % \hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
803 % \meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
804 % \marg{R}\hspace{0pt}\marg{X'}\hspace{0pt}\relax
805 % \marg{$\Gamma_R$}\hspace{0pt}\marg{$\Gamma_{X'}$}
806 %
807 % See also the implementation documentation below for more specific information
808 % on how to customize parts of the rendering, for instance.
809 %
810 %
811 %
812 % \subsection{Custom Qit Objects}
813 % \label{sec:QitObjectImpl}
814 %
815 % \changedreftext{v2.0-qit-objects}
816 %
817 % You can create your own Qit Object Implementation as follows. You need two
818 % components: a \emph{Parse} macro and a \emph{Render} macro.
819 %
820 % The \emph{Parse} macro is responsible for parsing input \LaTeX{} tokens as
821 % necessary, and building an argument list (which will be passed on to the
822 % \emph{Render} macro).
823 %
824 % \DescribeMacro{\qitobjAddArg} \DescribeMacro{\qitobjAddArgx} The \emph{Parse}
825 % macro (or any helper macro it calls) should call |\qitobjAddArg| to add
826 % arguments for the eventual call to \emph{Render}. The |\qitobjAddArg| macro
827 % does not expand its argument. The |\qitobjAddArgx| works like
828 % |\qitobjAddArg|, but it accepts a single \LaTeX{} command as its only
829 % argument, expands it, and adds the contents as a single new argument for the
830 % renderer.
831 %
832 % \DescribeMacro{\qitobjParseDone}
833 % Once the parser is finished, it must call |\qitobjParseDone|.
834 %
835 % The \emph{Render} macro is responsible for displaying the final Qit Object.
836 % It should accept mandatory arguments in the exact number as there were calls
837 % to |\qitobjAddArg|/|\qitobjAddArgx|.
838 %
839 % \DescribeMacro{\qitobjDone} The \emph{Render} macro must call |\qitobjDone|
840 % after it is finished, to do some cleaning up and to close the local \LaTeX{}
841 % group generated by the Qit Ojbect infrastructure.
842 %
843 % \DescribeMacro{\DefineQitObject} Declare your new Qit Object using the
844 % |\DefineQitObject| macro, using the syntax
845 % |\DefineQitObject|\marg{name}\marg{ParseCommand}\marg{RenderCommand}.
846 % This declares the command |\|\meta{name} as your Qit Object.
847 %
848 % You may define different Qit Objects (using different names) recycling the
849 % same parsers/renderers if needed. For instance, |\Hfnbase| uses the same
850 % renderer as |\Hbase|.
851 %
852 % \DescribeMacro{\DefineTunedQitObject} The |\DefineTunedQitObject| macro is a
853 % bit more powerful. It allows you to specify some fixed initial arguments to
854 % the parser, as well as to provide some local definitions which are in effect
855 % only during parsing and rendering of the Qit Object. This is useful if you
856 % would like to declare an alternative type of Qit Object to an existing one,
857 % where you just change some aspect of the behavior of the original Qit Object.
858 %
859 % Usage: |\DefineTunedQitObject|\hspace{0pt}\marg{name}\relax
860 % \marg{parse command}\hspace{0pt}\marg{render command}\hspace{0pt}\relax
861 % \marg{fixed first argument(s)}\hspace{0pt}\marg{custom definitions}\relax
862 %
863 % The \marg{first fixed argument(s)} must be a single argument, i.e., a single
864 % \LaTeX{} group, which may contain several arguments, for instance: |{{A}{B}}|.
865 %
866 % For instance, |\DCohx| is defined, using the same parser and renderer as for
867 % |\DCoh|, as follows:
868 % \begin{verbatim}
869 %\def\DCohxRefSystemName#1{R_{#1}}
870 %\def\DCohxStateSubscripts#1#2{#2\DCohxRefSystemName{#1}}
871 %\DefineTunedQitObject{DCohx}{\DCohbaseParse}{\DCohbaseRender}%
872 %{{\DCSym}}% initial args
873 %{\let\DCohbaseStateSubscripts\DCohxStateSubscripts}% local defs
874 % \end{verbatim}
875 %
876 %
877 % \paragraph{Useful helpers}
878 %
879 % There are some useful helpers for both the \emph{Parse} and \emph{Render}
880 % macros. More extensive documentation is available in the ``Implementation''
881 % section below.
882 %
883 % \DescribeMacro{\phfqit@parse@sizesarg} Parse a \meta{size-spec} optional
884 % argument.
885 %
886 % \needspace{3\baselineskip}
887 % \DescribeMacro{\phfqitParen} \DescribeMacro{\phfqitSquareBrackets}
888 % \DescribeMacro{\phfqitCurlyBrackets} Produce a parenthetic expression (or
889 % square or curly brackets) with the appropriate size and with the given
890 % contents.
891 %
892 % \paragraph{Example}
893 % Here is a simple example: let's build a work cost of transition Qit Object to
894 % display something like ``$W(\sigma\to\rho)$.''
895 %
896 % The arguments to be given are: they are \meta{$\sigma$} and \meta{$\rho$}. We
897 % would also like to accept an optional size specification \meta{size-spec}. We
898 % should decide on a convenient syntax to specify them. Here, we'll settle for
899 % simply |\WorkCostTransition`\Big{\rho}{\sigma}|.
900 %
901 % We can now write the \emph{Parse} macro. We use the |\phfqit@parsesizearg|
902 % helper, which stores the optional \meta{size-spec} into the
903 % |\phfqit@val@sizearg| macro before deferring our second helper macro. We then
904 % add arguments (for an eventual call to the \emph{Render} macro) using
905 % |\qitobjAddArg| (or |\qitobjAddArgx|).
906 % \begin{verbatim}
907 % \makeatletter
908 % \newcommand\WorkCostTransitionParse{%
909 % \phfqit@parsesizearg\WorkCostTransitionParse@%
910 % }
911 % % Helper to parse further input arguments:
912 % \newcommand\WorkCostTransitionParse@[2]{% {\rho}{\sigma}
913 % \qitobjAddArgx\phfqit@val@sizearg% size arg
914 % \qitobjAddArg{#1}% rho
915 % \qitobjAddArg{#2}% sigma
916 % \qitobjParseDone%
917 % }
918 % \makeatother
919 % \end{verbatim}
920 %
921 % The render macro should simply display the quantity, with the arguments given
922 % as usual mandatory arguments. We invoke the |\phfqitParens| helper, which
923 % produces the parenthesis at the correct size given the size spec tokens.
924 % \begin{verbatim}
925 % \newcommand\WorkCostTransitionRender[3]{% {size-spec-tokens}{\rho}{\sigma}
926 % W\phfqitParens#1{#2 \to #3}%
927 % \qitobjDone
928 % }
929 % \end{verbatim}
930 %
931 % Now declare the Qit Object:
932 % \begin{verbatim}
933 % \DefineQitObject{WorkCostTransition}{\WorkCostTransitionParse}{\WorkCostTransitionRender}
934 % \end{verbatim}
935 % \begingroup\makeatletter
936 % \newcommand\WorkCostTransitionParse{\relax
937 % \phfqit@parsesizearg\WorkCostTransitionParse@}
938 % \newcommand\WorkCostTransitionParse@[2]{\relax
939 % \qitobjAddArgx\phfqit@val@sizearg\relax
940 % \qitobjAddArg{#1}\relax
941 % \qitobjAddArg{#2}\relax
942 % \qitobjParseDone}
943 % \newcommand\WorkCostTransitionRender[3]{W\phfqitParens#1{#2 \to #3}\qitobjDone}
944 % \DefineQitObject{WorkCostTransition}{\WorkCostTransitionParse}{\WorkCostTransitionRender}
945 % Then: |\WorkCostTransition`\Big{\rho}{\sigma}| $\to$
946 % \fbox{$\WorkCostTransition`\Big{\rho}{\sigma}$}
947 % \endgroup
948 %
949 % You might want to check out the implementations of |\HbaseParse| and
950 % |\HbaseRender|, or |\DbaseParse| and |\DbaseRender| if you'd like to see some
951 % more involved examples.
952 %
953 %
954 %
955 %
956 %
957 % \StopEventually{\clearpage\PrintChanges
958 % \vspace{2cm plus 2cm minus 2cm}\PrintIndex}
959 %
960 % \section{Implementation}
961 %
962 % First, load dependent packages. Toolboxes, fonts and so on.
963 % \begin{macrocode}
964 \RequirePackage{calc}
965 \RequirePackage{etoolbox}
966 \RequirePackage{amsmath}
967 \RequirePackage{amssymb}
968 \RequirePackage{dsfont}
969 \RequirePackage{mathrsfs}
970 \RequirePackage{mathtools}
971 % \end{macrocode}
972 %
973 % Package \pkgname{xparse} is needed in order to get paren matching right for
974 % |\Hfn|.
975 % \begin{macrocode}
976 \RequirePackage{xparse}
977 % \end{macrocode}
978 %
979 % Package options are handled via \pkgname{xkeyval} \& \pkgname{kvoptions} (see
980 % implementation doc for \pkgname{phfnote}).
981 % \begin{macrocode}
982 \RequirePackage{xkeyval}
983 \RequirePackage{kvoptions}
984 % \end{macrocode}
985 %
986 % \subsection{Simple Symbols and Shorthands}
987 %
988 %
989 % \subsubsection{General Symbols}
990 %
991 % These symbols are documented in \autoref{sec:symbols}.
992 %
993 % \begin{macro}{\Hs}
994 % Hilbert space.
995 % \begin{macrocode}
996 \newcommand{\Hs}{\mathscr{H}}
997 % \end{macrocode}
998 % \end{macro}
999 %
1000 % \begin{macro}{\Ident}
1001 % Identity operator, $\Ident$.
1002 % \begin{macrocode}
1003 \newcommand{\Ident}{\mathds{1}}
1004 % \end{macrocode}
1005 % \end{macro}
1006 %
1007 %
1008 % \begin{macro}{\IdentProc}
1009 % Identity process.
1010 %
1011 % TODO: this could be implemented as a Qit Object.
1012 % \begin{macrocode}
1013 \def\IdentProc{%
1014 \phfqit@parsesizearg\phfqit@IdentProc@maybeA%
1015 }
1016 \newcommand\phfqit@IdentProc@maybeA[1][]{%
1017 \def\phfqit@IdentProc@val@A{#1}%
1018 \phfqit@IdentProc@maybeB%
1019 }
1020 \newcommand\phfqit@IdentProc@maybeB[1][]{%
1021 \def\phfqit@IdentProc@val@B{#1}%
1022 \phfqit@IdentProc@arg%
1023 }
1024 \def\phfqit@IdentProc@arg#1{%
1025 \def\phfqit@IdentProc@val@arg{#1}%
1026 % \end{macrocode}
1027 %
1028 % At this point, prepare the three arguments, each expanded exactly as they were when
1029 % given to these macros, and delegate the formatting to |\phfqit@IdentProc@do|.
1030 % \begin{macrocode}
1031 \edef\@tmp@args{%
1032 {\expandonce{\phfqit@IdentProc@val@A}}%
1033 {\expandonce{\phfqit@IdentProc@val@B}}%
1034 {\expandonce{\phfqit@IdentProc@val@arg}}%
1035 }%
1036 \expandafter\phfqit@IdentProc@do\@tmp@args%
1037 }
1038 \def\phfqit@IdentProc@do#1#2#3{%
1039 \operatorname{id}_{#1\notblank{#2}{\to #2}{}}%
1040 \notblank{#3}{\expandafter\phfqitParens\phfqit@val@sizearg{#3}}{}%
1041 }
1042 % \end{macrocode}
1043 % \end{macro}
1044 %
1045 %
1046 %
1047 % \begingroup\catcode`\^=12\relax
1048 % \begin{macro}{\ee^...}
1049 % Macro for the exponential.
1050 %
1051 % Because the character |^| might have different catcodes (e.g. with the
1052 % \pkgname{breqn} package), we use a hack with |\detokenize|. Basically this
1053 % boils down to |\def\ee^#1{\phfqitExpPowerExpression{#1}}| and
1054 % |\def\phfqitExpPowerExpression#1{e^{#1}}|, up to making sure that all the
1055 % |^| symbols are compared without catcodes.
1056 %
1057 % \changed[v4.0-fixed-ee-for-catcodes]{v4.0}{2021/10/07}{Fixed the definition
1058 % of \phfverb{\ee} in order to support the case where the catcode of
1059 % \phfverb{^} changes}
1060 % \begin{macrocode}
1061 \edef\phfqit@def@hat{\detokenize{^}}
1062 \expandafter\def\expandafter\phfqit@ee@gobblehat\phfqit@def@hat{%
1063 \phfqitExpPowerExpression}
1064 \def\phfqitExpPowerExpression#1{e^{#1}}
1065 \def\ee#1{\expandafter\phfqit@ee@gobblehat\detokenize{#1}}
1066 \robustify\phfqitExpPowerExpression
1067 \robustify\ee
1068 % \end{macrocode}
1069 % \end{macro}
1070 % \endgroup
1071 %
1072 % \subsubsection{Math Operators}
1073 %
1074 % See user documentation in \autoref{sec:math-operators}.
1075 %
1076 % \needspace{6\baselineskip}
1077 % \begin{macro}{\tr}
1078 % \begin{macro}{\supp}
1079 % \begin{macro}{\rank}
1080 % \begin{macro}{\linspan}
1081 % \begin{macro}{\spec}
1082 % \begin{macro}{\diag}
1083 % Some common math operators. Note that |\span| is already defined by \LaTeX{}, so we
1084 % resort to |\linspan| for the linear span of a set of vectors.
1085 % \begin{macrocode}
1086 \DeclareMathOperator{\tr}{tr}
1087 \DeclareMathOperator{\supp}{supp}
1088 \DeclareMathOperator{\rank}{rank}
1089 \DeclareMathOperator{\linspan}{span}
1090 \DeclareMathOperator{\spec}{spec}
1091 \DeclareMathOperator{\diag}{diag}
1092 % \end{macrocode}
1093 % \end{macro}
1094 % \end{macro}
1095 % \end{macro}
1096 % \end{macro}
1097 % \end{macro}
1098 % \end{macro}
1099 %
1100 % \begin{macro}{\phfqit@Realpart}
1101 % \begin{macro}{\phfqit@Imagpart}
1102 % Provide math operators for $\Re$ and $\Im$. The aliasing to the actual
1103 % commands |\Re| and |\Im| is done later, when we process the package options.
1104 % \begin{macrocode}
1105 \let\phfqit@Re\Re
1106 \DeclareMathOperator{\phfqit@Realpart}{Re}%
1107 \let\phfqit@Im\Im
1108 \DeclareMathOperator{\phfqit@Imagpart}{Im}%
1109 % \end{macrocode}
1110 % \end{macro}
1111 % \end{macro}
1112 %
1113 %
1114 % \subsubsection{Poly}
1115 %
1116 % \begin{macro}{\poly}
1117 % Poly symbol.
1118 % \iffalse meta-comment
1119 % \changed[v1.0-added-poly-command]{v1.0}{2015/05/22}{Added \phfverb\poly\space command}
1120 % \fi
1121 % \begin{macrocode}
1122 \DeclareMathOperator{\poly}{poly}
1123 % \end{macrocode}
1124 % \end{macro}
1125 %
1126 % \subsubsection{Bits and Bit Strings}
1127 %
1128 % See documentation in \autoref{sec:bits}
1129 %
1130 % \begin{macro}{\bit}
1131 % \begin{macro}{\bitstring}
1132 % Bits and bit strings.
1133 % \begin{macrocode}
1134 \newcommand\bit[1]{\texttt{#1}}
1135 \newcommand\bitstring[1]{\phfqit@bitstring{#1}}
1136 % \end{macrocode}
1137 %
1138 % The implementation of |\bitstring| needs some auxiliary internal macros.
1139 % \begin{macrocode}
1140 \def\phfqit@bitstring#1{%
1141 \begingroup%
1142 \setlength{\phfqit@len@bit}{\maxof{\widthof{\bit{0}}}{\widthof{\bit{1}}}}%
1143 \phfqitBitstringFormat{\phfqit@bitstring@#1\phfqit@END}%
1144 \endgroup%
1145 }
1146 % \end{macrocode}
1147 %
1148 % The internal |\phfqit@bitstring@| macro picks up the next bit, and puts it
1149 % into a \LaTeX{} |\makebox| on its own with a fixed width.
1150 % \begin{macrocode}
1151 \def\phfqit@bitstring@#1#2\phfqit@END{%
1152 \makebox[\phfqit@len@bit][c]{\phfqitBitstringFormatBit{#1}}%
1153 \if\relax\detokenize\expandafter{#2}\relax%
1154 \else%
1155 % \end{macrocode}
1156 %
1157 % If there are bits left, then recurse for the rest of the bitstring:
1158 % \begin{macrocode}
1159 \phfqitBitstringSep\phfqit@bitstring@#2\phfqit@END%
1160 \fi%
1161 }
1162 \newlength\phfqit@len@bit
1163 % \end{macrocode}
1164 % \end{macro}
1165 % \end{macro}
1166 %
1167 % \begin{macro}{\phfqitBitstringSep}
1168 % \begin{macro}{\phfqitBitstringFormat}
1169 % Redefine these to customize the bit string appearance.
1170 % \begin{macrocode}
1171 \newcommand\phfqitBitstringSep{\hspace{0.3ex}}
1172 \newcommand\phfqitBitstringFormat[1]{\ensuremath{\underline{\overline{#1}}}}
1173 \def\phfqitBitstringFormatBit{\bit}
1174 % \end{macrocode}
1175 % \end{macro}
1176 % \end{macro}
1177 %
1178 %
1179 % \subsubsection{Logical Gates}
1180 %
1181 % See user documentation in \autoref{sec:gates}.
1182 %
1183 % \begin{macro}{\gate}
1184 % Generic macro to format a gate name.
1185 % \begin{macrocode}
1186 \DeclareRobustCommand\gate[1]{\ifmmode\textsc{\lowercase{#1}}%
1187 \else{\rmfamily\textsc{\lowercase{#1}}}\fi}
1188 % \end{macrocode}
1189 % \end{macro}
1190 %
1191 % \needspace{5\baselineskip}
1192 % \begin{macro}{\AND}
1193 % \begin{macro}{\XOR}
1194 % \begin{macro}{\CNOT}
1195 % \begin{macro}{\NOT}
1196 % \begin{macro}{\NOOP}
1197 % Some common gates.
1198 % \begin{macrocode}
1199 \newcommand{\AND}{\gate{And}}
1200 \newcommand{\XOR}{\gate{Xor}}
1201 \newcommand{\CNOT}{\gate{C-Not}}
1202 \newcommand{\NOT}{\gate{Not}}
1203 \newcommand{\NOOP}{\gate{No-Op}}
1204 % \end{macrocode}
1205 % \end{macro}
1206 % \end{macro}
1207 % \end{macro}
1208 % \end{macro}
1209 % \end{macro}
1210 %
1211 %
1212 % \subsubsection{Lie Groups \& Algebras}
1213 %
1214 % \needspace{7\baselineskip}
1215 % \begin{macro}{\uu(N)}
1216 % \begin{macro}{\UU(N)}
1217 % \begin{macro}{\su(N)}
1218 % \begin{macro}{\SU(N)}
1219 % \begin{macro}{\so(N)}
1220 % \begin{macro}{\SO(N)}
1221 % \begin{macro}{\slalg(N)}
1222 % \begin{macro}{\SL(N)}
1223 % \begin{macro}{\GL(N)}
1224 % \begin{macro}{\SN(N)}
1225 % Some Lie Groups \& Algebras. See \autoref{sec:Lie-groups-algebras}
1226 % \begin{macrocode}
1227 \def\uu(#1){\phfqitLieAlgebra{u}{#1}}
1228 \def\UU(#1){\phfqitLieGroup{U}{#1}}
1229 \def\su(#1){\phfqitLieAlgebra{su}{#1}}
1230 \def\SU(#1){\phfqitLieGroup{SU}{#1}}
1231 \def\so(#1){\phfqitLieAlgebra{so}{#1}}
1232 \def\SO(#1){\phfqitLieGroup{SO}{#1}}
1233 \def\slalg(#1){\phfqitLieAlgebra{sl}{#1}} % \sl is "slanted font" in TeX
1234 \def\SL(#1){\phfqitLieGroup{SL}{#1}}
1235 \def\GL(#1){\phfqitLieGroup{GL}{#1}}
1236 \def\SN(#1){\phfqitDiscreteGroup{S}{#1}}
1237 % \end{macrocode}
1238 % \end{macro}
1239 % \end{macro}
1240 % \end{macro}
1241 % \end{macro}
1242 % \end{macro}
1243 % \end{macro}
1244 % \end{macro}
1245 % \end{macro}
1246 % \end{macro}
1247 % \end{macro}
1248 %
1249 % \begin{macro}{\phfqitLieAlgebra}
1250 % \begin{macro}{\phfqitLieGroup}
1251 % \begin{macro}{\phfqitDiscreteGroup}
1252 % Override these to change the appearance of the group names or algebra names.
1253 % The first argument is the name of the group or algebra (e.g. |su| or |SU|),
1254 % and the second argument is the parenthesized argument e.g. ``N''.
1255 % \begin{macrocode}
1256 \newcommand\phfqitLieAlgebra[2]{\mathfrak{#1}({#2})}
1257 \newcommand\phfqitLieGroup[2]{\mathrm{#1}({#2})}
1258 \newcommand\phfqitDiscreteGroup[2]{\mathrm{#1}_{#2}}
1259 % \end{macrocode}
1260 % \end{macro}
1261 % \end{macro}
1262 % \end{macro}
1263 %
1264 %
1265 %
1266 %
1267 %
1268 % \subsection{Helper for parsing a size argument}
1269 %
1270 % \begin{macro}{\phfqit@parsesizearg}
1271 % Utility to parse size argument with the backtick specification
1272 % (\autoref{topic:size-specification-backtick}).
1273 %
1274 % Parses a size argument, if any, and stores it into |\phfqit@val@sizearg|.
1275 % The value stored can directly be expanded as an optional argument to a
1276 % |\DeclarePairedDelimiter|-compatible command (see \pkgname{mathtools} package).
1277 %
1278 % |#1| should be a command token. It is the next action to take, after
1279 % argument has been parsed.
1280 % \begin{macrocode}
1281 \def\phfqit@parsesizearg#1{%
1282 \begingroup%
1283 \mathcode`\`="0060\relax%
1284 \gdef\phfqit@val@sizearg{}%
1285 \def\phfqit@tmp@contwithsize{\phfqit@parsesizearg@withsize{#1}}%
1286 \@ifnextchar`{\phfqit@tmp@contwithsize}{\endgroup#1}%
1287 }
1288 \def\phfqit@parsesizearg@withsize#1`#2{%
1289 \def\phfqit@tmp@x{#2}%
1290 \def\phfqit@tmp@star{*}%
1291 \ifx\phfqit@tmp@x\phfqit@tmp@star%
1292 \gdef\phfqit@val@sizearg{*}%
1293 \def\phfqit@tmp@cont{\endgroup#1}%
1294 \expandafter\phfqit@tmp@cont%
1295 \else%
1296 \gdef\phfqit@val@sizearg{[#2]}%
1297 \def\phfqit@tmp@cont{\endgroup#1}%
1298 \expandafter\phfqit@tmp@cont%
1299 \fi%
1300 }
1301 % \end{macrocode}
1302 % \end{macro}
1303 %
1304 % \begin{macro}{\phfqitDeclarePairedDelimiterXWithAltSizing}
1305 % \begin{macro}{\phfqitDeclarePairedDelimiterXPPWithAltSizing}
1306 % Macros that behave exactly like \pkgname{mathtools}'
1307 % |\DeclarePairedDelimiterX| and |\DeclarePairedDelimiterXPP|, except that
1308 % their size argument can also be specified by a backtick as for entropy
1309 % measures or other objects in this package (e.g., to define |\abs| such that
1310 % |$\abs`\Big{x - y}$| gives $\abs`\Big{x - y}$).
1311 % \changed[v4.0-new-phfqitDeclarePairedDelimiterxxx]{v4.0}{2021/10/07}{Added
1312 % \phfverb{\phfqitDeclarePairedDelimiterXWithAltSizing} and
1313 % \phfverb{\phfqitDeclarePairedDelimiterXPPWithAltSizing}}
1314 % \begin{macrocode}
1315 \def\phfqitDeclarePairedDelimiterXWithAltSizing{%
1316 \phfqitDeclareMathtoolsPairedDelimiterCmdWithAltSizing\DeclarePairedDelimiterX
1317 }
1318 \def\phfqitDeclarePairedDelimiterXPPWithAltSizing{%
1319 \phfqitDeclareMathtoolsPairedDelimiterCmdWithAltSizing\DeclarePairedDelimiterXPP
1320 }
1321 \def\phfqitDeclareMathtoolsPairedDelimiterCmdWithAltSizing#1#2{%
1322 \begingroup
1323 \escapechar=-1\relax
1324 \xdef\phfqit@tmp@thecmd{%
1325 \expandafter\noexpand\csname phfqit@paireddelim@def@\string#2\endcsname}%
1326 \endgroup
1327 \edef\x{%
1328 \noexpand\phfqit@paireddelim@parsesizearg{\expandonce\phfqit@tmp@thecmd}%
1329 }%
1330 \expandafter\DeclareRobustCommand\expandafter#2\expandafter{\x}%
1331 \expandafter#1\phfqit@tmp@thecmd
1332 }
1333 \def\phfqit@paireddelim@parsesizearg#1{%
1334 \phfqit@parsesizearg{\expandafter#1\phfqit@val@sizearg}%
1335 }
1336 % \end{macrocode}
1337 % \end{macro}
1338 % \end{macro}
1339 %
1340 %
1341 % \subsection{Bra-Ket Notation}
1342 %
1343 %
1344 % \begin{macro}{\phfqitKetsBarSpace}
1345 % \begin{macro}{\phfqitKetsRLAngleSpace}
1346 % These macros can be redefined to fine-tune the space that is inserted in
1347 % some of the ket/bra constructs.
1348 %
1349 % |\phfqitKetsBarSpace| is the space around the vertical bars, e.g., in a
1350 % bra-ket, or in matrix elements. (Previously, this space was hard-coded to
1351 % |\hspace*{0.2ex}|. Now, the spacing can be specified in this macro. We
1352 % furthermore use ``math units'' (|mu|), which are more suitable for
1353 % specifying space in math mode; recall that $1\,\mathrm{mu}$ is
1354 % $1/18\,\mathrm{em}$ in the math font.)
1355 % \begin{macrocode}
1356 \def\phfqitKetsBarSpace{\mkern 1.5mu\relax}
1357 % \end{macrocode}
1358 % The macro |\phfqitKetsRLAngleSpace| specifies the space between the right
1359 % angle bracket and the left angle bracket in ket-bra type constructs
1360 % ($\ketbra\phi\psi$). By default, it expands to negative space to bring the
1361 % angle brackets closer together. (Previously, this space was hard-coded to
1362 % |\hspace*{-0.25ex}|.)
1363 % \begin{macrocode}
1364 \def\phfqitKetsRLAngleSpace{\mkern -1.8mu\relax}
1365 % \end{macrocode}
1366 % \end{macro}
1367 % \end{macro}
1368 %
1369 % \needspace{7\baselineskip}
1370 % \begin{macro}{\ket}
1371 % \begin{macro}{\bra}
1372 % \begin{macro}{\braket}
1373 % \begin{macro}{\ketbra}
1374 % \begin{macro}{\proj}
1375 % \begin{macro}{\matrixel}
1376 % \begin{macro}{\dmatrixel}
1377 % Bras, kets, norms, some delimiter stuff. User documentation in
1378 % \autoref{sec:bra-ket}.
1379 % \begin{macrocode}
1380 \phfqitDeclarePairedDelimiterXWithAltSizing\ket[1]{\lvert}{\rangle}{{#1}}
1381 \phfqitDeclarePairedDelimiterXWithAltSizing\bra[1]{\langle}{\rvert}{{#1}}
1382 \phfqitDeclarePairedDelimiterXWithAltSizing\braket[2]{\langle}{\rangle}{%
1383 {#1}\phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#2}%
1384 }
1385 \phfqitDeclarePairedDelimiterXWithAltSizing\ketbra[2]{\lvert}{\rvert}{%
1386 {#1}\delimsize\rangle\phfqitKetsRLAngleSpace\delimsize\langle{#2}%
1387 }
1388 \phfqitDeclarePairedDelimiterXWithAltSizing\proj[1]{\lvert}{\rvert}{%
1389 {#1}\delimsize\rangle\phfqitKetsRLAngleSpace\delimsize\langle{#1}%
1390 }
1391 \phfqitDeclarePairedDelimiterXWithAltSizing\matrixel[3]{\langle}{\rangle}{%
1392 {#1}\phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#2}%
1393 \phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#3}%
1394 }
1395 \phfqitDeclarePairedDelimiterXWithAltSizing\dmatrixel[2]{\langle}{\rangle}{%
1396 {#1}\phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#2}%
1397 \phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#1}%
1398 }
1399 % \end{macrocode}
1400 % \end{macro}
1401 % \end{macro}
1402 % \end{macro}
1403 % \end{macro}
1404 % \end{macro}
1405 % \end{macro}
1406 % \end{macro}
1407 %
1408 % \begin{macro}{\phfqitKetsBeforeCommaSpace}
1409 % \begin{macro}{\phfqitKetsAfterCommaSpace}
1410 % \begin{macro}{\innerprod}
1411 % We also provide the |\innerprod| macro at this point. Customize the inner
1412 % spacing before and after the comma with |\phfqitKetsBeforeCommaSpace| and
1413 % |\phfqitKetsAfterCommaSpace|.
1414 % \begin{macrocode}
1415 \def\phfqitKetsBeforeCommaSpace{}
1416 \def\phfqitKetsAfterCommaSpace{\mkern 1.5mu\relax}
1417 \phfqitDeclarePairedDelimiterXWithAltSizing\innerprod[2]{\langle}{\rangle}{%
1418 {#1}\phfqitKetsBeforeCommaSpace,\phfqitKetsAfterCommaSpace{#2}%
1419 }
1420 % \end{macrocode}
1421 % \end{macro}
1422 % \end{macro}
1423 % \end{macro}
1424 %
1425 % \begin{macro}{\phfqitOKetsBarSpace}
1426 % \begin{macro}{\phfqitOKetsRLAngleSpace}
1427 % These macros are the same as |\phfqitKetsBarSpace| and
1428 % |\phfqitKetsRLAngleSpace|, except that they specify the corresponding
1429 % spacing for the |\oket| family of bra/ket-type constructs.
1430 % \begin{macrocode}
1431 \def\phfqitOKetsBarSpace{\phfqitKetsBarSpace}
1432 \def\phfqitOKetsRLAngleSpace{\phfqitKetsRLAngleSpace}
1433 % \end{macrocode}
1434 % \end{macro}
1435 % \end{macro}
1436 %
1437 %
1438 % \needspace{8\baselineskip}
1439 % \begin{macro}{\oket}
1440 % \begin{macro}{\obra}
1441 % \begin{macro}{\obraket}
1442 % \begin{macro}{\oketbra}
1443 % \begin{macro}{\oproj}
1444 % \begin{macro}{\omatrixel}
1445 % \begin{macro}{\odmatrixel}
1446 % Again Bras, kets, but for operator space this time. User documentation in
1447 % \autoref{sec:bra-ket}. These definitions depend on |\llangle| and
1448 % |\rrangle| being available and expanding to valid delimiter symbols. See
1449 % also the |llanglefrommnsymbolfonts| option.
1450 %
1451 % \changed[v4.1-okets-obras]{v4.1}{2021/10/08}{Added support for
1452 % \phfverb{\oket} and friends}
1453 % \begin{macrocode}
1454 \phfqitDeclarePairedDelimiterXWithAltSizing\oket[1]{\lvert}{\rrangle}{{#1}}
1455 \phfqitDeclarePairedDelimiterXWithAltSizing\obra[1]{\llangle}{\rvert}{{#1}}
1456 \phfqitDeclarePairedDelimiterXWithAltSizing\obraket[2]{\llangle}{\rrangle}{%
1457 {#1}\phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#2}%
1458 }
1459 \phfqitDeclarePairedDelimiterXWithAltSizing\oketbra[2]{\lvert}{\rvert}{%
1460 {#1}\delimsize\rrangle\phfqitOKetsRLAngleSpace\delimsize\llangle{#2}%
1461 }
1462 \phfqitDeclarePairedDelimiterXWithAltSizing\oproj[1]{\lvert}{\rvert}{%
1463 {#1}\delimsize\rrangle\phfqitOKetsRLAngleSpace\delimsize\llangle{#1}%
1464 }
1465 \phfqitDeclarePairedDelimiterXWithAltSizing\omatrixel[3]{\llangle}{\rrangle}{%
1466 {#1}\phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#2}%
1467 \phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#3}%
1468 }
1469 \phfqitDeclarePairedDelimiterXWithAltSizing\odmatrixel[2]{\llangle}{\rrangle}{%
1470 {#1}\phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#2}%
1471 \phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#1}%
1472 }
1473 % \end{macrocode}
1474 % \end{macro}
1475 % \end{macro}
1476 % \end{macro}
1477 % \end{macro}
1478 % \end{macro}
1479 % \end{macro}
1480 % \end{macro}
1481 %
1482 %
1483 % \subsection{Delimited Expressions}
1484 % Delimited expressions are documented in \autoref{sec:delimited}.
1485 %
1486 % \begin{macro}{\abs}
1487 % \begin{macro}{\avg}
1488 % \begin{macro}{\norm}
1489 % Other delimited expressions.
1490 % \begin{macrocode}
1491 \phfqitDeclarePairedDelimiterXWithAltSizing\abs[1]{\lvert}{\rvert}{{#1}}
1492 \phfqitDeclarePairedDelimiterXWithAltSizing\avg[1]{\langle}{\rangle}{{#1}}
1493 \phfqitDeclarePairedDelimiterXWithAltSizing\norm[1]{\lVert}{\rVert}{{#1}}
1494 % \end{macrocode}
1495 % \end{macro}
1496 % \end{macro}
1497 % \end{macro}
1498 %
1499 % \begin{macro}{\phfqitDefineNorm}
1500 % Use |\phfqitDefineNorm\opnorm{}{_\infty}| to define specific norms, with the
1501 % syntax |\phfqitDefineNorm|\meta{new command name}\meta{tokens
1502 % before}\meta{tokens after}. If you need arguments in the before/after
1503 % tokens, then your norm starts to be more complicated than what
1504 % |\phfqitDefineNorm| can handle, perhaps it's best you use
1505 % |\phfqitDeclarePairedDelimiterXPPWithAltSizing| directly.
1506 %
1507 % \changed[v4.0-new-phfqitDefineNorm]{v4.0}{2021/10/07}{Added
1508 % \phfverb{\phfqitDefineNorm}}
1509 % \begin{macrocode}
1510 \def\phfqitDefineNorm#1#2#3{%
1511 \phfqitDeclarePairedDelimiterXPPWithAltSizing#1[1]{#2}{\lVert}{\rVert}{#3}{{##1}}%
1512 }
1513 % \end{macrocode}
1514 % \end{macro}
1515 %
1516 % \begin{macro}{\phfqit@insideinterval}
1517 % Format the contents of an interval. Utility for defining |\intervalc| and
1518 % friends.
1519 % \begin{macrocode}
1520 \def\phfqit@insideinterval#1#2{{#1\mathclose{},\mathopen{}#2}}
1521 % \end{macrocode}
1522 % \end{macro}
1523 %
1524 % \needspace{4\baselineskip}
1525 % \begin{macro}{\intervalc}
1526 % \begin{macro}{\intervalo}
1527 % \begin{macro}{\intervalco}
1528 % \begin{macro}{\intervaloc}
1529 % Open/Closed/Semi-Open Intervals
1530 % \begin{macrocode}
1531 \phfqitDeclarePairedDelimiterXWithAltSizing\intervalc[2]{[}{]}{%
1532 \phfqit@insideinterval{#1}{#2}}
1533 \phfqitDeclarePairedDelimiterXWithAltSizing\intervalo[2]{]}{[}{%
1534 \phfqit@insideinterval{#1}{#2}}
1535 \phfqitDeclarePairedDelimiterXWithAltSizing\intervalco[2]{[}{[}{%
1536 \phfqit@insideinterval{#1}{#2}}
1537 \phfqitDeclarePairedDelimiterXWithAltSizing\intervaloc[2]{]}{]}{%
1538 \phfqit@insideinterval{#1}{#2}}
1539 % \end{macrocode}
1540 % \end{macro}
1541 % \end{macro}
1542 % \end{macro}
1543 % \end{macro}
1544 %
1545 %
1546 %
1547 %
1548 % \subsection{Entropy Measures and Other Qit Objects}
1549 %
1550 % \changed[v2.0-qit-objects]{v2.0}{2017/06/17}{Introduced the Qit Objects infrastructure}
1551 %
1552 %
1553 % \subsubsection{Some Internal Utilities}
1554 %
1555 % \begin{macro}{\phfqitParens}
1556 % Simple parenthesis-delimited expression, with
1557 % |\DeclarePairedDelimiterX|-compatible syntax. For example,
1558 % \par |\phfqitParens|\marg{content} \quad$\to$\quad
1559 % \fbox{\phfverb( \meta{content} \phfverb)}
1560 % \par |\phfqitParens*|\marg{content} \quad$\to$\quad
1561 % \fbox{\phfverb\left\phfverb( \meta{content} \phfverb\right\phfverb)}
1562 % \par |\phfqitParens[\big]|\marg{content} \quad$\to$\quad
1563 % \fbox{\phfverb\bigl\phfverb( \meta{content} \phfverb\bigr\phfverb)}
1564 %
1565 % \begin{macrocode}
1566 \DeclarePairedDelimiterX\phfqitParens[1]{(}{)}{#1}
1567 % \end{macrocode}
1568 % \end{macro}
1569 %
1570 % \begin{macro}{\phfqitSquareBrackets}
1571 % Simple bracket-delimited expression, with
1572 % |\DeclarePairedDelimiterX|-compatible syntax. For example,
1573 % \par |\phfqitSquareBrackets|\marg{content} \quad$\to$\quad
1574 % \fbox{\phfverb[ \meta{content} \phfverb]}
1575 % \par |\phfqitSquareBrackets*|\marg{content} \quad$\to$\quad
1576 % \fbox{\phfverb\left\phfverb[ \meta{content} \phfverb\right\phfverb]}
1577 % \par |\phfqitSquareBrackets[\big]|\marg{content} \quad$\to$\quad
1578 % \fbox{\phfverb\bigl\phfverb[ \meta{content} \phfverb\bigr\phfverb]}
1579 %
1580 % \begin{macrocode}
1581 \DeclarePairedDelimiterX\phfqitSquareBrackets[1]{[}{]}{#1}
1582 % \end{macrocode}
1583 % \end{macro}
1584 %
1585 % \begin{macro}{\phfqitCurlyBrackets}
1586 % Simple bracket-delimited expression, with
1587 % |\DeclarePairedDelimiterX|-compatible syntax. For example,
1588 % \par |\phfqitSquareBrackets|\marg{content} \quad$\to$\quad
1589 % \fbox{\phfverb\{ \meta{content} \phfverb\}}
1590 % \par |\phfqitSquareBrackets*|\marg{content} \quad$\to$\quad
1591 % \fbox{\phfverb\left\phfverb\{ \meta{content} \phfverb\right\phfverb\}}
1592 % \par |\phfqitSquareBrackets[\big]|\marg{content} \quad$\to$\quad
1593 % \fbox{\phfverb\bigl\phfverb\{ \meta{content} \phfverb\bigr\phfverb\}}
1594 %
1595 % \begin{macrocode}
1596 \DeclarePairedDelimiterX\phfqitCurlyBrackets[1]{\{}{\}}{#1}
1597 % \end{macrocode}
1598 % \end{macro}
1599 %
1600 %
1601 %
1602 % \subsubsection{Machinery for Qit Objects}
1603 %
1604 % See also user documentation in \autoref{sec:QitObjectImpl}.
1605 %
1606 % \begin{macro}{\QitObject}
1607 % The argument is the entropic quantity type or object kind (or ``entropic
1608 % quantity driver''): one of |Hbase|, |Hfnbase|, |Dbase|, |DCbase|, or any
1609 % other custom object.
1610 % \begin{macrocode}
1611 \newcommand\QitObject[1]{%
1612 \begingroup%
1613 \preto\QitObjectDone{\endgroup}%
1614 \QitObjectInit%
1615 \csname QitObj@reg@#1@initdefs\endcsname%
1616 %%\message{DEBUG: \detokenize{\QitObject{#1}}}%
1617 \def\QitObj@args{}%
1618 \def\qitobjParseDone{\QitObj@proceedToRender{#1}}%
1619 \def\qitobjDone{\QitObjectDone}%
1620 \csname QitObj@reg@#1@parse\endcsname%
1621 }
1622 % \end{macrocode}
1623 % \end{macro}
1624 %
1625 %
1626 % \begin{macro}{\DefineQitObject}
1627 % \begin{macro}{\DefineTunedQitObject}
1628 % Define a new Qit Object implementation with this macro. A Qit Object
1629 % implementation is specified in its simplest form by a \emph{name}, a
1630 % \emph{Parser} and a \emph{Renderer} (a single \LaTeX{} macro each). The
1631 % more advanced |\DefineTunedQitObject| allows you in addition to specify
1632 % local definitions to override defaults, as well as some initial arguments to
1633 % the parser.
1634 % \begin{macrocode}
1635 \def\DefineQitObject#1#2#3{%
1636 \DefineTunedQitObject{#1}{#2}{#3}{}{}%
1637 }%
1638 \def\DefineTunedQitObject#1#2#3#4#5{%
1639 \csdef{#1}{\QitObject{#1}#4}%
1640 \expandafter\robustify\csname #1\endcsname%
1641 \cslet{QitObj@reg@#1@parse}#2%
1642 \cslet{QitObj@reg@#1@render}#3%
1643 \csdef{QitObj@reg@#1@initdefs}{#5}%
1644 }
1645 % \end{macrocode}
1646 % \end{macro}
1647 % \end{macro}
1648 %
1649 %
1650 % Here are some callbacks meant for Qit Object implementations
1651 % (``types''/``drivers'').
1652 %
1653 % \begin{macro}{\qitobjAddArg}
1654 % \begin{macro}{\qitobjAddArgx}
1655 % These macros should only be called from within a \emph{Parse} macro of a qit
1656 % object type. Append an argument in preparation for an eventual call to the
1657 % corresponding \emph{Render} macro. |\qitobjAddArg| does not expand its
1658 % contents. |\qitobjAddArgx| expects a single command name as argument; it
1659 % expands the command once and stores those tokens as a single new argument.
1660 % \begin{macrocode}
1661 \def\qitobjAddArg#1{%
1662 \appto\QitObj@args{{#1}}%
1663 }
1664 \def\qitobjAddArgx#1{%
1665 \expandafter\qitobjAddArg\expandafter{#1}%
1666 }
1667 % \end{macrocode}
1668 % \end{macro}
1669 % \end{macro}
1670 %
1671 % \begin{macro}{\qitobjParseDone}
1672 % \begin{macro}{\qitobjDone}
1673 % These macros MUST be called at the end of the respective \emph{Parse}
1674 % (|\qitobjParseDone|) and \emph{Render} (|\qitobjDone|) implementations
1675 % (otherwise processing doesn't proceed, \LaTeX{} groups won't be closed, and
1676 % it will be a mess).
1677 %
1678 % These macros are correctly defined in |\QitObject| actually. Here we provide
1679 % empty definitions so that the \emph{Render} and \emph{Parse} user
1680 % implementation macros can be called stand-alone, too.
1681 % \begin{macrocode}
1682 \def\qitobjParseDone{}
1683 \def\qitobjDone{}
1684 % \end{macrocode}
1685 % \end{macro}
1686 % \end{macro}
1687 %
1688 % \begin{macro}{\QitObjectDone}
1689 % A hook which gets called after a Qit Object is displayed. This should
1690 % really stay empty on the global scope. However you can locally append or
1691 % prepend to it in tuned definitions for |\DeclareTunedQitObject| to perform
1692 % additional actions at the end of the Qit Object, for instance to close an
1693 % additional \LaTeX{} group.
1694 % \begin{macrocode}
1695 \def\QitObjectDone{}
1696 % \end{macrocode}
1697 % \end{macro}
1698 %
1699 % \begin{macro}{\QitObjectInit}
1700 % A hook which gets called before the parsing phase of a Qit Object. This
1701 % should really stay empty on the global scope. However you can locally
1702 % append or prepend to it in tuned definitions for |\DeclareTunedQitObject| to
1703 % perform additional actions before parsing the Qit Object (but which have to
1704 % be made within the \LaTeX{} group of the Qit Object). You can use this to
1705 % prepend code to |\QitObjectDone| so that you code gets called \emph{before}
1706 % the inner \LaTeX{} group is closed.
1707 % \begin{macrocode}
1708 \def\QitObjectInit{}
1709 % \end{macrocode}
1710 % \end{macro}
1711 %
1712 % An internal helper; it's useful to keep it separate for readability and for
1713 % debugging.
1714 % \begin{macrocode}
1715 \def\QitObj@proceedToRender#1{%
1716 %%\message{DEBUG: Rendering #1|\detokenize\expandafter{\QitObj@args}|}%
1717 \expandafter\def\expandafter\x\expandafter{%
1718 \csname QitObj@reg@#1@render\endcsname}%
1719 \expandafter\x\QitObj@args%
1720 }
1721 % \end{macrocode}
1722 %
1723 %
1724 % \subsubsection{Qit Object Implementation: Entropy, Conditional Entropy}
1725 %
1726 % See also the user doc in \autoref{sec:entropy-measures}.
1727 %
1728 % \begin{macro}{\HbaseParse}
1729 % Base parser macro for usual entropy measures; possibly conditional and/or
1730 % smooth.
1731 %
1732 % USAGE:
1733 % |\Hbase|\marg{H-symbol}\hspace{0pt}\relax
1734 % \marg{subscript}\hspace{0pt}\relax
1735 % \meta{size-spec}\hspace{0pt}\oarg{state}\relax
1736 % \hspace{0pt}\oarg{epsilon}\hspace{0pt}\marg{target system}\hspace{0pt}\relax
1737 % \oarg{conditioning system}
1738 %
1739 % The argument \meta{size-spec} is optional, and is documented in
1740 % \autoref{topic:size-specification-backtick}. For example \meta{size-spec} =
1741 % |`*| or |`\Big|.
1742 %
1743 % Examples:
1744 % \par |\Hbase{\hat{H}}{\mathrm{max}}[\rho][\epsilon]{E}[X']|
1745 % \quad$\to$\quad
1746 % \fbox{$\Hbase{\hat{H}}{\mathrm{max}}[\rho][\epsilon]{E}[X']$}
1747 % \par |\Hbase{\hat{H}}{\mathrm{max}}`*[\rho][\epsilon]{\bigotimes_i E}[X']|
1748 % \quad$\to$\quad
1749 % \fbox{$\Hbase{\hat{H}}{\mathrm{max}}`*[\rho][\epsilon]{\displaystyle\bigotimes_i E}[X']$}
1750 %
1751 % The |\HbaseParse| macro is responsible for parsing the arguments to
1752 % |\Hbase|. We should parse the arguments using helper macros as needed,
1753 % adding rendering arguments with |\qitobjAddArg| or |\qitobjAddArgx|, and
1754 % then calling |\qitobjParseDone|. The arguments are then automatically
1755 % provided as arguments to the |\HbaseRender| function. We just have to make
1756 % sure we add the correct number of arguments in the correct order.
1757 %
1758 % \begin{macrocode}
1759 \def\HbaseParse#1#2{%
1760 % \end{macrocode}
1761 %
1762 % The first arguments are the mandatory arguments
1763 % \marg{H-symbol}\hspace{0pt}\marg{subscript}. Then defer to helper macros for
1764 % the rest of the parsing.
1765 % \begin{macrocode}
1766 \qitobjAddArg{#1}%
1767 \qitobjAddArg{#2}%
1768 \phfqit@parsesizearg\HbaseParse@%
1769 }
1770 % \end{macrocode}
1771 %
1772 % Store the delimiter size argument which |\phfqit@parsesizearg| has stored into
1773 % |\phfqit@val@sizearg|, then parse an optional \oarg{state} argument.
1774 % \begin{macrocode}
1775 \newcommand\HbaseParse@[1][]{%
1776 \qitobjAddArgx{\phfqit@val@sizearg}%
1777 \qitobjAddArg{#1}%
1778 \HbaseParse@@%
1779 }
1780 % \end{macrocode}
1781 % Then parse an optional \oarg{epsilon} argument, as well as a mandatory
1782 % \marg{target system} argument.
1783 % \begin{macrocode}
1784 \newcommand\HbaseParse@@[2][]{%
1785 \qitobjAddArg{#1}%
1786 \qitobjAddArg{#2}%
1787 \HbaseParse@@@%
1788 }
1789 % \end{macrocode}
1790 % Finally, parse an optional \oarg{conditioning system}.
1791 % \begin{macrocode}
1792 \newcommand\HbaseParse@@@[1][]{%
1793 \qitobjAddArg{#1}%
1794 \qitobjParseDone%
1795 }
1796 % \end{macrocode}
1797 % \end{macro}
1798 %
1799 %
1800 % \begin{macro}{\HbaseRender}
1801 % Render the entropy measure.
1802 % \par |#1| = ``$H$'' symbol to use (e.g. |H|)
1803 % \par |#2| = subscript (type of entropy, e.g. |\marthrm{min},0|)
1804 % \par |#3| = possible size argument to expand in front of parens command (one
1805 % of \emph{(empty)}, |*|, or |[\big]| using a standard sizing command)
1806 % \par |#4| = the state (e.g. |\rho|), may be left empty
1807 % \par |#5| = epsilon argument (superscript to entropy measure), if any, or
1808 % leave argument empty
1809 % \par |#6| = system to measure entropy of
1810 % \par |#7| = conditioning system, if any, or else leave the argument empty
1811 % \begin{macrocode}
1812 \def\HbaseRender#1#2#3#4#5#6#7{%
1813 %%\message{DEBUG: HbaseRender\detokenize{{#1}{#2}{#3}{#4}{#5}{#6}{#7}}}%
1814 % \end{macrocode}
1815 %
1816 % Start with the entropy symbol (`H'), the subscript, and the superscript:
1817 % \begin{macrocode}
1818 \HbaseRenderSym{#1}_{\HbaseRenderSub{#2}}^{\HbaseRenderSup{#5}}
1819 % \end{macrocode}
1820 % Render the contents of the entropy (parenthetic expression with system \&
1821 % conditioning system), only if the system or conditioning system or state are
1822 % not empty:
1823 % \begin{macrocode}
1824 \notblank{#4#6#7}{%
1825 \HbaseRenderContents{#3}{#6}{#7}%
1826 % \end{macrocode}
1827 % Finally, add the state as subscript, if any:
1828 % \begin{macrocode}
1829 \HbaseRenderTail{#4}%
1830 }{}%
1831 % \end{macrocode}
1832 % We're done.
1833 % \begin{macrocode}
1834 \qitobjDone%
1835 }
1836 % \end{macrocode}
1837 % \end{macro}
1838 %
1839 % \needspace{5\baselineskip}
1840 % \begin{macro}{\HbaseRenderSym}
1841 % \begin{macro}{\HbaseRenderSub}
1842 % \begin{macro}{\HbaseRenderSup}
1843 % \begin{macro}{\HbaseRenderTail}
1844 % Macros to render different parts of the entropy measure. By default, don't
1845 % do anything special to them (but this might be locally overridden in a tuned
1846 % Qit Object, for instance).
1847 % \begin{macrocode}
1848 \def\HbaseRenderSym#1{#1}%
1849 \def\HbaseRenderSub#1{#1}%
1850 \def\HbaseRenderSup#1{#1}%
1851 \def\HbaseRenderTail#1{_{#1}}%
1852 % \end{macrocode}
1853 % \end{macro}
1854 % \end{macro}
1855 % \end{macro}
1856 % \end{macro}
1857 %
1858 % \begin{macro}{\HbaseRenderContents}
1859 % For the main contents rendering macro, we need to do a little more work.
1860 % First, declare a token register in which we will prepare the contents of the
1861 % parenthetic expression.
1862 % \begin{macrocode}
1863 \newtoks\Hbase@tmp@toks
1864 \def\Hbase@addtoks#1\@Hbase@END@ADD@TOKS{%
1865 \Hbase@tmp@toks=\expandafter{\the\Hbase@tmp@toks#1}}%
1866 % \end{macrocode}
1867 % Now we need to define the macro which formats the contents of the entropy.
1868 % The arguments are |#1| = possible sizing argument, |#2| = system name, |#3| =
1869 % conditioning system if any.
1870 % \begin{macrocode}
1871 \def\HbaseRenderContents#1#2#3{%
1872 % \end{macrocode}
1873 % We need to construct the parenthetic argument to the entropy, which we will
1874 % store in the token register |\Hbase@tmp@toks|. Start with system name:
1875 % \begin{macrocode}
1876 \Hbase@tmp@toks={#2}%
1877 % \end{macrocode}
1878 % \ldots{} add conditional system, if specified:
1879 % \begin{macrocode}
1880 \notblank{#3}{%
1881 \Hbase@addtoks\mathclose{}\,\delimsize\vert\,\mathopen{}%
1882 #3%
1883 \@Hbase@END@ADD@TOKS%
1884 }{}%
1885 % \end{macrocode}
1886 % The tokens are ready now. Prepare the argument to the command
1887 % |\HbaseRenderContentsInnerParens| (normally just |\phfqitParens|), and go:
1888 % \begin{macrocode}
1889 \edef\tmp@args{\unexpanded{#1}{\the\Hbase@tmp@toks}}%
1890 \expandafter\HbaseRenderContentsInnerParens\tmp@args%
1891 }
1892 % \end{macrocode}
1893 % \end{macro}
1894 %
1895 % \begin{macro}{\X}
1896 % Macro which expands to the parenthetic expression type macro we would like
1897 % to use. By default, this is |\phfqitParens|.
1898 % \begin{macrocode}
1899 \def\HbaseRenderContentsInnerParens{\phfqitParens}
1900 % \end{macrocode}
1901 % \end{macro}
1902 %
1903 %
1904 % \begin{macro}{\Hbase}
1905 % Finally, we declare our base entropic quantity type:
1906 % \begin{macrocode}
1907 \DefineQitObject{Hbase}{\HbaseParse}{\HbaseRender}
1908 % \end{macrocode}
1909 % \end{macro}
1910 %
1911 %
1912 % \subsubsection{Qit Object Implementation: Entropy Function}
1913 %
1914 % See also the user doc in \autoref{sec:entropy-function}.
1915 %
1916 % \begin{macro}{\Hfnbase}
1917 % Base implementation of an entropy function.
1918 %
1919 % Usage: |\Hfnbase{H}{1}{2}(x)| $\to$ $\Hfnbase{H}{1}{2}(x)$,
1920 % |\Hfnbase{H}{1}{2}`*(x)| $\to$ $\Hfnbase{H}{1}{2}`*(x)$,
1921 % |\Hfnbase{H}{1}{2}`\big(x)| $\to$ $\Hfnbase{H}{1}{2}`\big(x)$.
1922 %
1923 % We can use the same renderer as |\Hbase|, we just need a different parser.
1924 % The parser first accepts the mandatory arguments
1925 % \marg{H-symbol}\hspace{0pt}\marg{subscript}\hspace{0pt}\marg{superscript}.
1926 % \begin{macrocode}
1927 \def\HfnbaseParse#1#2#3{%
1928 \qitobjAddArg{#1}% H-sym
1929 \qitobjAddArg{#2}% sub
1930 \phfqit@parsesizearg{\HfnbaseParse@{#3}}%
1931 }
1932 % \end{macrocode}
1933 %
1934 % Continue to parse a the argument given in parentheses. The first mandatory
1935 % argument is simply the subscript passed on from the previous macro. It might
1936 % be tempting to do simply |\def\HfnbaseParse@#1(#2){...}|, but this does not
1937 % allow for recursive use of parenthesis within the entropy argument, for
1938 % instance |\Hfn(g(x)+h(y))|. Because of this, we use \pkgname{xparse}'s
1939 % |\NewDocumentCommand| which can handle this.
1940 % \begin{macrocode}
1941 \NewDocumentCommand{\HfnbaseParse@}{mr()}{%
1942 \qitobjAddArgx{\phfqit@val@sizearg}% size-arg
1943 \qitobjAddArg{}% state
1944 \qitobjAddArg{#1}% epsilon
1945 \qitobjAddArg{#2}% system--main arg
1946 \qitobjAddArg{}% cond system
1947 %%\message{DEBUG: Hfnbase args are |\detokenize\expandafter{\QitObj@args}|}%
1948 \qitobjParseDone%
1949 }
1950 \DefineQitObject{Hfnbase}{\HfnbaseParse}{\HbaseRender}
1951 % \end{macrocode}
1952 % \end{macro}
1953 %
1954 %
1955 % \subsubsection{Qit Object Implementation: Relative Entropy}
1956 %
1957 % User documentation in \autoref{sec:relative-entropies}.
1958 %
1959 %
1960 % \begin{macro}{\DbaseParse}
1961 % Base macro for relative entropy macros.
1962 %
1963 % USAGE:
1964 % |\Dbase|\marg{D-symbol}\hspace{0pt}\relax
1965 % [|_|\meta{subscript}]\hspace{0pt}\relax
1966 % [|^|\meta{superscript}]\hspace{0pt}\relax
1967 % \meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative to state}
1968 %
1969 % The subscript and superscripts are optional and don't have to be specified.
1970 % They may be specified in any order. Repetitions are allowed and
1971 % concatenates the arguments, e.g., |^{a}_{x}_{y}^{z}_{w}| is the same as
1972 % |_{xyw}^{az}|.
1973 %
1974 % The \meta{size-spec} is a backtick-style specification as always.
1975 %
1976 % \begin{macrocode}
1977 \def\DbaseParse#1{%
1978 \qitobjAddArg{#1}% D-sym
1979 \def\DbaseParse@val@sub{}%
1980 \def\DbaseParse@val@sup{}%
1981 \DbaseParse@%
1982 }
1983 \def\DbaseParse@{%
1984 \@ifnextchar_{\DbaseParse@parsesub}{\DbaseParse@@}%
1985 }
1986 \def\DbaseParse@@{%
1987 \@ifnextchar^{\DbaseParse@parsesup}{\DbaseParse@@@}%
1988 }
1989 \def\DbaseParse@parsesub_#1{%
1990 \appto\DbaseParse@val@sub{#1}%
1991 \DbaseParse@% return to maybe parsing other sub/superscripts
1992 }
1993 \def\DbaseParse@parsesup^#1{%
1994 \appto\DbaseParse@val@sup{#1}%
1995 \DbaseParse@% return to maybe parsing other sub/superscripts
1996 }
1997 \def\DbaseParse@@@{%
1998 \qitobjAddArgx\DbaseParse@val@sub%
1999 \qitobjAddArgx\DbaseParse@val@sup%
2000 \phfqit@parsesizearg\DbaseParse@rest%
2001 }
2002 \def\DbaseParse@rest#1#2{%
2003 \qitobjAddArgx\phfqit@val@sizearg%
2004 \qitobjAddArg{#1}% rho
2005 \qitobjAddArg{#2}% Gamma
2006 \qitobjParseDone%
2007 }
2008 % \end{macrocode}
2009 % \end{macro}
2010 %
2011 %
2012 %
2013 %
2014 %
2015 % \begin{macro}{\DbaseRender}
2016 % Macro which formats a relative entropy of the form
2017 % $D_\mathrm{sub}^\mathrm{sup}(A\Vert B)$:
2018 % \par |\DbaseRender{D}{\mathrm{min}}{\epsilon}{[\big]}{\rho}{\Gamma}|
2019 % \quad$\to$\quad
2020 % \fbox{$\DbaseRender{D}{\mathrm{min}}{\epsilon}{[\big]}{\rho}{\Gamma}$}
2021 %
2022 % \begin{macrocode}
2023 \def\DbaseRender#1#2#3#4#5#6{%
2024 %%\message{DEBUG: DbaseRender\detokenize{{#1}{#2}{#3}{#4}{#5}{#6}}}%
2025 % \end{macrocode}
2026 %
2027 % Start with the entropy symbol (`H'), the subscript, and the superscript:
2028 % \begin{macrocode}
2029 \DbaseRenderSym{#1}_{\DbaseRenderSub{#2}}^{\DbaseRenderSup{#3}}
2030 % \end{macrocode}
2031 % Render the contents of the entropy (parenthetic expression with the (one or)
2032 % two states), only if the arguments are non-empty:
2033 % \begin{macrocode}
2034 \notblank{#5#6}{%
2035 \DbaseRenderContents{#4}{#5}{#6}%
2036 }{}%
2037 % \end{macrocode}
2038 % We're done.
2039 % \begin{macrocode}
2040 \qitobjDone%
2041 }
2042 % \end{macrocode}
2043 % \end{macro}
2044 %
2045 % \needspace{5\baselineskip}
2046 % \begin{macro}{\DbaseRenderSym}
2047 % \begin{macro}{\DbaseRenderSub}
2048 % \begin{macro}{\DbaseRenderSup}
2049 % Macros to render different parts of the entropy measure. By default, don't
2050 % do anything special to them (but this might be locally overridden in a
2051 % tuned Qit Object).
2052 % \begin{macrocode}
2053 \def\DbaseRenderSym#1{#1}%
2054 \def\DbaseRenderSub#1{#1}%
2055 \def\DbaseRenderSup#1{#1}%
2056 % \end{macrocode}
2057 % \end{macro}
2058 % \end{macro}
2059 % \end{macro}
2060 %
2061 % \begin{macro}{\DbaseRenderContents}
2062 % Now we need to define the macro which formats the contents of the entropy.
2063 % First, define a useful token register.
2064 % \begin{macrocode}
2065 \newtoks\Dbase@tmp@toks
2066 \def\Dbase@addtoks#1\@Dbase@END@ADD@TOKS{%
2067 \Dbase@tmp@toks=\expandafter{\the\Dbase@tmp@toks#1}}%
2068 % \end{macrocode}
2069 %
2070 % The arguments are |#1| = possible sizing argument, |#2| = first state, |#3| =
2071 % second state (or operator), if any.
2072 % \begin{macrocode}
2073 \def\DbaseRenderContents#1#2#3{%
2074 % \end{macrocode}
2075 % We need to construct the parenthetic argument to the relative entropy, which
2076 % we will store in the token register |\Dbase@tmp@toks|. Start with system
2077 % name:
2078 % \begin{macrocode}
2079 \Dbase@tmp@toks={#2}%
2080 % \end{macrocode}
2081 % \ldots{} add conditional system, if specified:
2082 % \begin{macrocode}
2083 \notblank{#3}{%
2084 \Dbase@addtoks\mathclose{}\,\delimsize\Vert\,\mathopen{}%
2085 #3%
2086 \@Dbase@END@ADD@TOKS%
2087 }{}%
2088 % \end{macrocode}
2089 % The tokens are ready now. Prepare the argument to the command
2090 % |\DbaseRenderContentsInnerParens| (by default just |\phfqitParens|), and go:
2091 % \begin{macrocode}
2092 \edef\tmp@args{\unexpanded{#1}{\the\Dbase@tmp@toks}}%
2093 \expandafter\DbaseRenderContentsInnerParens\tmp@args%
2094 }
2095 % \end{macrocode}
2096 % \end{macro}
2097 %
2098 % \begin{macro}{\DbaseRenderContentsInnerParens}
2099 % Macro which expands to the parenthetic expression type macro we would like
2100 % to use. By default, this is |\phfqitParens|.
2101 % \begin{macrocode}
2102 \def\DbaseRenderContentsInnerParens{\phfqitParens}
2103 % \end{macrocode}
2104 % \end{macro}
2105 %
2106 % \begin{macro}{\Dbase}
2107 % Finally, define the |\Dbase| macro by declaring a new qit object.
2108 % \begin{macrocode}
2109 \DefineQitObject{Dbase}{\DbaseParse}{\DbaseRender}
2110 % \end{macrocode}
2111 % \end{macro}
2112 %
2113 %
2114 % \subsubsection{Qit Object Type: Coherent Relative Entropy}
2115 %
2116 % See also user documentation in \autoref{sec:coh-rel-entr}.
2117 %
2118 % \begin{macro}{\DCohbaseParse}
2119 % Base macros for coherent relative entropy-type quantities of the form
2120 % ${\bar D}_{X\to X'}^{\epsilon}(\rho_{X'R}\Vert\Gamma_X,\Gamma_{X'})$.
2121 %
2122 % USAGE:
2123 % |\DCohbase|\marg{D symbol}\hspace{0pt}\relax
2124 % \oarg{epsilon}\hspace{0pt}\relax
2125 % \marg{state or \texttt{\textup{*}}fully-decorated-state}\hspace{0pt}\relax
2126 % \marg{System In}\hspace{0pt}\relax
2127 % \marg{System Out}\hspace{0pt}\relax
2128 % \marg{Gamma In}\hspace{0pt}\relax
2129 % \marg{Gamma Out}
2130 %
2131 % \begin{macrocode}
2132 \def\DCohbaseParse#1{%
2133 \qitobjAddArg{#1}% D-sym
2134 \DCohbaseParse@%
2135 }
2136 \newcommand\DCohbaseParse@[1][]{%
2137 \qitobjAddArg{#1}% epsilon
2138 \phfqit@parsesizearg\DCohbaseParse@rest%
2139 }
2140 \def\DCohbaseParse@rest#1#2#3#4#5{%
2141 % rho, X, X', \Gamma_X, \Gamma_{X'}
2142 \qitobjAddArgx\phfqit@val@sizearg%
2143 \DCohbaseParse@parserhosub#1\DCohbaseParse@ENDSTATE{#2}{#3}%
2144 \qitobjAddArg{#2}%
2145 \qitobjAddArg{#3}%
2146 \qitobjAddArg{#4}%
2147 \qitobjAddArg{#5}%
2148 \qitobjParseDone%
2149 }
2150 \def\DCohbaseParse@parserhosub{%
2151 \@ifnextchar*\DCohbaseParse@parserhosub@nosub%
2152 \DCohbaseParse@parserhosub@wsub%
2153 }
2154 \def\DCohbaseParse@parserhosub@nosub*#1\DCohbaseParse@ENDSTATE#2#3{%
2155 \qitobjAddArg{#1}% rho
2156 }
2157 \def\DCohbaseParse@parserhosub@wsub#1\DCohbaseParse@ENDSTATE#2#3{%
2158 \qitobjAddArg{#1_{\begingroup\let\emptysystem\relax%
2159 \DCohbaseStateSubscripts{#2}{#3}\endgroup}}% all this for "rho" arg
2160 }
2161 % \end{macrocode}
2162 % \end{macro}
2163 %
2164 % \begin{macro}{\DCohbaseStateSubscripts}
2165 % Macro which produces the relevant subscript for the state. By default,
2166 % simply produce ``$X'R$'' (but don't produce an ``empty system''
2167 % symbol). This macro may be overridden e.g. locally.
2168 % \begin{macrocode}
2169 \def\DCohbaseStateSubscripts#1#2{%
2170 #2#1%
2171 }
2172 % \end{macrocode}
2173 % \end{macro}
2174 %
2175 % \begin{macro}{\DCohbaseRender}
2176 % Render the coherent relative entropy.
2177 % \par |#1| = ``$D$'' symbol
2178 % \par |#2| = superscript (epsilon)
2179 % \par |#3| = possible size argument tokens (i.e., |[\big]|)
2180 % \par |#4| = fully decorated state (i.e., with necessary subscripts as required)
2181 % \par |#5| = input system name
2182 % \par |#6| = output system name
2183 % \par |#7| = Gamma-in
2184 % \par |#8| = Gamma-out
2185 % \begin{macrocode}
2186 \def\DCohbaseRender#1#2#3#4#5#6#7#8{%
2187 %
2188 %%\message{DEBUG: DCohbaseRender here, args are |\detokenize{{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}|.}}
2189 %
2190 \DCohbaseRenderSym{#1}%
2191 _{\DCohbaseRenderSystems{#5}{#6}}%
2192 ^{\DCohbaseRenderSup{#2}}%
2193 \notblank{#4#7#8}{%
2194 \DCohbaseRenderContents{#3}{#4}{#7}{#8}%
2195 }{}%
2196 % \end{macrocode}
2197 % We're done.
2198 % \begin{macrocode}
2199 \qitobjDone%
2200 }
2201 % \end{macrocode}
2202 % \end{macro}
2203 %
2204 % \needspace{5\baselineskip}
2205 % \begin{macro}{\DCohbaseRenderSym}
2206 % \begin{macro}{\DCohbaseRenderSystems}
2207 % \begin{macro}{\DCohbaseRenderSup}
2208 % Macros to render different parts of the entropy measure. By default, don't
2209 % do anything special to them (but this might be locally overridden in a
2210 % tuned Qit Object)
2211 % \begin{macrocode}
2212 \def\DCohbaseRenderSym#1{#1}%
2213 \def\DCohbaseRenderSystems#1#2{#1\to #2}%
2214 \def\DCohbaseRenderSup#1{#1}%
2215 % \end{macrocode}
2216 % \end{macro}
2217 % \end{macro}
2218 % \end{macro}
2219 %
2220 % \begin{macro}{\DCohbaseRenderContents}
2221 % Now we define the macro which formats the contents of the entropy.
2222 %
2223 % Define first a useful token register for rendering the contents.
2224 % \begin{macrocode}
2225 \newtoks\DCohbase@tmp@toks
2226 \def\DCohbase@addtoks#1\@DCohbase@END@ADD@TOKS{%
2227 \DCohbase@tmp@toks=\expandafter{\the\DCohbase@tmp@toks#1}}%
2228 % \end{macrocode}
2229 %
2230 % The arguments are |#1| = possible sizing argument tokens, |#2| = decorated
2231 % state, |#3| = Gamma-X, |#4| = Gamma-{X'}.
2232 % \begin{macrocode}
2233 \def\DCohbaseRenderContents#1#2#3#4{%
2234 % \end{macrocode}
2235 % We need to construct the parenthetic argument to the coherent relative
2236 % entropy, which we will prepare in the token register |\DCohbase@tmp@toks|.
2237 % Start with the state:
2238 % \begin{macrocode}
2239 \DCohbase@tmp@toks={#2}%
2240 % \end{macrocode}
2241 % \ldots{} add conditional system, if specified:
2242 % \begin{macrocode}
2243 \notblank{#3}{%
2244 \DCohbase@addtoks\mathclose{}\,\delimsize\Vert\,\mathopen{}%
2245 #3\@DCohbase@END@ADD@TOKS%
2246 \notblank{#4}{%
2247 \DCohbase@addtoks\mathclose{},\mathopen{}%
2248 #4\@DCohbase@END@ADD@TOKS%
2249 }{}%
2250 }{%
2251 \notblank{#4}{%
2252 \PackageWarning{phfqit}{Value `#4' ignored because previous parameter
2253 was blank}%
2254 }{}%
2255 }
2256 % \end{macrocode}
2257 % The tokens are ready now. Prepare the argument to the command
2258 % |\DCohbaseRenderContentsInnerParens| (by default just |\phfqitParens|), and go:
2259 % \begin{macrocode}
2260 \edef\tmp@args{\unexpanded{#1}{\the\DCohbase@tmp@toks}}%
2261 \expandafter\DCohbaseRenderContentsInnerParens\tmp@args%
2262 }
2263 % \end{macrocode}
2264 % \end{macro}
2265 %
2266 % \begin{macro}{\DCohbaseRenderContentsInnerParens}
2267 % Macro which expands to the parenthetic expression type macro we would like
2268 % to use. By default, this is |\phfqitParens|.
2269 % \begin{macrocode}
2270 \def\DCohbaseRenderContentsInnerParens{\phfqitParens}
2271 % \end{macrocode}
2272 % \end{macro}
2273 %
2274 % \begin{macro}{\DCohbase}
2275 % Finally, define the |\DCohbase| macro by declaring a new qit object.
2276 % \begin{macrocode}
2277 \DefineQitObject{DCohbase}{\DCohbaseParse}{\DCohbaseRender}
2278 % \end{macrocode}
2279 % \end{macro}
2280 %
2281 %
2282 % \subsection{Additional helpers for entropy measures}
2283 %
2284 % \begin{macro}{\HSym}
2285 % Symbol to use to denote an entropy measure.
2286 % \begin{macrocode}
2287 \def\HSym{H}
2288 % \end{macrocode}
2289 % \end{macro}
2290 %
2291 % \begin{macro}{\DSym}
2292 % Symbol to use to denote a relative entropy measure.
2293 % \begin{macrocode}
2294 \newcommand\DSym{D}
2295 % \end{macrocode}
2296 % \end{macro}
2297 %
2298 % \begin{macro}{\DCSym}
2299 % Symbol to use for the coherent relative entropy measure.
2300 % \begin{macrocode}
2301 \newcommand\DCSym{\bar\DSym}
2302 % \end{macrocode}
2303 % \end{macro}
2304 %
2305 % \begin{macro}{\emptysystem}
2306 % Designates the trivial system (uses symbol for empty set). It is important
2307 % to this, because of the automatic indexes set on the ``rho'' argument.
2308 % \begin{macrocode}
2309 \def\emptysystem{\ensuremath{\emptyset}}
2310 % \end{macrocode}
2311 % \end{macro}
2312 %
2313 % \begin{macro}{\DCohxRefSystemName}
2314 % \begin{macro}{\DCohxStateSubscripts}
2315 % Macros helpful for defining |\DCohx|.
2316 % \begin{macrocode}
2317 \def\DCohxRefSystemName#1{R_{#1}}
2318 \def\DCohxStateSubscripts#1#2{#2\DCohxRefSystemName{#1}}
2319 % \end{macrocode}
2320 % \end{macro}
2321 % \end{macro}
2322 %
2323 %
2324 % Finally, some macros provided for backwards compatibility:
2325 % \begin{macrocode}
2326 \let\@HHbase\Hbase
2327 \let\@DDbase\Dbase
2328 \let\HHSym\HSym
2329 \let\DDSym\DSym
2330 % \end{macrocode}
2331 %
2332 %
2333 % \subsection{Handle package options}
2334 %
2335 % \changedreftext{v2.0-pkg-opt-qitobjdef}
2336 % \changedreftext{v2.0-pkg-opt-newReIm}
2337 %
2338 % Initialization code for \pkgname{kvoptions} for our package options. See
2339 % \autoref{sec:pkg-options}.
2340 % \begin{macrocode}
2341 \SetupKeyvalOptions{
2342 family=phfqit,
2343 prefix=phfqit@opt@
2344 }
2345 % \end{macrocode}
2346 %
2347 % Set of predefined qit objects to load. Either |stdset| (standard set, the
2348 % default) or |none| (none).
2349 % \begin{macrocode}
2350 \DeclareStringOption[stdset]{qitobjdef}
2351 % \end{macrocode}
2352 %
2353 % Whether we should load the |\llangle| and |\rrangle| delimiters from the
2354 % MnSymbol fonts.
2355 % \begin{macrocode}
2356 \DeclareBoolOption[true]{llanglefrommnsymbolfonts}
2357 % \end{macrocode}
2358 %
2359 % Whether to override \LaTeX{}'s default {\makeatletter $\phfqit@Re$ and
2360 % $\phfqit@Im$} symbols by our more readable $\Re$ and $\Im$.
2361 % \begin{macrocode}
2362 \DeclareBoolOption[true]{newReIm}
2363 % \end{macrocode}
2364 %
2365 %
2366 % Process package options.
2367 % \begin{macrocode}
2368 \ProcessKeyvalOptions*
2369 % \end{macrocode}
2370 %
2371 %
2372 % \subsubsection{Re/Im symbols}
2373 %
2374 % \begin{macro}{\Re}
2375 % \begin{macro}{\Im}
2376 % Provide |\Re| and |\Im| commands to override \LaTeX{}'s default if the
2377 % corresponding package option is set (which is the default).
2378 % \begin{macrocode}
2379 \ifphfqit@opt@newReIm
2380 \renewcommand{\Re}{\phfqit@Realpart}
2381 \renewcommand{\Im}{\phfqit@Imagpart}
2382 \fi
2383 % \end{macrocode}
2384 % \end{macro}
2385 % \end{macro}
2386 %
2387 % \subsubsection{Load \phfverb{\llangle} and \phfverb{\rrangle} from the
2388 % \emph{MnSymbol} fonts}
2389 %
2390 % We need to import |\llangle| and |\rrangle| from the |MnSymbol|
2391 % fonts.\footnote{see e.g. \url{https://tex.stackexchange.com/a/79701/32188}}
2392 %
2393 % \begin{macrocode}
2394 \ifphfqit@opt@llanglefrommnsymbolfonts
2395 \DeclareFontFamily{OMX}{MnSymbolE}{}
2396 \DeclareSymbolFont{phfqit@MnLargeSymbols}{OMX}{MnSymbolE}{m}{n}
2397 \SetSymbolFont{phfqit@MnLargeSymbols}{bold}{OMX}{MnSymbolE}{b}{n}
2398 \DeclareFontShape{OMX}{MnSymbolE}{m}{n}{
2399 <-6> MnSymbolE5
2400 <6-7> MnSymbolE6
2401 <7-8> MnSymbolE7
2402 <8-9> MnSymbolE8
2403 <9-10> MnSymbolE9
2404 <10-12> MnSymbolE10
2405 <12-> MnSymbolE12
2406 }{}
2407 \DeclareFontShape{OMX}{MnSymbolE}{b}{n}{
2408 <-6> MnSymbolE-Bold5
2409 <6-7> MnSymbolE-Bold6
2410 <7-8> MnSymbolE-Bold7
2411 <8-9> MnSymbolE-Bold8
2412 <9-10> MnSymbolE-Bold9
2413 <10-12> MnSymbolE-Bold10
2414 <12-> MnSymbolE-Bold12
2415 }{}
2416 \let\llangle\@undefined
2417 \let\rrangle\@undefined
2418 \DeclareMathDelimiter{\llangle}{\mathopen}%
2419 {phfqit@MnLargeSymbols}{'164}{phfqit@MnLargeSymbols}{'164}
2420 \DeclareMathDelimiter{\rrangle}{\mathclose}%
2421 {phfqit@MnLargeSymbols}{'171}{phfqit@MnLargeSymbols}{'171}
2422 \fi
2423 % \end{macrocode}
2424 %
2425 % \subsubsection{Standard entropy measures}
2426 %
2427 % Load the requested set of qit objects.
2428 % \begin{macrocode}
2429 \def\phfqit@tmp@str@none{none}
2430 \def\phfqit@tmp@str@stdset{stdset}
2431 \ifx\phfqit@opt@qitobjdef\phfqit@tmp@str@none%
2432 % \end{macrocode}
2433 % In this case, do not load any definitions.
2434 % \begin{macrocode}
2435 \else\ifx\phfqit@opt@qitobjdef\phfqit@tmp@str@stdset%
2436 % \end{macrocode}
2437 % In this case, provide our standard set of ``qit objects'' (i.e., entropy
2438 % measures).
2439 %
2440 % \needspace{4\baselineskip}
2441 % \begin{macro}{\HH}
2442 % \begin{macro}{\Hzero}
2443 % \begin{macro}{\Hmin}
2444 % \begin{macro}{\Hmaxf}
2445 % The definition of individual entropy macros just delegates to |\Hbase|
2446 % with the relevant subscript.
2447 % \begin{macrocode}
2448 \def\HH{\Hbase{\HSym}{}}
2449 \def\Hzero{\Hbase{\HSym}{\mathrm{max},0}}
2450 \def\Hmin{\Hbase{\HSym}{\mathrm{min}}}
2451 \def\Hmaxf{\Hbase{\HSym}{\mathrm{max}}}
2452 \def\Hfn{\Hfnbase{\HSym}{}{}}
2453 \let\Hfunc\Hfn% backwards compatibility
2454 % \end{macrocode}
2455 % \end{macro}
2456 % \end{macro}
2457 % \end{macro}
2458 % \end{macro}
2459 %
2460 %
2461 % \begin{macro}{\DD}
2462 % (Usual) quantum relative entropy. (Actually this is more versatile, because
2463 % you can also specify subscript and superscript, so you can make on-the-fly
2464 % custom relative entropy measures.)
2465 % \begin{macrocode}
2466 \def\DD{\Dbase{\DSym}}
2467 % \end{macrocode}
2468 % \end{macro}
2469 %
2470 % \begin{macro}{\Dminz}
2471 % ``Old'' min-relative entropy, based on the R\'enyi-zero relative entropy.
2472 % \begin{macrocode}
2473 \newcommand\Dminz[1][]{\Dbase{\DSym}_{\mathrm{min,0}}^{#1}}
2474 % \end{macrocode}
2475 % \end{macro}
2476 %
2477 % \begin{macro}{\Dminf}
2478 % Min-relative entropy (``new'' version).
2479 % \begin{macrocode}
2480 \newcommand\Dminf[1][]{\Dbase{\DSym}_{\mathrm{min}}^{#1}}
2481 % \end{macrocode}
2482 % \end{macro}
2483 %
2484 % \begin{macro}{\Dmax}
2485 % Max-relative entropy.
2486 % \begin{macrocode}
2487 \newcommand\Dmax[1][]{\Dbase{\DSym}_{\mathrm{max}}^{#1}}
2488 % \end{macrocode}
2489 % \end{macro}
2490 %
2491 % \begin{macro}{\Dr}
2492 % Rob-relative entropy.
2493 % \begin{macrocode}
2494 \newcommand\Dr[1][]{\Dbase{\DSym}_{\mathrm{r}}^{#1}}
2495 % \end{macrocode}
2496 % \end{macro}
2497 %
2498 %
2499 % \begin{macro}{\DHyp}
2500 % Hypothesis testing relative entropy.
2501 % \begin{macrocode}
2502 \newcommand\DHyp[1][\eta]{\Dbase{\DSym}_{\mathrm{H}}^{#1}}
2503 % \end{macrocode}
2504 % \end{macro}
2505 %
2506 % \begin{macro}{\Dhyp}
2507 % Hypothesis testing relative entropy (alternative definition).
2508 % \changed[v3.1-added-Dhyp-qitobjdef-stdset]{v3.1}{2021/07/27}{Added the
2509 % \phfverb{\Dhyp} variant of the hypothesis testing relative entropy}
2510 % \begin{macrocode}
2511 \newcommand\Dhyp[1][\eta]{\Dbase{\DSym}_{\mathrm{h}}^{#1}}
2512 % \end{macrocode}
2513 % \end{macro}
2514 %
2515 % \begin{macro}{\DCoh}
2516 % Coherent relative entropy (old style).
2517 % \begin{macrocode}
2518 \DefineTunedQitObject{DCoh}{\DCohbaseParse}{\DCohbaseRender}{{\DCSym}}{}
2519 % \end{macrocode}
2520 % \end{macro}
2521 %
2522 % \begin{macro}{\DCohx}
2523 % Coherent relative entropy (new style).
2524 % \begin{macrocode}
2525 \DefineTunedQitObject{DCohx}{\DCohbaseParse}{\DCohbaseRender}%
2526 {{\DCSym}}{%
2527 \let\DCohbaseStateSubscripts\DCohxStateSubscripts%
2528 }
2529 % \end{macrocode}
2530 % \end{macro}
2531 %
2532 %
2533 % End case |qitobjdef=stdset|. Last case is the final |\else| branch which is an
2534 % error, as we have an unknown set of standard definitions to load.
2535 % \begin{macrocode}
2536 \else
2537 \PackageError{phfqit}{Invalid value `\phfqit@opt@qitobjdef' specified for
2538 package option `qitobjdef'. Please specify one of `stdset' (the default) or
2539 `none'}{You specified an invalid value to the `qitobjdef' package option of
2540 the `phfqit' package.}
2541 \fi
2542 \fi
2543 % \end{macrocode}
2544 %
2545 %
2546 % \Finale
2547 \endinput