summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-08-20 22:13:28 +0000
committerKarl Berry <karl@freefriends.org>2017-08-20 22:13:28 +0000
commitdb59a59aaaa697ab9e342dd19f098f8ce33294a0 (patch)
tree4ab25cb85b56437f43e37d8c0701d18e991eec51 /Master/texmf-dist/source
parent30c193b890874a6cd3065cb3f16b5845c4614e60 (diff)
phfqit (20aug17)
git-svn-id: svn://tug.org/texlive/trunk@45084 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/phfqit/phfqit.dtx1600
-rw-r--r--Master/texmf-dist/source/latex/phfqit/phfqit.ins4
2 files changed, 1214 insertions, 390 deletions
diff --git a/Master/texmf-dist/source/latex/phfqit/phfqit.dtx b/Master/texmf-dist/source/latex/phfqit/phfqit.dtx
index b828d60798b..60833cd48e8 100644
--- a/Master/texmf-dist/source/latex/phfqit/phfqit.dtx
+++ b/Master/texmf-dist/source/latex/phfqit/phfqit.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2016 by Philippe Faist <philippe.faist@bluewin.ch>
+% Copyright (C) 2016 by Philippe Faist, philippe.faist@bluewin.ch
% -------------------------------------------------------
%
% This file may be distributed and/or modified under the
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{phfqit}
%<*package>
- [2016/08/15 v1.0 phfqit package]
+ [2017/08/16 v2.0 phfqit package]
%</package>
%
%<*driver>
@@ -67,7 +67,7 @@
%
% \GetFileInfo{phfqit.dtx}
%
-% \DoNotIndex{\newcommand,\newenvironment,\def,\gdef,\edef,\xdef,\if,\else,\fi,\ifx}
+% \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}
%
% \title{\phfqitltxPkgTitle{phfqit}}
% \author{Philippe Faist\quad\email{philippe.faist@bluewin.ch}}
@@ -106,13 +106,29 @@
%
% \section{Basic Usage}
%
-% This package is straightforward to use. There are no package options.
+% \label{sec:pkg-options}
+%
+% This package is straightforward to use:
% \begin{verbatim}
% \usepackage{phfqit}
% \end{verbatim}
%
-% [TODO: In the future, use package options to control which definitions we
-% want?]
+% A single package option controls which entropy measures are defined for you.
+%
+% \begin{pkgoptions}
+% \item[qitobjdef=\meta{\phfverb{stdset} $\mid$ \phfverb{none}}] Load
+% the predefined set of ``qit objects, '' i.e., entropy measures. The entropy
+% measures documented below (and specified as such) will be loaded unless you
+% set \pkgoptionfmt{qitobjdef=none}.
+% \item[newReIm=\metatruefalsearg] Do not override \LaTeX{}'s default
+% {\makeatletter $\phfqit@Re$ and $\phfqit@Im$} symbols by $\Re$ and $\Im$.
+% See \autoref{sec:description-newReIm}.
+% \end{pkgoptions}
+%
+% \changed[v2.0-pkg-opt-qitobjdef]{v2.0}{2017/08/16}{Added the
+% \phfverb{qitobjdef} package option}
+% \changed[v2.0-pkg-opt-newReIm]{v2.0}{2017/08/16}{Added the \phfverb{newReIm}
+% package option}
%
% \subsection{Semantic vs. Syntactic Notation}
%
@@ -161,6 +177,7 @@
% \end{center}
%
%
+%
% \section{General Symbols (and Math Operators)}
% \label{sec:symbols}
%
@@ -187,15 +204,16 @@
% \autoref{topic:size-specification-backtick}.
%
% \begingroup\catcode`\^=12\relax
-% \DescribeMacro{\ee^X}\endgroup
-% A macro for the exponential. Type the \LaTeX{} code as if |\ee| were just the symbol,
-% i.e.\@ as |\ee^{<ARGUMENT>}|. The ideas is that this macro may be redefined to change
-% the appearance of the $e$ symbol, or even to change the notation to |\exp{<ARGUMENT>}|
-% if needed for inline math.
+% \DescribeMacro{\ee^X}\endgroup A macro for the exponential. Type the \LaTeX{}
+% code as if |\ee| were just the symbol, i.e.\@ as |\ee^{<ARGUMENT>}|. The
+% ideas is that this macro may be redefined to change the appearance of the $e$
+% symbol, or even to change the notation to |\exp{<ARGUMENT>}| if needed for
+% inline math.
%
%
% \subsection{Math/Linear Algebra Operators}
% \label{sec:math-operators}
+% \label{sec:description-newReIm}
%
% \needspace{6\baselineskip}
% \DescribeMacro{\tr} \DescribeMacro{\supp} \DescribeMacro{\rank}
@@ -208,12 +226,12 @@
% \DescribeMacro{\Re} \DescribeMacro{\Im} Also, redefine |\Re| and |\Im| (real
% and imaginary parts of a complex number), to the more readable $\Re(z)$ and
% $\Im(z)$. (The original symbols were {\makeatletter $\phfqit@Re(z)$ and
-% $\phfqit@Im(z)$}.)
+% $\phfqit@Im(z)$}.) Keep the old definitions using the package option
+% \pkgoptionfmt{newReIm=false}.
%
% \subsection{Poly symbol}
%
% \DescribeMacro{\poly} Can be typeset in $\poly(n)$ time.
-% \iffalse meta-comment \changedreftext{v1.0-added-poly-command} \fi
%
%
% \subsection{Bits and Bit Strings}
@@ -323,45 +341,64 @@
%
%
%
-% \section{Entropy Measures}
-%
-% \subsection{Entropy, Conditional Entropy}
-% \label{sec:entropy-measures}
+% \section{Entropy Measures and Other ``Qit Objects''}
%
-% The entropy measures (except for |\Hfunc|) all share the same syntax. This
-% syntax is only described for the min-entropy |\Hmin|, but the other entropy
-% measures enjoy the same features.
-%
-% The name of the macros are chosen such that they identify the \emph{abstract
-% entropy measure}, and not necessarily the way one uses to write it down in a
-% specific context. For example, for the ``old'' max-entropy
+% A ``Qit Object'' is any form of quantity which has several parameters and/or
+% arguments which are put together in some notation. The idea is to use
+% \LaTeX{} macros to represent an actual quantity and not just some set of
+% notational symbols. For example, for the ``old'' max-entropy
% $H_\mathrm{max,old}(X)_\rho = \log\rank\rho$, you should use |\Hzero|
% independently of whether it should be denoted by $H_0$, $H_\mathrm{max}$ or
% $H_\mathrm{max,old}$. This allows you to change the notation by redefining
% the command |\Hzero|, while making sure that the correct quantity is
% addressed. (You might have both ``old''-style and ``new''-style max-entropy
-% in the same paper.) The macros |\Hmin|, |\Hzero|, |\Hmaxf| and |\HH| may be
-% redefined to change the subscript by using the following code (change
+% in the same paper. Their meaning should never change, even if you change your
+% mind on the notation.) The macros |\Hmin|, |\Hzero|, |\Hmaxf| and |\HH| may
+% be redefined to change the subscript by using the following code (change
% ``|\mathrm{max},0|'' to your favorite subscript text):
% \begin{verbatim}
-% \makeatletter
-% \renewcommand\Hzero{\@HHbase{\HHSym}{\mathrm{max},0}}
-% \makeatother
+% \renewcommand{\Hzero}{\Hbase{\HSym}{\mathrm{max},0}}
% \end{verbatim}
%
+% The \pkgname{phfqit} package provides a basic infrastructure allowing to
+% define such ``Qit Object'' implementations. This package provides the
+% following Qit Objects: entropy measures (|\Hbase|), an entropy function
+% (|\Hfnbase|), relative entropy measures (|\Dbase|), as well as coherent
+% relative entropy measures (|\DCohbase|). The more specific commands |\Hmin|,
+% |\Hzero|, etc.\@ are then defined based on these ``base commands.''
+%
+% You may also define your own Qit Object implementations. See
+% \autoref{sec:QitObjectImpl} for documentation on that.
+%
+% The actual entropy measure definitions |\Hmin|, |\Hmaxf|, etc., can be
+% disabled by specifying the package option \pkgoptionfmt{qitobjdef=none}.
+%
+%
+% \subsection{Entropy, Conditional Entropy}
+% \label{sec:entropy-measures}
+%
+% These entropy measures all share the same syntax. This syntax is only
+% described for the min-entropy |\Hmin|, but the other entropy measures enjoy
+% the same features.
+%
% These commands are robust, meaning they can be used for example in figure
% captions and section headings.
%
% \DescribeMacro{\Hmin} Min-entropy. The general syntax is
-% |\Hmin|\hspace{0pt}\oarg{state}\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
+% |\Hmin|\hspace{0pt}\meta{size-spec}\relax
+% \hspace{0pt}\oarg{state}\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
% \marg{target system}\hspace{0pt}\oarg{conditioning system}. For example:
% \begin{center}
% \begin{tabular}{lc}
% |\Hmin{X}| & $\Hmin{X}$ \\
% |\Hmin[\rho]{X}| & $\Hmin[\rho]{X}$ \\
% |\Hmin[\rho][\epsilon]{X}[Y]| & $\Hmin[\rho][\epsilon]{X}[Y]$ \\
-% \verb+\Hmin[\rho|\rho][\epsilon]{X}[Y]+ & $\Hmin[\rho\mid\rho][\epsilon]{X}[Y]$ \\
-% |\Hmin[][\epsilon]{X}[Y]| & $\Hmin[][\epsilon]{X}[Y]$ \\
+% \verb+\Hmin[\rho|\rho][\epsilon]{X}[Y]+
+% & $\Hmin[\rho\mid\rho][\epsilon]{X}[Y]$ \\
+% |\Hmin[][\epsilon]{X}[Y]| & $\Hmin[][\epsilon]{X}[Y]$ \\[1ex]
+% |\Hmin`\Big[\rho]{X}[Y]| & $\Hmin`\Big[\rho][\epsilon]{X}[Y]$ \\[0.5ex]
+% |\Hmin`*[\rho]{\bigoplus_i X_i}[Y]| &
+% $\displaystyle\Hmin`*[\rho][\epsilon]{\bigoplus_i X_i}[Y]$
% \end{tabular}
% \end{center}
%
@@ -378,25 +415,88 @@
% arguments as for |\Hmin|. For example, |\Hmaxf[][\epsilon]{X}[Y]| gives
% $\Hmaxf[][\epsilon]{X}[Y]$.
%
-% \DescribeMacro{\Hfunc} The entropy, written as a mathematical function. It is
-% useful to write, e.g., $\Hfunc(p_1\rho_1 + p_2\rho_2)$ (code:
-% |\Hfunc(p_1\rho_1 + p_2\rho_2)|). Sizing specifications also work, e.g.\@
-% |\Hfunc`\big(x)| or |\Hfunc`*(x)|. However there is neither support for an
-% epsilon-like superscript nor for a conditioning system.
+% The commands |\Hmin|, |\HH|, |\Hzero|, and |\Hmaxf| are defined only if the
+% package option \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
%
-% \DescribeMacro{\HHSym} You may redefine this macro if you want to change the
+% \DescribeMacro{\HSym} You may redefine this macro if you want to change the
% ``$H$'' symbol of all entropy measures.
-% \begingroup \def\HHSym{\spadesuit} For example, with
-% |\renewcommand\HHSym{\spadesuit}|, |\Hmin{A}[B]| would give $\Hmin{A}[B]$.
+% \begingroup \def\HSym{\spadesuit} For example, with
+% |\renewcommand\HSym{\spadesuit}|, |\Hmin{A}[B]| would give $\Hmin{A}[B]$.
% \endgroup
%
-% \subsection{Relative Entropy Measures}
+% \paragraph{Appearance and alternative notation.}
+% You may change the notation of any of the above entropy measures by redefining
+% the corresponding commands as follows:
+% \begin{verbatim}
+% \renewcommand{\Hzero}{\Hbase{\HSym}{\mathrm{max}}}
+% \end{verbatim}
+% \begingroup\renewcommand{\Hzero}{\Hbase{\HSym}{\mathrm{max}}}
+% Then, |\Hzero[\rho]{A}[B]| would produce: $\Hzero[\rho]{A}[B]$.\endgroup
+%
+% \paragraph{Base entropy measure macro.}
+% \DescribeMacro{\Hbase} Base macro entropy for an entropy measure. The general
+% syntax is:
+% |\Hbase|\hspace{0pt}\marg{H-symbol}\hspace{0pt}\marg{subscript}\relax
+% \hspace{0pt}\oarg{state}\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
+% \marg{target system}\hspace{0pt}\oarg{conditioning system}
+%
+% Using this macro it is easy to define custom special-purpose entropy measures,
+% for instance:
+% \begin{verbatim}
+% \newcommand\Hxyz{\Hbase{\tilde\HSym}{\mathrm{xyz}}}
+% \end{verbatim}
+% \begingroup\newcommand\Hxyz{\Hbase{\tilde\HSym}{\mathrm{xyz}}}
+% The above code defines the command |\Hxyz[\rho][\epsilon]{A}[B]| $\to$
+% \fbox{$\Hxyz[\rho][\epsilon]{A}[B]$}. \endgroup
+%
+% See also the implementation documentation below for more specific information
+% on how to customize parts of the rendering, for instance.
+%
+% \subsection{Entropy Function}
+% \label{sec:entropy-function}
+%
+% \DescribeMacro{\Hfn} The entropy, written as a mathematical function. It is
+% useful to write, e.g., $\Hfunc(p_1\rho_1 + p_2\rho_2)$ as \relax
+% |\Hfunc(p_1\rho_1 + p_2\rho_2)|. Sizing specifications also work, e.g.\@
+% |\Hfunc`\big(x)| or |\Hfunc`*(x)|.
+%
+% Usage is: |\Hfn|\hspace{0pt}\meta{size-spec}\hspace{0pt}|(|\meta{argument}|)|
+%
+% This macro doesn't allow for any subscript, any epsilon-like superscript nor
+% for any conditioning system. Define your own macro on top of |\Hfnbase| if
+% you need that.
+%
+% Note that the \meta{argument} may contain matching parentheses, e.g.,
+% |\Hfn`\Big( g(x) + h(y) )| $\to$ \fbox{$\Hfn`\Big(g(x)+h(y))$}.
+%
+% \DescribeMacro{\Hfunc}
+% The alias |\Hfunc| is provided for backwards compatibility; same as |\Hfn|.
+%
+% The commands |\Hfn| and |\Hfunc| are defined only if the package option
+% \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
+%
+% \DescribeMacro{\Hfnbase} There is also a base macro for this kind of Qit
+% Object, |\Hfnbase|. It allows you to specify an arbitrary symbol to use for
+% ``$H$'', as well as custom subscripts and superscripts. The syntax is:
+%
+% |\Hfnbase|\marg{H-symbol}\hspace{0pt}\marg{sub}\hspace{0pt}\relax
+% \marg{sup}\hspace{0pt}\relax
+% \meta{size-spec}\hspace{0pt}|(|\meta{argument}|)|.
+%
+%
+% \subsection{Relative Entropy}
% \label{sec:relative-entropies}
%
% Relative entropies also have a corresponding set of commands.
%
+% The syntax varies from command to command, but all relative entropies accept
+% the final arguments \meta{size-spec}\marg{state}\marg{relative-to-state}. The
+% size-spec is as always given using the backtick syntax described in
+% \autoref{topic:size-specification-backtick}.
+%
% \DescribeMacro{\DD}
-% Generic relative entropy. The syntax of this command is either of the following:\\
+% Generic relative entropy. The syntax of this command is either of the following:
+% \par
% |\DD|\hspace{0pt}\meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state},\\
% |\DD_|\marg{subscript}\hspace{0pt}\meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state},\\
% |\DD_|\marg{subscript}|^|\marg{superscript}\hspace{0pt}\meta{size-spec}\relax
@@ -406,15 +506,15 @@
% In all cases, the argument is typeset as:
% $\bigl(\meta{state}\big\Vert\meta{relative-to state}\bigr)$. The size of the
% delimiters can be set with a size specification using the standard backtick
-% syntax, as for the other entropies and as described in
-% \autoref{topic:size-specification-backtick}.
+% syntax as described in \autoref{topic:size-specification-backtick} (as for the
+% other entropy measures).
%
% Examples:
% \begin{center}
% \begin{tabular}{lc}
-% |\DD{\rho}{\sigma}| & $\DD{\rho}{\sigma}$ \\
-% |\DD*{\rho}{\sigma}| & $\DD*{\rho}{\sigma}$ \\
-% |\DD`\big{\rho}{\sigma}| & $\DD`\big{\rho}{\sigma}$ \\
+% |\DD{\rho}{\sigma}| & $\DD{\rho}{\sigma}$ \\[1ex]
+% |\DD`*{M_1^\dagger M_1}{\sigma}| & $\DD`*{M_1^\dagger M_1}{\sigma}$ \\[1ex]
+% |\DD`\Big{\rho}{\sigma}| & $\DD`\Big{\rho}{\sigma}$ \\
% \end{tabular}
% \end{center}
%
@@ -437,9 +537,6 @@
% $\Dmax[\epsilon]{\rho}{\sigma}$ and |\Dmax[\epsilon]`\big{\rho}{\sigma}| gives
% $\Dmax[\epsilon]`\big{\rho}{\sigma}$.
%
-% The size-spec is as always given using the backtick syntax described in
-% \autoref{topic:size-specification-backtick}.
-%
% \DescribeMacro{\Dminz} The ``old'' min-relative entropy, based on the
% R\'enyi-zero relative entropy. The syntax is the same as for
% |\Dmax|.
@@ -457,43 +554,284 @@
% in, and it is not a zero-error quantity which is smoothed with the purified
% distance.)
%
-% \DescribeMacro{\DDSym} The symbol to use to denote a relative entropy. You
-% may redefine this command to change the symbol. (This works like |\HHSym|
+% The commands |\DD|, |\Dmax|, |\Dminz|, |\Dminf|, |\Dr| and |\DHyp| are defined
+% only if the package option \pkgoptionfmt{qitobjdef=stdset} is set (which is
+% the default).
+%
+% \DescribeMacro{\DSym} The symbol to use to denote a relative entropy. You
+% may redefine this command to change the symbol. (This works like |\HSym|
% above.)
%
+% \paragraph{Appearance and alternative notation}
+% You may change the notation of any of the above relative entropy measures by
+% redefining the corresponding commands as follows:
+% \begin{verbatim}
+% \renewcommand{\Dminz}[1][]{\Dbase{\DSym}_{\mathrm{MIN}}^{#1}}
+% \end{verbatim}
+% \begingroup\renewcommand{\Dminz}[1][]{\Dbase{\DSym}_{\mathrm{MIN}}^{#1}}
+% The above command produces: |\Dminz[\epsilon]{\rho}{\sigma}| $\to$
+% \fbox{$\Dminz[\epsilon]{\rho}{\sigma}$}.\endgroup
+%
%
-% \subsection{Coherent Relative Entropy}
-% \label{sec:coh-rel-entr}
+% \paragraph{Base relative entropy command}
+% As for the $H$-type entropy measures, there is a ``base relative entropy
+% command'' |\Dbase|. Its syntax is:
+% \par |\Dbase|\marg{D-symbol}\hspace{0pt}\relax
+% [|_|\marg{subscript}][|^|\marg{superscript}]\hspace{0pt}\meta{size-spec}\relax
+% \hspace{0pt}\marg{state}\hspace{0pt}\marg{relative-to state}
%
-% A macro for a new quantity, the coherent relative entropy, is also available.
+% Example: |\Dbase{\hat\DSym}_{0}^{\eta'}`\Big{\rho}{\sigma}| $\to$
+% \fbox{$\Dbase{\hat\DSym}_{0}^{\eta'}`\Big{\rho}{\sigma}$}
%
-% \DescribeMacro{\DCoh}
-% Typeset a coherent relative entropy. The syntax is
-% |\DCoh|\hspace{0pt}\oarg{epsilon}\hspace{0pt}\meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
-% \marg{A}\hspace{0pt}\marg{B}\hspace{0pt}\marg{Gamma-1}\hspace{0pt}\marg{Gamma-2}.
+% The ``|_|\marg{subscript}'' and ``|^|\marg{superscript}'' parts are optional
+% and may be specified in any order.
+%
+% See also the implementation documentation below for more specific information
+% on how to customize parts of the rendering, for instance.
+%
+%
+% \subsection{Coherent Relative Entropy}
+% \label{sec:coh-rel-entr}
%
-% For example, |\DCoh[\epsilon]{\rho}{A}{B}{\Gamma_A}{\Gamma_B}| gives
-% $\DCoh[\epsilon]{\rho}{A}{B}{\Gamma_A}{\Gamma_B}$.
+% A macro for the coherent relative entropy is also available.
%
-% The subscript |BA| is automatically added to the \meta{rho} argument. If this
-% is not desired, then begin the \meta{rho} argument with a star. For example,
-% |\DCoh{*\sigma_A\otimes\rho_B}{A}{B}{\Gamma_A}{\Gamma_B}| gives
-% $\DCoh{*\sigma_A\otimes\rho_B}{A}{B}{\Gamma_A}{\Gamma_B}$.
+% \DescribeMacro{\DCohx} Typeset a coherent relative entropy using an
+% alternative form for the reference system. The syntax is:
+%
+% |\DCohx|\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
+% \meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
+% \marg{X}\hspace{0pt}\marg{X'}\hspace{0pt}\relax
+% \marg{$\Gamma_X$}\hspace{0pt}\marg{$\Gamma_{X'}$}
+%
+% For example, |\DCohx[\epsilon]{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}| gives
+% $\DCohx[\epsilon]{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}$.
+%
+% The subscript $X'R_X$ (or whatever the system names) is automatically added to
+% the \meta{rho} argument. The `$R$' symbol is used by default for designating
+% the reference system; you may change that by redefining |\DCohxRefSystemName|
+% (see below). If no subscript should be added to the \meta{rho} argument, then
+% begin the \meta{rho} argument with a star. For example,
+% |\DCoh{*\sigma_R\otimes\rho_{X'}}{X}{X'}{\Gamma_X}{\Gamma_{X'}}| gives
+% $\DCoh{*\sigma_R\otimes\rho_{X'}}{X}{X'}{\Gamma_X}{\Gamma_{X'}}$.
%
% The \meta{size-spec} is of course optional and follows the same syntax as
% everywhere else (\autoref{topic:size-specification-backtick}).
%
+% The command |\DCohx| is defined only if the package option
+% \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
+%
% \DescribeMacro{\emptysystem} Use the |\emptysystem| macro to denote a trivial
% system. For example, |\DCoh{\rho}{X}{\emptysystem}{\Gamma}{1}| gives
% $\DCoh{\rho}{X}{\emptysystem}{\Gamma}{1}$.
%
+% \DescribeMacro{\DCohxRefSystemName} When using |\DCohx|, the macro
+% |\DCohxRefSystemName| is invoked to produce the reference system name
+% corresponding to the input system name. By default, this is a $R_\cdot$
+% symbol with subscript the input system name. You may redefine this macro if
+% you prefer another reference system name:
+% \begin{verbatim}
+% \renewcommand\DCohxRefSystemName[1]{E_{#1}}
+% \end{verbatim}
+% \begin{flushleft}
+% \begingroup\renewcommand\DCohxRefSystemName[1]{E_{#1}}
+% Then: |\DCohx{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}| $\to$
+% $\DCohx{\rho}{X}{X'}{\Gamma_X}{\Gamma_{X'}}$
+% \endgroup
+% \end{flushleft}
+%
% \DescribeMacro{\DCSym} The symbol to use to denote a coherent relative
% entropy. You may redefine this command to change the symbol. (This works
-% like |\HHSym| and |\DDSym| above.)
+% like |\HSym| and |\DSym| above.)
+%
+% \DescribeMacro{\DCoh}
+% Typeset a coherent relative entropy using the old notation. The syntax is:
+%
+% |\DCoh|\hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
+% \meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
+% \marg{R}\hspace{0pt}\marg{X'}\hspace{0pt}\relax
+% \marg{$\Gamma_R$}\hspace{0pt}\marg{$\Gamma_{X'}$}
+%
+% For example, |\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}| gives
+% $\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}$.
+%
+% The subscript $X'R$ (or whatever the system names) is automatically added to
+% the \meta{rho} argument. If this is not desired, then begin the \meta{rho}
+% argument with a star. For example,
+% |\DCoh{*\sigma_R\otimes\rho_{X'}}{R}{X'}{\Gamma_R}{\Gamma_{X'}}| gives
+% $\DCoh{*\sigma_R\otimes\rho_{X'}}{R}{X'}{\Gamma_R}{\Gamma_{X'}}$.
+%
+% The \meta{size-spec} is of course optional and follows the same syntax as
+% everywhere else (\autoref{topic:size-specification-backtick}).
+%
+% The command |\DCoh| is defined only if the package option
+% \pkgoptionfmt{qitobjdef=stdset} is set (which is the default).
+%
+%
+% \paragraph{Appearance and alternative notation}
+% You may change the notation of any of the above relative entropy measures by
+% redefining the corresponding commands as follows:
+% \begin{verbatim}
+% \renewcommand{\DCoh}{\DCohbase{\tilde\DSym}}
+% \end{verbatim}
+% \begingroup\renewcommand{\DCoh}{\DCohbase{\tilde\DSym}}
+% Then: |\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}| $\to$
+% \fbox{$\DCoh[\epsilon]{\rho}{R}{X'}{\Gamma_R}{\Gamma_{X'}}$}.\endgroup
+%
+%
+% \paragraph{Base relative entropy command}
+% As for the other entropy measures, there is a ``base coherent relative entropy
+% command'' |\DCohbase|. Its syntax is:
+% \par |\DCohbase|\marg{D-symbol}\hspace{0pt}\relax
+% \hspace{0pt}\oarg{epsilon}\hspace{0pt}\relax
+% \meta{size-spec}\hspace{0pt}\marg{rho}\hspace{0pt}\relax
+% \marg{R}\hspace{0pt}\marg{X'}\hspace{0pt}\relax
+% \marg{$\Gamma_R$}\hspace{0pt}\marg{$\Gamma_{X'}$}
+%
+% See also the implementation documentation below for more specific information
+% on how to customize parts of the rendering, for instance.
+%
+%
%
+% \subsection{Custom Qit Objects}
+% \label{sec:QitObjectImpl}
%
+% \changedreftext{v2.0-qit-objects}
%
+% You can create your own Qit Object Implementation as follows. You need two
+% components: a \emph{Parse} macro and a \emph{Render} macro.
+%
+% The \emph{Parse} macro is responsible for parsing input \LaTeX{} tokens as
+% necessary, and building an argument list (which will be passed on to the
+% \emph{Render} macro).
+%
+% \DescribeMacro{\qitobjAddArg} \DescribeMacro{\qitobjAddArgx} The \emph{Parse}
+% macro (or any helper macro it calls) should call |\qitobjAddArg| to add
+% arguments for the eventual call to \emph{Render}. The |\qitobjAddArg| macro
+% does not expand its argument. The |\qitobjAddArgx| works like
+% |\qitobjAddArg|, but it accepts a single \LaTeX{} command as its only
+% argument, expands it, and adds the contents as a single new argument for the
+% renderer.
+%
+% \DescribeMacro{\qitobjParseDone}
+% Once the parser is finished, it must call |\qitobjParseDone|.
+%
+% The \emph{Render} macro is responsible for displaying the final Qit Object.
+% It should accept mandatory arguments in the exact number as there were calls
+% to |\qitobjAddArg|/|\qitobjAddArgx|.
+%
+% \DescribeMacro{\qitobjDone} The \emph{Render} macro must call |\qitobjDone|
+% after it is finished, to do some cleaning up and to close the local \LaTeX{}
+% group generated by the Qit Ojbect infrastructure.
+%
+% \DescribeMacro{\DefineQitObject} Declare your new Qit Object using the
+% |\DefineQitObject| macro, using the syntax
+% |\DefineQitObject|\marg{name}\marg{ParseCommand}\marg{RenderCommand}.
+% This declares the command |\|\meta{name} as your Qit Object.
+%
+% You may define different Qit Objects (using different names) recycling the
+% same parsers/renderers if needed. For instance, |\Hfnbase| uses the same
+% renderer as |\Hbase|.
+%
+% \DescribeMacro{\DefineTunedQitObject} The |\DefineTunedQitObject| macro is a
+% bit more powerful. It allows you to specify some fixed initial arguments to
+% the parser, as well as to provide some local definitions which are in effect
+% only during parsing and rendering of the Qit Object. This is useful if you
+% would like to declare an alternative type of Qit Object to an existing one,
+% where you just change some aspect of the behavior of the original Qit Object.
+%
+% Usage: |\DefineTunedQitObject|\hspace{0pt}\marg{name}\relax
+% \marg{parse command}\hspace{0pt}\marg{render command}\hspace{0pt}\relax
+% \marg{fixed first argument(s)}\hspace{0pt}\marg{custom definitions}\relax
+%
+% The \marg{first fixed argument(s)} must be a single argument, i.e., a single
+% \LaTeX{} group, which may contain several arguments, for instance: |{{A}{B}}|.
+%
+% For instance, |\DCohx| is defined, using the same parser and renderer as for
+% |\DCoh|, as follows:
+% \begin{verbatim}
+%\def\DCohxRefSystemName#1{R_{#1}}
+%\def\DCohxStateSubscripts#1#2{#2\DCohxRefSystemName{#1}}
+%\DefineTunedQitObject{DCohx}{\DCohbaseParse}{\DCohbaseRender}%
+%{{\DCSym}}% initial args
+%{\let\DCohbaseStateSubscripts\DCohxStateSubscripts}% local defs
+% \end{verbatim}
+%
%
+% \paragraph{Useful helpers}
+%
+% There are some useful helpers for both the \emph{Parse} and \emph{Render}
+% macros. More extensive documentation is available in the ``Implementation''
+% section below.
+%
+% \DescribeMacro{\phfqit@parse@sizesarg} Parse a \meta{size-spec} optional
+% argument.
+%
+% \needspace{3\baselineskip}
+% \DescribeMacro{\phfqitParen} \DescribeMacro{\phfqitSquareBrackets}
+% \DescribeMacro{\phfqitCurlyBrackets} Produce a parenthetic expression (or
+% square or curly brackets) with the appropriate size and with the given
+% contents.
+%
+% \paragraph{Example}
+% Here is a simple example: let's build a work cost of transition Qit Object to
+% display something like ``$W(\sigma\to\rho)$.''
+%
+% The arguments to be given are: they are \meta{$\sigma$} and \meta{$\rho$}. We
+% would also like to accept an optional size specification \meta{size-spec}. We
+% should decide on a convenient syntax to specify them. Here, we'll settle for
+% simply |\WorkCostTransition`\Big{\rho}{\sigma}|.
+%
+% We can now write the \emph{Parse} macro. We use the |\phfqit@parsesizearg|
+% helper, which stores the optional \meta{size-spec} into the
+% |\phfqit@val@sizearg| macro before deferring our second helper macro. We then
+% add arguments (for an eventual call to the \emph{Render} macro) using
+% |\qitobjAddArg| (or |\qitobjAddArgx|).
+% \begin{verbatim}
+% \makeatletter
+% \newcommand\WorkCostTransitionParse{%
+% \phfqit@parsesizearg\WorkCostTransitionParse@%
+% }
+% % Helper to parse further input arguments:
+% \newcommand\WorkCostTransitionParse@[2]{% {\rho}{\sigma}
+% \qitobjAddArgx\phfqit@val@sizearg% size arg
+% \qitobjAddArg{#1}% rho
+% \qitobjAddArg{#2}% sigma
+% \qitobjParseDone%
+% }
+% \makeatother
+% \end{verbatim}
+%
+% The render macro should simply display the quantity, with the arguments given
+% as usual mandatory arguments. We invoke the |\phfqitParens| helper, which
+% produces the parenthesis at the correct size given the size spec tokens.
+% \begin{verbatim}
+% \newcommand\WorkCostTransitionRender[3]{% {size-spec-tokens}{\rho}{\sigma}
+% W\phfqitParens#1{#2 \to #3}%
+% \qitobjDone
+% }
+% \end{verbatim}
+%
+% Now declare the Qit Object:
+% \begin{verbatim}
+% \DefineQitObject{WorkCostTransition}{\WorkCostTransitionParse}{\WorkCostTransitionRender}
+% \end{verbatim}
+% \begingroup\makeatletter
+% \newcommand\WorkCostTransitionParse{\relax
+% \phfqit@parsesizearg\WorkCostTransitionParse@}
+% \newcommand\WorkCostTransitionParse@[2]{\relax
+% \qitobjAddArgx\phfqit@val@sizearg\relax
+% \qitobjAddArg{#1}\relax
+% \qitobjAddArg{#2}\relax
+% \qitobjParseDone}
+% \newcommand\WorkCostTransitionRender[3]{W\phfqitParens#1{#2 \to #3}\qitobjDone}
+% \DefineQitObject{WorkCostTransition}{\WorkCostTransitionParse}{\WorkCostTransitionRender}
+% Then: |\WorkCostTransition`\Big{\rho}{\sigma}| $\to$
+% \fbox{$\WorkCostTransition`\Big{\rho}{\sigma}$}
+% \endgroup
+%
+% You might want to check out the implementations of |\HbaseParse| and
+% |\HbaseRender|, or |\DbaseParse| and |\DbaseRender| if you'd like to see some
+% more involved examples.
%
%
%
@@ -513,7 +851,20 @@
\RequirePackage{mathrsfs}
\RequirePackage{mathtools}
% \end{macrocode}
+%
+% Package \pkgname{xparse} is needed in order to get paren matching right for
+% |\Hfn|.
+% \begin{macrocode}
+\RequirePackage{xparse}
+% \end{macrocode}
%
+% Package options are handled via \pkgname{xkeyval} \& \pkgname{kvoptions} (see
+% implementation doc for \pkgname{phfnote}).
+% \begin{macrocode}
+\RequirePackage{xkeyval}
+\RequirePackage{kvoptions}
+% \end{macrocode}
+%
% \subsection{Simple Symbols and Shorthands}
%
%
@@ -538,6 +889,8 @@
%
% \begin{macro}{\IdentProc}
% Identity process.
+%
+% TODO: this could be implemented as a Qit Object.
% \begin{macrocode}
\def\IdentProc{%
\phfqit@parsesizearg\phfqit@IdentProc@maybeA%
@@ -566,7 +919,7 @@
}
\def\phfqit@IdentProc@do#1#2#3{%
\operatorname{id}_{#1\notblank{#2}{\to #2}{}}%
- \notblank{#3}{\expandafter\phfqit@inner@parens\phfqit@val@sizearg{#3}}{}%
+ \notblank{#3}{\expandafter\phfqitParens\phfqit@val@sizearg{#3}}{}%
}
% \end{macrocode}
% \end{macro}
@@ -610,20 +963,20 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\Re}
-% \begin{macro}{\Im}
-% Also, alter the appearance of |\Re| and |\Im| to something more readable.
+% \begin{macro}{\phfqit@Realpart}
+% \begin{macro}{\phfqit@Imagpart}
+% Provide math operators for $\Re$ and $\Im$. The aliasing to the actual
+% commands |\Re| and |\Im| is done later, when we process the package options.
% \begin{macrocode}
\let\phfqit@Re\Re
\DeclareMathOperator{\phfqit@Realpart}{Re}%
-\renewcommand{\Re}{\phfqit@Realpart}
\let\phfqit@Im\Im
\DeclareMathOperator{\phfqit@Imagpart}{Im}%
-\renewcommand{\Im}{\phfqit@Imagpart}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
+%
% \subsubsection{Poly}
%
% \begin{macro}{\poly}
@@ -858,7 +1211,10 @@
%
%
%
-% \subsection{Entropy Measures}
+% \subsection{Entropy Measures and Other Qit Objects}
+%
+% \changed[v2.0-qit-objects]{v2.0}{2017/06/17}{Introduced the Qit Objects infrastructure}
+%
%
% \subsubsection{Some Internal Utilities}
%
@@ -877,409 +1233,763 @@
\begingroup%
\mathcode`\`="0060\relax%
\gdef\phfqit@val@sizearg{}%
- \@ifnextchar`{\phfqit@parsesizearg@withsize{#1}}{\endgroup#1}%
+ \def\phfqit@tmp@contwithsize{\phfqit@parsesizearg@withsize{#1}}%
+ \@ifnextchar`{\phfqit@tmp@contwithsize}{\endgroup#1}%
}
\def\phfqit@parsesizearg@withsize#1`#2{%
- \def\@tmp@arg{#2}%
- \def\@tmp@star{*}%
- \def\@tmp@endgroupandcontinue{\endgroup#1}%
- \ifx\@tmp@arg\@tmp@star\relax%
+ \def\phfqit@tmp@x{#2}%
+ \def\phfqit@tmp@star{*}%
+ \ifx\phfqit@tmp@x\phfqit@tmp@star%
\gdef\phfqit@val@sizearg{*}%
- \expandafter\@tmp@endgroupandcontinue%
+ \def\phfqit@tmp@cont{\endgroup#1}%
+ \expandafter\phfqit@tmp@cont%
\else%
\gdef\phfqit@val@sizearg{[#2]}%
- \expandafter\@tmp@endgroupandcontinue%
+ \def\phfqit@tmp@cont{\endgroup#1}%
+ \expandafter\phfqit@tmp@cont%
\fi%
}
% \end{macrocode}
% \end{macro}
-%
%
-% \begin{macro}{\phfqit@inner@parens}
+% \begin{macro}{\phfqitParens}
% Simple parenthesis-delimited expression, with
% |\DeclarePairedDelimiter|-compatible syntax. For example,
-% \par |\phfqit@inner@parens|\marg{content} \quad$\to$\quad
+% \par |\phfqitParens|\marg{content} \quad$\to$\quad
% \fbox{\phfverb( \meta{content} \phfverb)}
-% \par |\phfqit@inner@parens*|\marg{content} \quad$\to$\quad
+% \par |\phfqitParens*|\marg{content} \quad$\to$\quad
% \fbox{\phfverb\left\phfverb( \meta{content} \phfverb\right\phfverb)}
-% \par |\phfqit@inner@parens[\big]|\marg{content} \quad$\to$\quad
+% \par |\phfqitParens[\big]|\marg{content} \quad$\to$\quad
% \fbox{\phfverb\bigl\phfverb( \meta{content} \phfverb\bigr\phfverb)}
%
% \begin{macrocode}
-\DeclarePairedDelimiterX\phfqit@inner@parens[1]{(}{)}{#1}
+\DeclarePairedDelimiterX\phfqitParens[1]{(}{)}{#1}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\phfqitSquareBrackets}
+% Simple bracket-delimited expression, with
+% |\DeclarePairedDelimiter|-compatible syntax. For example,
+% \par |\phfqitSquareBrackets|\marg{content} \quad$\to$\quad
+% \fbox{\phfverb[ \meta{content} \phfverb]}
+% \par |\phfqitSquareBrackets*|\marg{content} \quad$\to$\quad
+% \fbox{\phfverb\left\phfverb[ \meta{content} \phfverb\right\phfverb]}
+% \par |\phfqitSquareBrackets[\big]|\marg{content} \quad$\to$\quad
+% \fbox{\phfverb\bigl\phfverb[ \meta{content} \phfverb\bigr\phfverb]}
+%
+% \begin{macrocode}
+\DeclarePairedDelimiterX\phfqitSquareBrackets[1]{[}{]}{#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\phfqitCurlyBrackets}
+% Simple bracket-delimited expression, with
+% |\DeclarePairedDelimiter|-compatible syntax. For example,
+% \par |\phfqitSquareBrackets|\marg{content} \quad$\to$\quad
+% \fbox{\phfverb\{ \meta{content} \phfverb\}}
+% \par |\phfqitSquareBrackets*|\marg{content} \quad$\to$\quad
+% \fbox{\phfverb\left\phfverb\{ \meta{content} \phfverb\right\phfverb\}}
+% \par |\phfqitSquareBrackets[\big]|\marg{content} \quad$\to$\quad
+% \fbox{\phfverb\bigl\phfverb\{ \meta{content} \phfverb\bigr\phfverb\}}
+%
+% \begin{macrocode}
+\DeclarePairedDelimiterX\phfqitCurlyBrackets[1]{\{}{\}}{#1}
+% \end{macrocode}
+% \end{macro}
%
%
-% \subsubsection{Entropy, Conditional Entropy, and Entropy Function}
%
-% See user documentation in \autoref{sec:entropy-measures}.
+% \subsubsection{Machinery for Qit Objects}
%
-% \begin{macro}{\HHSym}
-% The symbol used to designate an entropy measure (not relative).
+% See also user documentation in \autoref{sec:QitObjectImpl}.
+%
+% \begin{macro}{\QitObject}
+% The argument is the entropic quantity type or object kind (or ``entropic
+% quantity driver''): one of |Hbase|, |Hfnbase|, |Dbase|, |DCbase|, or any
+% other custom object.
% \begin{macrocode}
-\newcommand\HHSym{H}
+\newcommand\QitObject[1]{%
+ \begingroup%
+ \preto\QitObjectDone{\endgroup}%
+ \QitObjectInit%
+ \csname QitObj@reg@#1@initdefs\endcsname%
+%%\message{DEBUG: \detokenize{\QitObject{#1}}}%
+ \def\QitObj@args{}%
+ \def\qitobjParseDone{\QitObj@proceedToRender{#1}}%
+ \def\qitobjDone{\QitObjectDone}%
+ \csname QitObj@reg@#1@parse\endcsname%
+}
% \end{macrocode}
% \end{macro}
%
%
-% \begingroup\makeatletter
-% \begin{macro}{\@HHbase}
-% Base macro for entropy macros.
+% \begin{macro}{\DefineQitObject}
+% \begin{macro}{\DefineTunedQitObject}
+% Define a new Qit Object implementation with this macro. A Qit Object
+% implementation is specified in its simplest form by a \emph{name}, a
+% \emph{Parser} and a \emph{Renderer} (a single \LaTeX{} macro each). The
+% more advanced |\DefineTunedQitObject| allows you in addition to specify
+% local definitions to override defaults, as well as some initial arguments to
+% the parser.
+% \begin{macrocode}
+\def\DefineQitObject#1#2#3{%
+ \DefineTunedQitObject{#1}{#2}{#3}{}{}%
+}%
+\def\DefineTunedQitObject#1#2#3#4#5{%
+ \csdef{#1}{\QitObject{#1}#4}%
+ \expandafter\robustify\csname #1\endcsname%
+ \cslet{QitObj@reg@#1@parse}#2%
+ \cslet{QitObj@reg@#1@render}#3%
+ \csdef{QitObj@reg@#1@initdefs}{#5}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% Here are some callbacks meant for Qit Object implementations
+% (``types''/``drivers'').
+%
+% \begin{macro}{\qitobjAddArg}
+% \begin{macro}{\qitobjAddArgx}
+% These macros should only be called from within a \emph{Parse} macro of a qit
+% object type. Append an argument in preparation for an eventual call to the
+% corresponding \emph{Render} macro. |\qitobjAddArg| does not expand its
+% contents. |\qitobjAddArgx| expects a single command name as argument; it
+% expands the command once and stores those tokens as a single new argument.
+% \begin{macrocode}
+\def\qitobjAddArg#1{%
+ \appto\QitObj@args{{#1}}%
+}
+\def\qitobjAddArgx#1{%
+ \expandafter\qitobjAddArg\expandafter{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\qitobjParseDone}
+% \begin{macro}{\qitobjDone}
+% These macros MUST be called at the end of the respective \emph{Parse}
+% (|\qitobjParseDone|) and \emph{Render} (|\qitobjDone|) implementations
+% (otherwise processing doesn't proceed, \LaTeX{} groups won't be closed, and
+% it will be a mess).
+%
+% These macros are correctly defined in |\QitObject| actually. Here we provide
+% empty definitions so that the \emph{Render} and \emph{Parse} user
+% implementation macros can be called stand-alone, too.
+% \begin{macrocode}
+\def\qitobjParseDone{}
+\def\qitobjDone{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\QitObjectDone}
+% A hook which gets called after a Qit Object is displayed. This should
+% really stay empty on the global scope. However you can locally append or
+% prepend to it in tuned definitions for |\DeclareTunedQitObject| to perform
+% additional actions at the end of the Qit Object, for instance to close an
+% additional \LaTeX{} group.
+% \begin{macrocode}
+\def\QitObjectDone{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\QitObjectInit}
+% A hook which gets called before the parsing phase of a Qit Object. This
+% should really stay empty on the global scope. However you can locally
+% append or prepend to it in tuned definitions for |\DeclareTunedQitObject| to
+% perform additional actions before parsing the Qit Object (but which have to
+% be made within the \LaTeX{} group of the Qit Object). You can use this to
+% prepend code to |\QitObjectDone| so that you code gets called \emph{before}
+% the inner \LaTeX{} group is closed.
+% \begin{macrocode}
+\def\QitObjectInit{}
+% \end{macrocode}
+% \end{macro}
+%
+% An internal helper; it's useful to keep it separate for readability and for
+% debugging.
+% \begin{macrocode}
+\def\QitObj@proceedToRender#1{%
+%%\message{DEBUG: Rendering #1|\detokenize\expandafter{\QitObj@args}|}%
+ \expandafter\def\expandafter\x\expandafter{%
+ \csname QitObj@reg@#1@render\endcsname}%
+ \expandafter\x\QitObj@args%
+}
+% \end{macrocode}
+%
+%
+% \subsubsection{Qit Object Implementation: Entropy, Conditional Entropy}
+%
+% See also the user doc in \autoref{sec:entropy-measures}.
+%
+% \begin{macro}{\HbaseParse}
+% Base parser macro for usual entropy measures; possibly conditional and/or
+% smooth.
%
% USAGE:
-% |\@HHbase|\marg{H-symbol}\hspace{0pt}\marg{subscript}\hspace{0pt}\relax
-% \marg{superscript}\hspace{0pt}\meta{size-spec}\hspace{0pt}\oarg{state}\hspace{0pt}\relax
-% \oarg{epsilon}\hspace{0pt}\marg{target system}\hspace{0pt}\oarg{conditioning system}
+% |\Hbase|\marg{H-symbol}\hspace{0pt}\relax
+% \marg{subscript}\hspace{0pt}\relax
+% \meta{size-spec}\hspace{0pt}\oarg{state}\relax
+% \hspace{0pt}\oarg{epsilon}\hspace{0pt}\marg{target system}\hspace{0pt}\relax
+% \oarg{conditioning system}
%
% The argument \meta{size-spec} is optional, and is documented in
% \autoref{topic:size-specification-backtick}. For example \meta{size-spec} =
% |`*| or |`\Big|.
%
-% This command is robust.
-%
% Examples:
-% \par |\@HHbase{\hat{H}}{\mathrm{max}}[\rho][\epsilon]{E}[X']|
-% \quad$\to$\quad
-% \fbox{$\@HHbase{\hat{H}}{\mathrm{max}}[\rho][\epsilon]{E}[X']$}
-% \par |\@HHbase{\hat{H}}{\mathrm{max}}`*[\rho][\epsilon]{\bigotimes_i E}[X']|
+% \par |\Hbase{\hat{H}}{\mathrm{max}}[\rho][\epsilon]{E}[X']|
% \quad$\to$\quad
-% \fbox{$\@HHbase{\hat{H}}{\mathrm{max}}`*[\rho][\epsilon]{\displaystyle\bigotimes_i E}[X']$}
-% \par |\@HHbase{\hat{H}}{\mathrm{max}}`\big[\rho][\epsilon]{E}[X']|
+% \fbox{$\Hbase{\hat{H}}{\mathrm{max}}[\rho][\epsilon]{E}[X']$}
+% \par |\Hbase{\hat{H}}{\mathrm{max}}`*[\rho][\epsilon]{\bigotimes_i E}[X']|
% \quad$\to$\quad
-% \fbox{$\@HHbase{\hat{H}}{\mathrm{max}}`\big[\rho][\epsilon]{E}[X']$}
+% \fbox{$\Hbase{\hat{H}}{\mathrm{max}}`*[\rho][\epsilon]{\displaystyle\bigotimes_i E}[X']$}
+%
+% The |\HbaseParse| macro is responsible for parsing the arguments to
+% |\Hbase|. We should parse the arguments using helper macros as needed,
+% adding rendering arguments with |\qitobjAddArg| or |\qitobjAddArgx|, and
+% then calling |\qitobjParseDone|. The arguments are then automatically
+% provided as arguments to the |\HbaseRender| function. We just have to make
+% sure we add the correct number of arguments in the correct order.
%
% \begin{macrocode}
-\def\@HHbase#1#2{%
- #1_{#2}%
- \@HHbase@parsesize%
-}
-\robustify\@HHbase
+\def\HbaseParse#1#2{%
% \end{macrocode}
-%
%
-% TODO: use our generic size parser, don't duplicate code.... this is
-% historical and I don't dare change it without thorough testing:
+% The first arguments are the mandatory arguments
+% \marg{H-symbol}\hspace{0pt}\marg{subscript}. Then defer to helper macros for
+% the rest of the parsing.
% \begin{macrocode}
-\def\@HHbase@parsesize{%
- \begingroup\mathcode`\`="0060\relax%
- \gdef\HH@tmp@sizearg{}%
- \@ifnextchar`\@HHbase@withsize\@HHbase@endgroupandparseinner%
-}
-\def\@HHbase@withsize`#1{%
- \def\@tmp@arg{#1}%
- \def\@tmp@star{*}%
- \ifx\@tmp@arg\@tmp@star\relax%
- \gdef\HH@tmp@sizearg{*}%
- \expandafter\@HHbase@endgroupandparseinner%
- \else%
- \gdef\HH@tmp@sizearg{[#1]}%
- \expandafter\@HHbase@endgroupandparseinner%
- \fi%
-}
-\def\@HHbase@endgroupandparseinner{\endgroup\@HHbase@parseinner}
-\newcommand\@HHbase@parseinner[1][]{% arg: state
- \def\HH@tmpstore@state{#1}%
- \@HHbase@parseinner@%
-}
-\newcommand\@HHbase@parseinner@[2][]{% arg: epsilon and target system
- \def\HH@tmpstore@epsilon{#1}%
- \def\HH@tmpstore@system{#2}%
- \@HHbase@parseinner@@%
+ \qitobjAddArg{#1}%
+ \qitobjAddArg{#2}%
+ \phfqit@parsesizearg\HbaseParse@%
}
-\newcommand\@HHbase@parseinner@@[1][]{% arg: conditioning system
- \def\HH@tmpstore@condsys{#1}%
- \@HHbase@do@inner%
-}
-\newtoks\HH@tmp@toks
-\def\HH@addtoks#1\@HH@END@ADD@TOKS{\HH@tmp@toks=\expandafter{\the\HH@tmp@toks#1}}%
-% \end{macrocode}
-% \end{macro}
-% \begin{macro}{\@HHbase@do@inner}
-% Format the entropy measure. All information is stored in macros of the form
-% |\HH@tmpstore@<FIELD>|. The base string (entropy symbol and subscript) have
-% already been typeset.
-% \begin{macrocode}
-\def\@HHbase@do@inner{%
% \end{macrocode}
-% Add the superscript:
+%
+% Store the delimiter size argument which |\phfqit@parsesizearg| has stored into
+% |\phfqit@val@sizearg|, then parse an optional \oarg{state} argument.
% \begin{macrocode}
- ^{\HH@tmpstore@epsilon}%
+\newcommand\HbaseParse@[1][]{%
+ \qitobjAddArgx{\phfqit@val@sizearg}%
+ \qitobjAddArg{#1}%
+ \HbaseParse@@%
+}
% \end{macrocode}
-% If system is blank, we just want the symbol itself with no
-% argument. (|\notblank| is from the \pkgname{etoolbox} package.) Otherwise, add the
-% rest:
+% Then parse an optional \oarg{epsilon} argument, as well as a mandatory
+% \marg{target system} argument.
% \begin{macrocode}
- \expandafter\notblank\expandafter{\HH@tmpstore@system}{%
+\newcommand\HbaseParse@@[2][]{%
+ \qitobjAddArg{#1}%
+ \qitobjAddArg{#2}%
+ \HbaseParse@@@%
+}
% \end{macrocode}
-% Construct the parenthetic argument to the entropy, which we will store in the
-% token register |\HH@tmp@toks|:
+% Finally, parse an optional \oarg{conditioning system}.
% \begin{macrocode}
- \HH@tmp@toks={}%
+\newcommand\HbaseParse@@@[1][]{%
+ \qitobjAddArg{#1}%
+ \qitobjParseDone%
+}
% \end{macrocode}
-% \ldots{} add system name:
+% \end{macro}
+%
+%
+% \begin{macro}{\HbaseRender}
+% Render the entropy measure.
+% \par |#1| = ``$H$'' symbol to use (e.g. |H|)
+% \par |#2| = subscript (type of entropy, e.g. |\marthrm{min},0|)
+% \par |#3| = possible size argument to expand in front of parens command (one
+% of \emph{(empty)}, |*|, or |[\big]| using a standard sizing command)
+% \par |#4| = the state (e.g. |\rho|), may be left empty
+% \par |#5| = epsilon argument (superscript to entropy measure), if any, or
+% leave argument empty
+% \par |#6| = system to measure entropy of
+% \par |#7| = conditioning system, if any, or else leave the argument empty
% \begin{macrocode}
- \expandafter\HH@addtoks\HH@tmpstore@system\@HH@END@ADD@TOKS%
+\def\HbaseRender#1#2#3#4#5#6#7{%
+%%\message{DEBUG: HbaseRender\detokenize{{#1}{#2}{#3}{#4}{#5}{#6}{#7}}}%
% \end{macrocode}
-% \ldots{} add conditional system, if specified:
+%
+% Start with the entropy symbol (`H'), the subscript, and the superscript:
% \begin{macrocode}
- \expandafter\notblank\expandafter{\HH@tmpstore@condsys}{%
- \HH@addtoks\mathclose{}\,\delimsize\vert\,\mathopen{}\@HH@END@ADD@TOKS%
- \expandafter\HH@addtoks\HH@tmpstore@condsys\@HH@END@ADD@TOKS%
- }{}%
+ \HbaseRenderSym{#1}_{\HbaseRenderSub{#2}}^{\HbaseRenderSup{#5}}
% \end{macrocode}
-% The tokens are ready now. Prepare the argument to the |\phfqit@inner@parens|
-% command, and go:
+% Render the contents of the entropy (parenthetic expression with system \&
+% conditioning system), only if the system or conditioning system or state are
+% not empty:
% \begin{macrocode}
- \edef\tmp@args{\expandonce{\HH@tmp@sizearg}{\the\HH@tmp@toks}}%
- \expandafter\phfqit@inner@parens\tmp@args%
+ \notblank{#4#6#7}{%
+ \HbaseRenderContents{#3}{#6}{#7}%
% \end{macrocode}
% Finally, add the state as subscript, if any:
% \begin{macrocode}
- _{\HH@tmpstore@state}%
- %
+ \HbaseRenderTail{#4}%
}{}%
- %
+% \end{macrocode}
+% We're done.
+% \begin{macrocode}
+ \qitobjDone%
}
% \end{macrocode}
% \end{macro}
-% \endgroup
-%
-%
-%
-% Now, we have the proper entropy commands.
%
-% \needspace{4\baselineskip}
-% \begin{macro}{\HH}
-% \begin{macro}{\Hzero}
-% \begin{macro}{\Hmin}
-% \begin{macro}{\Hmaxf}
-% The definition of individual entropy macros just delegates to |\@HHbase|
-% with the relevant subscript.
+% \needspace{5\baselineskip}
+% \begin{macro}{\HbaseRenderSym}
+% \begin{macro}{\HbaseRenderSub}
+% \begin{macro}{\HbaseRenderSup}
+% \begin{macro}{\HbaseRenderTail}
+% Macros to render different parts of the entropy measure. By default, don't
+% do anything special to them (but this might be locally overridden in a tuned
+% Qit Object, for instance).
% \begin{macrocode}
-\newcommand\HH{\@HHbase{\HHSym}{}}
-\newcommand\Hzero{\@HHbase{\HHSym}{\mathrm{max},0}}
-\newcommand\Hmin{\@HHbase{\HHSym}{\mathrm{min}}}
-\newcommand\Hmaxf{\@HHbase{\HHSym}{\mathrm{max}}}
+\def\HbaseRenderSym#1{#1}%
+\def\HbaseRenderSub#1{#1}%
+\def\HbaseRenderSup#1{#1}%
+\def\HbaseRenderTail#1{_{#1}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\Hfunc}
-% Entropy function. Usage: |\Hfunc(x)|, |\Hfunc`*(x)|, |\Hfunc`\big(x)|.
-%
-% TODO: Use our generic size-specification parser! Don't duplicate code!
+% \begin{macro}{\HbaseRenderContents}
+% For the main contents rendering macro, we need to do a little more work.
+% First, declare a token register in which we will prepare the contents of the
+% parenthetic expression.
% \begin{macrocode}
-\DeclareRobustCommand\Hfunc{%
- \begingroup\mathcode`\`="0060\relax%
- \gdef\Hfunc@tmp@sizearg{}%
- \@ifnextchar`\Hfunc@withsize\Hfunc@next%
-}
-\def\Hfunc@withsize`#1{%
- \def\@tmp@arg{#1}%
- \def\@tmp@star{*}%
- \ifx\@tmp@arg\@tmp@star\relax%
- \gdef\Hfunc@tmp@sizearg{*}%
- \endgroup%
- \expandafter\Hfunc@inner%
- \else%
- \gdef\Hfunc@tmp@sizearg{[#1]}%
- \endgroup%
- \expandafter\Hfunc@inner%
- \fi%
-}
-\def\Hfunc@next{\endgroup\Hfunc@inner}
-\def\Hfunc@inner(#1){%
- \HHSym% ({#1})%
- \expandafter\phfqit@inner@parens\Hfunc@tmp@sizearg{#1}%
+\newtoks\Hbase@tmp@toks
+\def\Hbase@addtoks#1\@Hbase@END@ADD@TOKS{%
+ \Hbase@tmp@toks=\expandafter{\the\Hbase@tmp@toks#1}}%
+% \end{macrocode}
+% Now we need to define the macro which formats the contents of the entropy.
+% The arguments are |#1| = possible sizing argument, |#2| = system name, |#3| =
+% conditioning system if any.
+% \begin{macrocode}
+\def\HbaseRenderContents#1#2#3{%
+% \end{macrocode}
+% We need to construct the parenthetic argument to the entropy, which we will
+% store in the token register |\Hbase@tmp@toks|. Start with system name:
+% \begin{macrocode}
+ \Hbase@tmp@toks={#2}%
+% \end{macrocode}
+% \ldots{} add conditional system, if specified:
+% \begin{macrocode}
+ \notblank{#3}{%
+ \Hbase@addtoks\mathclose{}\,\delimsize\vert\,\mathopen{}%
+ #3%
+ \@Hbase@END@ADD@TOKS%
+ }{}%
+% \end{macrocode}
+% The tokens are ready now. Prepare the argument to the command
+% |\HbaseRenderContentsInnerParens| (normally just |\phfqitParens|), and go:
+% \begin{macrocode}
+ \edef\tmp@args{\unexpanded{#1}{\the\Hbase@tmp@toks}}%
+ \expandafter\HbaseRenderContentsInnerParens\tmp@args%
}
% \end{macrocode}
% \end{macro}
-%
-%
-% \subsubsection{Relative Entropies}
-%
-% User documentation in \autoref{sec:relative-entropies}
%
-% \begin{macro}{\DDSym}
-% Symbol to use to denote a relative entropy.
+% \begin{macro}{\X}
+% Macro which expands to the parenthetic expression type macro we would like
+% to use. By default, this is |\phfqitParens|.
% \begin{macrocode}
-\newcommand\DDSym{D}
+\def\HbaseRenderContentsInnerParens{\phfqitParens}
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\@DDbase@inner}
-% Internal macro to format the inner contents of a relative entropy.
-% \begingroup\makeatletter
-% \par |\@DDbase@inner{\rho}{\Gamma}| \quad$\to$\quad \fbox{$\@DDbase@inner{\rho}{\Gamma}$}
-% \endgroup
%
-% You can also specify the optional size specifier compatible with the
-% |\DeclarePariedDelimiter| syntax: |\@DDbase@inner*{\rho}{\Gamma}| and
-% |\@DDbase@inner[\big]{\rho}{\Gamma}|, for example.
%
+% \begin{macro}{\Hbase}
+% Finally, we declare our base entropic quantity type:
% \begin{macrocode}
-\DeclarePairedDelimiterX\@DDbase@inner[2]{(}{)}{%
- #1\mathclose{}\,\delimsize\Vert\,\mathopen{}#2%
-}
+\DefineQitObject{Hbase}{\HbaseParse}{\HbaseRender}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@DDbase}
-% Base macro for relative entropy macros.
%
-% USAGE:
-% |\@DDbase|\marg{D-symbol}\hspace{0pt}\marg{subscript}\hspace{0pt}\relax
-% \marg{superscript}\meta{size-spec}\marg{state}\marg{relative to state}
-%
-% The \meta{size-spec} may be either a backtick-style specification, or a star
-% or an optional argument (``|[\big]|'').
+% \subsubsection{Qit Object Implementation: Entropy Function}
%
-% \begingroup\makeatletter
-% Examples:
-% \par|\@DDbase{DSYMBOL}{subscript}{superscript}{\rho}{\Gamma}| \quad$\to$\quad
-% $\@DDbase{DSYMBOL}{subscript}{superscript}{\rho}{\Gamma}$, and similarly\\
-% |\@DDbase{DSYMBOL}{subscript}{superscript}*{\rho}{\Gamma}|,
-% |\@DDbase{DSYMBOL}{subscript}{superscript}[\big]{\rho}{\Gamma}|,
-% |\@DDbase{D-symbol}{subscript}{superscript}`*{\rho}{\Gamma}|,
-% |\@DDbase{D-symbol}{subscript}{superscript}`\big{\rho}{\Gamma}|.
-% \endgroup
+% See also the user doc in \autoref{sec:entropy-function}.
%
-% This command is robust.
+% \begin{macro}{\Hfnbase}
+% Base implementation of an entropy function.
%
+% Usage: |\Hfnbase{H}{1}{2}(x)| $\to$ $\Hfnbase{H}{1}{2}(x)$,
+% |\Hfnbase{H}{1}{2}`*(x)| $\to$ $\Hfnbase{H}{1}{2}`*(x)$,
+% |\Hfnbase{H}{1}{2}`\big(x)| $\to$ $\Hfnbase{H}{1}{2}`\big(x)$.
+%
+% We can use the same renderer as |\Hbase|, we just need a different parser.
+% The parser first accepts the mandatory arguments
+% \marg{H-symbol}\hspace{0pt}\marg{subscript}\hspace{0pt}\marg{superscript}.
% \begin{macrocode}
-\def\@DDbase#1#2#3{%
- #1_{#2}^{#3}%
- \@DDbase@parsesize%
-}
-\robustify\@DDbase
-\def\@DDbase@parsesize{%
- \@ifnextchar`\@DDbase@withsize\@DDbase@inner%
+\def\HfnbaseParse#1#2#3{%
+ \qitobjAddArg{#1}% H-sym
+ \qitobjAddArg{#2}% sub
+ \phfqit@parsesizearg{\HfnbaseParse@{#3}}%
}
-\def\@DDbase@withsize`#1{%
- \def\@tmp@arg{#1}%
- \def\@tmp@star{*}%
- \ifx\@tmp@arg\@tmp@star\relax%
- \def\tmp@cmd{\@DDbase@inner*}%
- \expandafter\tmp@cmd%
- \else%
- \def\tmp@cmd{\@DDbase@inner[#1]}%
- \expandafter\tmp@cmd%
- \fi%
+% \end{macrocode}
+%
+% Continue to parse a the argument given in parentheses. The first mandatory
+% argument is simply the subscript passed on from the previous macro. It might
+% be tempting to do simply |\def\HfnbaseParse@#1(#2){...}|, but this does not
+% allow for recursive use of parenthesis within the entropy argument, for
+% instance |\Hfn(g(x)+h(y))|. Because of this, we use \pkgname{xparse}'s
+% |\NewDocumentCommand| which can handle this.
+% \begin{macrocode}
+\NewDocumentCommand{\HfnbaseParse@}{mr()}{%
+ \qitobjAddArgx{\phfqit@val@sizearg}% size-arg
+ \qitobjAddArg{}% state
+ \qitobjAddArg{#1}% epsilon
+ \qitobjAddArg{#2}% system--main arg
+ \qitobjAddArg{}% cond system
+%%\message{DEBUG: Hfnbase args are |\detokenize\expandafter{\QitObj@args}|}%
+ \qitobjParseDone%
}
+\DefineQitObject{Hfnbase}{\HfnbaseParse}{\HbaseRender}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\DD}
-% (Usual) quantum relative entropy. Actually this is more versatile, because
-% you can also specify subscript and superscript.
+%
+% \subsubsection{Qit Object Implementation: Relative Entropy}
+%
+% User documentation in \autoref{sec:relative-entropies}.
+%
+%
+% \begin{macro}{\DbaseParse}
+% Base macro for relative entropy macros.
+%
+% USAGE:
+% |\Dbase|\marg{D-symbol}\hspace{0pt}\relax
+% [|_|\meta{subscript}]\hspace{0pt}\relax
+% [|^|\meta{superscript}]\hspace{0pt}\relax
+% \meta{size-spec}\hspace{0pt}\marg{state}\hspace{0pt}\marg{relative to state}
+%
+% The subscript and superscripts are optional and don't have to be specified.
+% They may be specified in any order. Repetitions are allowed and
+% concatenates the arguments, e.g., |^{a}_{x}_{y}^{z}_{w}| is the same as
+% |_{xyw}^{az}|.
+%
+% The \meta{size-spec} is a backtick-style specification as always.
+%
% \begin{macrocode}
-\DeclareRobustCommand\DD{%
- \def\DD@tmp@sub{}%
- \def\DD@tmp@sup{}%
- \DD@%
+\def\DbaseParse#1{%
+ \qitobjAddArg{#1}% D-sym
+ \def\DbaseParse@val@sub{}%
+ \def\DbaseParse@val@sup{}%
+ \DbaseParse@%
}
-\def\DD@{%
- \@ifnextchar_\DD@parsesub\DD@@%
+\def\DbaseParse@{%
+ \@ifnextchar_{\DbaseParse@parsesub}{\DbaseParse@@}%
}
-\def\DD@@{%
- \@ifnextchar^\DD@parsesup\DD@@@%
+\def\DbaseParse@@{%
+ \@ifnextchar^{\DbaseParse@parsesup}{\DbaseParse@@@}%
}
-\def\DD@@@{% sub/super-scripts have been parsed, move on to rest of command
- \@DDbase{\DDSym}{\DD@tmp@sub}{\DD@tmp@sup}%
+\def\DbaseParse@parsesub_#1{%
+ \appto\DbaseParse@val@sub{#1}%
+ \DbaseParse@% return to maybe parsing other sub/superscripts
}
-\def\DD@parsesub_#1{%
- \def\DD@tmp@sub{#1}%
- \DD@% continue parsing maybe another sub or superscript
+\def\DbaseParse@parsesup^#1{%
+ \appto\DbaseParse@val@sup{#1}%
+ \DbaseParse@% return to maybe parsing other sub/superscripts
}
-\def\DD@parsesup^#1{%
- \def\DD@tmp@sup{#1}%
- \DD@% continue parsing maybe another sub or superscript
+\def\DbaseParse@@@{%
+ \qitobjAddArgx\DbaseParse@val@sub%
+ \qitobjAddArgx\DbaseParse@val@sup%
+ \phfqit@parsesizearg\DbaseParse@rest%
+}
+\def\DbaseParse@rest#1#2{%
+ \qitobjAddArgx\phfqit@val@sizearg%
+ \qitobjAddArg{#1}% rho
+ \qitobjAddArg{#2}% Gamma
+ \qitobjParseDone%
}
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\Dminz}
-% ``Old'' min-relative entropy, based on the R\'enyi-zero relative entropy.
+%
+%
+%
+%
+%
+% \begin{macro}{\DbaseRender}
+% Macro which formats a relative entropy of the form
+% $D_\mathrm{sub}^\mathrm{sup}(A\Vert B)$:
+% \par |\DbaseRender{D}{\mathrm{min}}{\epsilon}{[\big]}{\rho}{\Gamma}|
+% \quad$\to$\quad
+% \fbox{$\DbaseRender{D}{\mathrm{min}}{\epsilon}{[\big]}{\rho}{\Gamma}$}
+%
+% \begin{macrocode}
+\def\DbaseRender#1#2#3#4#5#6{%
+%%\message{DEBUG: DbaseRender\detokenize{{#1}{#2}{#3}{#4}{#5}{#6}}}%
+% \end{macrocode}
+%
+% Start with the entropy symbol (`H'), the subscript, and the superscript:
+% \begin{macrocode}
+ \DbaseRenderSym{#1}_{\DbaseRenderSub{#2}}^{\DbaseRenderSup{#3}}
+% \end{macrocode}
+% Render the contents of the entropy (parenthetic expression with the (one or)
+% two states), only if the arguments are non-empty:
+% \begin{macrocode}
+ \notblank{#5#6}{%
+ \DbaseRenderContents{#4}{#5}{#6}%
+ }{}%
+% \end{macrocode}
+% We're done.
% \begin{macrocode}
-\DeclareRobustCommand\Dminz[1][]{%
- \@DDbase{\DDSym}{\mathrm{min,0}}{#1}%
+ \qitobjDone%
}
% \end{macrocode}
% \end{macro}
+%
+% \needspace{5\baselineskip}
+% \begin{macro}{\DbaseRenderSym}
+% \begin{macro}{\DbaseRenderSub}
+% \begin{macro}{\DbaseRenderSup}
+% Macros to render different parts of the entropy measure. By default, don't
+% do anything special to them (but this might be locally overridden in a
+% tuned Qit Object).
+% \begin{macrocode}
+\def\DbaseRenderSym#1{#1}%
+\def\DbaseRenderSub#1{#1}%
+\def\DbaseRenderSup#1{#1}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\Dminf}
-% Min-relative entropy (``new'' version).
+% \begin{macro}{\DbaseRenderContents}
+% Now we need to define the macro which formats the contents of the entropy.
+% First, define a useful token register.
% \begin{macrocode}
-
+\newtoks\Dbase@tmp@toks
+\def\Dbase@addtoks#1\@Dbase@END@ADD@TOKS{%
+ \Dbase@tmp@toks=\expandafter{\the\Dbase@tmp@toks#1}}%
+% \end{macrocode}
%
-% \Dminf{\rho}{\sigma}
-% \Dminf[\epsilon]{\rho}{\sigma}
-% \Dminf<states-spec>
-% \Dminf[\epsilon]<states-spec>
+% The arguments are |#1| = possible sizing argument, |#2| = first state, |#3| =
+% second state (or operator), if any.
+% \begin{macrocode}
+\def\DbaseRenderContents#1#2#3{%
+% \end{macrocode}
+% We need to construct the parenthetic argument to the relative entropy, which
+% we will store in the token register |\Dbase@tmp@toks|. Start with system
+% name:
+% \begin{macrocode}
+ \Dbase@tmp@toks={#2}%
+% \end{macrocode}
+% \ldots{} add conditional system, if specified:
+% \begin{macrocode}
+ \notblank{#3}{%
+ \Dbase@addtoks\mathclose{}\,\delimsize\Vert\,\mathopen{}%
+ #3%
+ \@Dbase@END@ADD@TOKS%
+ }{}%
+% \end{macrocode}
+% The tokens are ready now. Prepare the argument to the command
+% |\DbaseRenderContentsInnerParens| (by default just |\phfqitParens|), and go:
+% \begin{macrocode}
+ \edef\tmp@args{\unexpanded{#1}{\the\Dbase@tmp@toks}}%
+ \expandafter\DbaseRenderContentsInnerParens\tmp@args%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DbaseRenderContentsInnerParens}
+% Macro which expands to the parenthetic expression type macro we would like
+% to use. By default, this is |\phfqitParens|.
+% \begin{macrocode}
+\def\DbaseRenderContentsInnerParens{\phfqitParens}
+% \end{macrocode}
+% \end{macro}
%
-% Where <states-spec> = <size-spec>{\rho}{\sigma}
+% \begin{macro}{\Dbase}
+% Finally, define the |\Dbase| macro by declaring a new qit object.
+% \begin{macrocode}
+\DefineQitObject{Dbase}{\DbaseParse}{\DbaseRender}
+% \end{macrocode}
+% \end{macro}
+%
%
-% Where optional <size-spec> = "`*" or "`\Big"
+% \subsubsection{Qit Object Type: Coherent Relative Entropy}
%
-\DeclareRobustCommand\Dminf[1][]{%
- \@DDbase{\DDSym}{\mathrm{min}}{#1}%
+% See also user documentation in \autoref{sec:coh-rel-entr}.
+%
+% \begin{macro}{\DCohbaseParse}
+% Base macros for coherent relative entropy-type quantities of the form
+% ${\bar D}_{X\to X'}^{\epsilon}(\rho_{X'R}\Vert\Gamma_X,\Gamma_{X'})$.
+%
+% USAGE:
+% |\DCohbase|\marg{D symbol}\hspace{0pt}\relax
+% \oarg{epsilon}\hspace{0pt}\relax
+% \marg{state or \texttt{\textup{*}}fully-decorated-state}\hspace{0pt}\relax
+% \marg{System In}\hspace{0pt}\relax
+% \marg{System Out}\hspace{0pt}\relax
+% \marg{Gamma In}\hspace{0pt}\relax
+% \marg{Gamma Out}
+%
+% \begin{macrocode}
+\def\DCohbaseParse#1{%
+ \qitobjAddArg{#1}% D-sym
+ \DCohbaseParse@%
+}
+\newcommand\DCohbaseParse@[1][]{%
+ \qitobjAddArg{#1}% epsilon
+ \phfqit@parsesizearg\DCohbaseParse@rest%
+}
+\def\DCohbaseParse@rest#1#2#3#4#5{%
+ % rho, X, X', \Gamma_X, \Gamma_{X'}
+ \qitobjAddArgx\phfqit@val@sizearg%
+ \DCohbaseParse@parserhosub#1\DCohbaseParse@ENDSTATE{#2}{#3}%
+ \qitobjAddArg{#2}%
+ \qitobjAddArg{#3}%
+ \qitobjAddArg{#4}%
+ \qitobjAddArg{#5}%
+ \qitobjParseDone%
+}
+\def\DCohbaseParse@parserhosub{%
+ \@ifnextchar*\DCohbaseParse@parserhosub@nosub%
+ \DCohbaseParse@parserhosub@wsub%
+}
+\def\DCohbaseParse@parserhosub@nosub*#1\DCohbaseParse@ENDSTATE#2#3{%
+ \qitobjAddArg{#1}% rho
+}
+\def\DCohbaseParse@parserhosub@wsub#1\DCohbaseParse@ENDSTATE#2#3{%
+ \qitobjAddArg{#1_{\begingroup\let\emptysystem\relax%
+ \DCohbaseStateSubscripts{#2}{#3}\endgroup}}% all this for "rho" arg
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Dmax}
-% Max-relative entropy.
+% \begin{macro}{\DCohbaseStateSubscripts}
+% Macro which produces the relevant subscript for the state. By default,
+% simply produce ``$X'R$'' (but don't produce an ``empty system''
+% symbol). This macro may be overridden e.g. locally.
% \begin{macrocode}
-\DeclareRobustCommand\Dmax[1][]{%
- \@DDbase{\DDSym}{\mathrm{max}}{#1}%
+\def\DCohbaseStateSubscripts#1#2{%
+ #2#1%
}
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\Dr}
-% Rob-relative entropy.
+%
+% \begin{macro}{\DCohbaseRender}
+% Render the coherent relative entropy.
+% \par |#1| = ``$D$'' symbol
+% \par |#2| = superscript (epsilon)
+% \par |#3| = possible size argument tokens (i.e., |[\big]|)
+% \par |#4| = fully decorated state (i.e., with necessary subscripts as required)
+% \par |#5| = input system name
+% \par |#6| = output system name
+% \par |#7| = Gamma-in
+% \par |#8| = Gamma-out
+% \begin{macrocode}
+\def\DCohbaseRender#1#2#3#4#5#6#7#8{%
+ %
+%%\message{DEBUG: DCohbaseRender here, args are |\detokenize{{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}|.}}
+ %
+ \DCohbaseRenderSym{#1}%
+ _{\DCohbaseRenderSystems{#5}{#6}}%
+ ^{\DCohbaseRenderSup{#2}}%
+ \notblank{#4#7#8}{%
+ \DCohbaseRenderContents{#3}{#4}{#7}{#8}%
+ }{}%
+% \end{macrocode}
+% We're done.
% \begin{macrocode}
-\DeclareRobustCommand\Dr[1][]{%
- \@DDbase{\DDSym}{\mathrm{r}}{#1}%
+ \qitobjDone%
}
% \end{macrocode}
% \end{macro}
%
-%
-% \begin{macro}{\DHyp}
-% Hypothesis testing relative entropy.
+% \needspace{5\baselineskip}
+% \begin{macro}{\DCohbaseRenderSym}
+% \begin{macro}{\DCohbaseRenderSystems}
+% \begin{macro}{\DCohbaseRenderSup}
+% Macros to render different parts of the entropy measure. By default, don't
+% do anything special to them (but this might be locally overridden in a
+% tuned Qit Object)
% \begin{macrocode}
-\DeclareRobustCommand\DHyp[1][\eta]{%
- \@DDbase{\DDSym}{\mathrm{H}}{#1}%
-}
+\def\DCohbaseRenderSym#1{#1}%
+\def\DCohbaseRenderSystems#1#2{#1\to #2}%
+\def\DCohbaseRenderSup#1{#1}%
% \end{macrocode}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
+% \begin{macro}{\DCohbaseRenderContents}
+% Now we define the macro which formats the contents of the entropy.
%
-% \subsubsection{Coherent Relative Entropy}
+% Define first a useful token register for rendering the contents.
+% \begin{macrocode}
+\newtoks\DCohbase@tmp@toks
+\def\DCohbase@addtoks#1\@DCohbase@END@ADD@TOKS{%
+ \DCohbase@tmp@toks=\expandafter{\the\DCohbase@tmp@toks#1}}%
+% \end{macrocode}
+%
+% The arguments are |#1| = possible sizing argument tokens, |#2| = decorated
+% state, |#3| = Gamma-X, |#4| = Gamma-{X'}.
+% \begin{macrocode}
+\def\DCohbaseRenderContents#1#2#3#4{%
+% \end{macrocode}
+% We need to construct the parenthetic argument to the coherent relative
+% entropy, which we will prepare in the token register |\DCohbase@tmp@toks|.
+% Start with the state:
+% \begin{macrocode}
+ \DCohbase@tmp@toks={#2}%
+% \end{macrocode}
+% \ldots{} add conditional system, if specified:
+% \begin{macrocode}
+ \notblank{#3#4}{%
+ \DCohbase@addtoks\mathclose{}\,\delimsize\Vert\,\mathopen{}%
+ #3\mathclose{},\mathopen{}#4\@DCohbase@END@ADD@TOKS%
+ }{}%
+% \end{macrocode}
+% The tokens are ready now. Prepare the argument to the command
+% |\DCohbaseRenderContentsInnerParens| (by default just |\phfqitParens|), and go:
+% \begin{macrocode}
+ \edef\tmp@args{\unexpanded{#1}{\the\DCohbase@tmp@toks}}%
+ \expandafter\DCohbaseRenderContentsInnerParens\tmp@args%
+}
+% \end{macrocode}
+% \end{macro}
%
-% See user documentation in \autoref{sec:coh-rel-entr}.
+% \begin{macro}{\DCohbaseRenderContentsInnerParens}
+% Macro which expands to the parenthetic expression type macro we would like
+% to use. By default, this is |\phfqitParens|.
+% \begin{macrocode}
+\def\DCohbaseRenderContentsInnerParens{\phfqitParens}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCohbase}
+% Finally, define the |\DCohbase| macro by declaring a new qit object.
+% \begin{macrocode}
+\DefineQitObject{DCohbase}{\DCohbaseParse}{\DCohbaseRender}
+% \end{macrocode}
+% \end{macro}
%
-% \begin{macro}{\DC@inner}
-% Format the contents of the coherent relative entropy. This is simply a
-% |\DeclarePariedDelimiter|-style command. The syntax is
-% |\DC@inner|\hspace{0pt}\marg{rho}\hspace{0pt}\marg{Gamma1}\hspace{0pt}\marg{Gamma2}, and
-% this typesets as $\bigl(\meta{rho}\big\Vert\meta{Gamma1},\meta{Gamma2}\bigr)$.
-% \begin{macrocode}
-\DeclarePairedDelimiterX\DC@inner[3]{(}{)}{%
- #1\mathclose{}\,\delimsize\Vert\,\mathopen{}#2\mathclose{},\mathopen{}#3%
-}
+%
+% \subsection{Additional helpers for entropy measures}
+%
+% \begin{macro}{\HSym}
+% Symbol to use to denote an entropy measure.
+% \begin{macrocode}
+\def\HSym{H}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DSym}
+% Symbol to use to denote a relative entropy measure.
+% \begin{macrocode}
+\newcommand\DSym{D}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DCSym}
-% Symbol to use for the coherent relative entropy
+% Symbol to use for the coherent relative entropy measure.
% \begin{macrocode}
-\newcommand\DCSym{\bar\DDSym}
+\newcommand\DCSym{\bar\DSym}
% \end{macrocode}
% \end{macro}
%
@@ -1291,71 +2001,185 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\DCohxRefSystemName}
+% \begin{macro}{\DCohxStateSubscripts}
+% Macros helpful for defining |\DCohx|.
+% \begin{macrocode}
+\def\DCohxRefSystemName#1{R_{#1}}
+\def\DCohxStateSubscripts#1#2{#2\DCohxRefSystemName{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\DCoh}
-% The Coherent Relative Entropy.
%
-% TODO: Use our generic size parser, don't duplicate code!
+% Finally, some macros provided for backwards compatibility:
+% \begin{macrocode}
+\let\@HHbase\Hbase
+\let\@DDbase\Dbase
+\let\HHSym\HSym
+\let\DDSym\DSym
+% \end{macrocode}
+%
+%
+% \subsection{Handle package options}
+%
+% \changedreftext{v2.0-pkg-opt-qitobjdef}
+% \changedreftext{v2.0-pkg-opt-newReIm}
%
-% First part: read the first few arguments (epsilon superscript, optional size
-% specification).
+% Initialization code for \pkgname{kvoptions} for our package options. See
+% \autoref{sec:pkg-options}.
% \begin{macrocode}
-\newcommand\DCoh[1][]{%
- \def\DC@tmp@sup{#1}%
- %\message{*********|\detokenize{#1}|*********}%
- \begingroup\mathcode`\`="0060\relax
- \DC@parsesize%
-}
-\def\DC@parsesize#1{%
- \gdef\DC@tmp@sizeargs{}%
- \ifstrequal{#1}{`}\DC@withsize{\endgroup\DC@rest{#1}}%
-}
-\def\DC@withsize#1{%
- %\message{*********\detokenize{#1}********}%
- \def\@tmp@arg{#1}%
- \def\@tmp@star{*}%
- \ifx\@tmp@arg\@tmp@star\relax%
- \gdef\DC@tmp@sizeargs{*}%
- \endgroup%
- \expandafter\DC@rest%
- \else%
- \gdef\DC@tmp@sizeargs{[#1]}%
- \endgroup%
- \expandafter\DC@rest%
- \fi%
+\SetupKeyvalOptions{
+ family=phfqit,
+ prefix=phfqit@opt@
}
% \end{macrocode}
%
-% Read the rest and typeset the output. |#1|=rho, |#2|=system-in,
-% |#3|=system-out, |#4|=Gamma-in, |#5|=Gamma-out:
-% \begin{macrocode}
-\def\DC@rest#1#2#3#4#5{%
- %\message{*********\detokenize{#1}|\detokenize{#2}|\detokenize{#3}%
- % |\detokenize{#4}|\detokenize{#5}|********}%
- \def\DC@tmp@rho{\DC@fmtrhosub#1\DC@ENDSTATE{#2}{#3}}%
- \DCSym_{#2\to #3}^{\DC@tmp@sup}%
- \expandafter\DC@inner\DC@tmp@sizeargs{\DC@tmp@rho}{#4}{#5}%
-}
+% Set of predefined qit objects to load. Either |stdset| (standard set, the
+% default) or |none| (none).
+% \begin{macrocode}
+\DeclareStringOption[stdset]{qitobjdef}
% \end{macrocode}
+%
+% Whether to override \LaTeX{}'s default {\makeatletter $\phfqit@Re$ and
+% $\phfqit@Im$} symbols by our more readable $\Re$ and $\Im$.
+% \begin{macrocode}
+\DeclareBoolOption[true]{newReIm}
+% \end{macrocode}
+%
%
-% Read the following tokens until the marker |\DC@ENDSTATE|, and format this as
-% a state with or without the automatic system subscripts (depending on if the
-% argument starts with a `|*|').
+% Process package options.
% \begin{macrocode}
-\def\DC@fmtrhosub{%
- \@ifnextchar*\DC@fmtrhosub@nosub\DC@fmtrhosub@wsub%
-}
-\def\DC@fmtrhosub@nosub*#1\DC@ENDSTATE#2#3{%
- #1%
-}
-\def\DC@fmtrhosub@wsub#1\DC@ENDSTATE#2#3{%
- \begingroup%
- \let\emptysystem\relax%
- #1_{#3#2}%
- \endgroup%
+\ProcessKeyvalOptions*
+% \end{macrocode}
+%
+%
+% \subsubsection{Re/Im symbols}
+%
+% \begin{macro}{\Re}
+% \begin{macro}{\Im}
+% Provide |\Re| and |\Im| commands to override \LaTeX{}'s default if the
+% corresponding package option is set (which is the default).
+% \begin{macrocode}
+\ifphfqit@opt@newReIm
+ \renewcommand{\Re}{\phfqit@Realpart}
+ \renewcommand{\Im}{\phfqit@Imagpart}
+\fi
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Standard entropy measures}
+%
+% Load the requested set of qit objects.
+% \begin{macrocode}
+\def\phfqit@tmp@str@none{none}
+\def\phfqit@tmp@str@stdset{stdset}
+\ifx\phfqit@opt@qitobjdef\phfqit@tmp@str@none%
+% \end{macrocode}
+% In this case, do not load any definitions.
+% \begin{macrocode}
+\else\ifx\phfqit@opt@qitobjdef\phfqit@tmp@str@stdset%
+% \end{macrocode}
+% In this case, provide our standard set of ``qit objects'' (i.e., entropy
+% measures).
+%
+% \needspace{4\baselineskip}
+% \begin{macro}{\HH}
+% \begin{macro}{\Hzero}
+% \begin{macro}{\Hmin}
+% \begin{macro}{\Hmaxf}
+% The definition of individual entropy macros just delegates to |\Hbase|
+% with the relevant subscript.
+% \begin{macrocode}
+\def\HH{\Hbase{\HSym}{}}
+\def\Hzero{\Hbase{\HSym}{\mathrm{max},0}}
+\def\Hmin{\Hbase{\HSym}{\mathrm{min}}}
+\def\Hmaxf{\Hbase{\HSym}{\mathrm{max}}}
+\def\Hfn{\Hfnbase{\HSym}{}{}}
+\let\Hfunc\Hfn% backwards compatibility
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\DD}
+% (Usual) quantum relative entropy. (Actually this is more versatile, because
+% you can also specify subscript and superscript, so you can make on-the-fly
+% custom relative entropy measures.)
+% \begin{macrocode}
+\def\DD{\Dbase{\DSym}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Dminz}
+% ``Old'' min-relative entropy, based on the R\'enyi-zero relative entropy.
+% \begin{macrocode}
+\newcommand\Dminz[1][]{\Dbase{\DSym}_{\mathrm{min,0}}^{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Dminf}
+% Min-relative entropy (``new'' version).
+% \begin{macrocode}
+\newcommand\Dminf[1][]{\Dbase{\DSym}_{\mathrm{min}}^{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Dmax}
+% Max-relative entropy.
+% \begin{macrocode}
+\newcommand\Dmax[1][]{\Dbase{\DSym}_{\mathrm{max}}^{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Dr}
+% Rob-relative entropy.
+% \begin{macrocode}
+\newcommand\Dr[1][]{\Dbase{\DSym}_{\mathrm{r}}^{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\DHyp}
+% Hypothesis testing relative entropy.
+% \begin{macrocode}
+\newcommand\DHyp[1][\eta]{\Dbase{\DSym}_{\mathrm{H}}^{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCoh}
+% Coherent relative entropy (old style).
+% \begin{macrocode}
+\DefineTunedQitObject{DCoh}{\DCohbaseParse}{\DCohbaseRender}{{\DCSym}}{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCohx}
+% Coherent relative entropy (new style).
+% \begin{macrocode}
+\DefineTunedQitObject{DCohx}{\DCohbaseParse}{\DCohbaseRender}%
+{{\DCSym}}{%
+ \let\DCohbaseStateSubscripts\DCohxStateSubscripts%
}
% \end{macrocode}
% \end{macro}
%
+%
+% End case |qitobjdef=stdset|. Last case is the final |\else| branch which is an
+% error, as we have an unknown set of standard definitions to load.
+% \begin{macrocode}
+\else
+\PackageError{phfqit}{Invalid value `\phfqit@opt@qitobjdef' specified for
+ package option `qitobjdef'. Please specify one of `stdset' (the default) or
+ `none'}{You specified an invalid value to the `qitobjdef' package option of
+ the `phfqit' package.}
+\fi
+\fi
+% \end{macrocode}
+%
+%
% \Finale
\endinput
diff --git a/Master/texmf-dist/source/latex/phfqit/phfqit.ins b/Master/texmf-dist/source/latex/phfqit/phfqit.ins
index 2c7d087a1e6..91861977c8e 100644
--- a/Master/texmf-dist/source/latex/phfqit/phfqit.ins
+++ b/Master/texmf-dist/source/latex/phfqit/phfqit.ins
@@ -1,5 +1,5 @@
%%
-%% Copyright (C) 2016 by Philippe Faist <philippe.faist@bluewin.ch>
+%% Copyright (C) 2016 by Philippe Faist, philippe.faist@bluewin.ch
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3 of this license
@@ -21,7 +21,7 @@
This is a generated file.
-Copyright (C) 2016 by Philippe Faist <philippe.faist@bluewin.ch>
+Copyright (C) 2016 by Philippe Faist, philippe.faist@bluewin.ch
This file may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3 of this license