| 1 |
% \iffalse |
| 2 |
% |
| 3 |
% permute.dtx and permute.ins and all files generated from these files are |
| 4 |
% referred to as `the permute package'. It is distributed under the terms |
| 5 |
% of the \LaTeX\ Project Public License from CTAN archives in directory |
| 6 |
% macros/latex/base/lppl.txt. Either version 1.0 or, at your option, any |
| 7 |
% later version. The use of the package is completely free. |
| 8 |
% |
| 9 |
% Permission is granted to modify the permute package. You are not allowed to |
| 10 |
% distribute any changed version of the package, neither under the same name |
| 11 |
% nor under a different one. |
| 12 |
% |
| 13 |
% Send comments, ideas and bug reports via electronic mail to |
| 14 |
% |
| 15 |
% [email protected] |
| 16 |
% |
| 17 |
% (w)(c) 1997--1999 by Carsten Heinz |
| 18 |
% |
| 19 |
%<*driver> |
| 20 |
\documentclass{ltxdoc} |
| 21 |
|
| 22 |
\usepackage{permute}[1999/11/10] |
| 23 |
|
| 24 |
\EnableCrossrefs |
| 25 |
\CodelineIndex |
| 26 |
\OnlyDescription |
| 27 |
|
| 28 |
\begin{document} |
| 29 |
\DocInput{permute.dtx} |
| 30 |
\end{document} |
| 31 |
%</driver> |
| 32 |
% \fi |
| 33 |
% |
| 34 |
% \newbox\abstractbox |
| 35 |
% \setbox\abstractbox=\vbox{ |
| 36 |
% \begin{abstract} |
| 37 |
% The \textsf{permute} package inputs, outputs and composes permutations. |
| 38 |
% For example, |$\pmt{(123)}\circ\pmt{(321)} = \pmt{(123)(321)}$| produces |
| 39 |
% $\pmt{(123)}\circ\pmt{(321)}=\pmt{(123)(321)}$. A misleading example is |
| 40 |
% $(a\ldots z)\circ(z\ldots a)=\pmt{(a\ldots z)(z\ldots a)}$ printed via |
| 41 |
% |$(a\ldots z)\circ(z\ldots a)=\pmt{(a\ldots z)(z\ldots a)}$| |
| 42 |
% --- misleading since the package doesn't care about the human |
| 43 |
% interpretation of ``\ldots''. |
| 44 |
% \end{abstract}} |
| 45 |
% |
| 46 |
% \title{The \textsf{Permute} Package} |
| 47 |
% \author{Copyright 1997--1999 by Carsten Heinz} |
| 48 |
% \date{Version 0.12\\ \box\abstractbox} |
| 49 |
% \maketitle |
| 50 |
% |
| 51 |
%^^A |
| 52 |
%^^A private adjustments |
| 53 |
%^^A |
| 54 |
% \makeatletter |
| 55 |
% \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}^^A |
| 56 |
% {1.25ex \@plus1ex \@minus.2ex}^^A |
| 57 |
% {-1em}^^A |
| 58 |
% {\normalfont\normalsize\bfseries}} |
| 59 |
% \makeatother |
| 60 |
% \newenvironment{syntax}{\list{}{\itemindent-\leftmargin}}{\endlist} |
| 61 |
% |
| 62 |
% |
| 63 |
% \section{User's guide} |
| 64 |
% |
| 65 |
% |
| 66 |
% \subsection{Software license} |
| 67 |
% |
| 68 |
% \texttt{permute.dtx} and \texttt{permute.ins} and all files generated from |
| 69 |
% these files are referred to as `the \textsf{permute} package'. |
| 70 |
% It is distributed under the terms of the \LaTeX\ Project Public License |
| 71 |
% from CTAN archives in directory \texttt{macros/latex/base/lppl.txt}. |
| 72 |
% Either version 1.0 or, at your option, any later version. |
| 73 |
% The use of the package is completely free. |
| 74 |
% |
| 75 |
% Permission is granted to modify the \textsf{permute} package. |
| 76 |
% You are not allowed to distribute any changed version of the package, |
| 77 |
% neither under the same name nor under a different one. |
| 78 |
% |
| 79 |
% Send comments, ideas and bug reports via electronic mail to |
| 80 |
% \texttt{[email protected]}. |
| 81 |
% |
| 82 |
% |
| 83 |
% \subsection{Installation} |
| 84 |
% |
| 85 |
% \begin{enumerate} |
| 86 |
% \item Following the \TeX\ directory structure (TDS) you should put the files |
| 87 |
% of the package into directories as follows: |
| 88 |
% \begin{center} |
| 89 |
% \begin{tabular}{l@{\quad$\to$\quad}l} |
| 90 |
% \texttt{permute.dvi} |
| 91 |
% & \texttt{texmf/doc/latex/permute}\\ |
| 92 |
% \texttt{permute.dtx}, \texttt{permute.ins} |
| 93 |
% & \texttt{texmf/source/latex/permute}\\ |
| 94 |
% \end{tabular} |
| 95 |
% \end{center} |
| 96 |
% Of course, you need not to use the TDS. |
| 97 |
% Simply adjust the directories below. |
| 98 |
% \item Create the directory \texttt{texmf/tex/latex/permute}. |
| 99 |
% \item Change the working directory to \texttt{texmf/source/latex/permute} |
| 100 |
% and run \texttt{permute.ins} through \TeX. |
| 101 |
% \item Move the generated file to \texttt{texmf/tex/latex/permute} if this |
| 102 |
% is not already done. |
| 103 |
% \item If your \TeX\ implementation uses a filename database, update it. |
| 104 |
% \end{enumerate} |
| 105 |
% |
| 106 |
% |
| 107 |
% \subsection{Input and output formats} |
| 108 |
% |
| 109 |
% \paragraph{General notation.} |
| 110 |
% First we restrict ourselves to $S_1,\ldots,S_9$: |
| 111 |
% $$S_n:=\{f:\{1,\ldots,n\}\to\{1,\ldots,n\}\,\vert\, |
| 112 |
% f\textrm{ is one-to-one and onto}\}.$$ |
| 113 |
% A permutation $f\in S_n$ can be written \textbf{verbose} as an explicit |
| 114 |
% sequence of pre-image/image pairs like this: |
| 115 |
% $$f=\pmtv[12\ldots n]{1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}}.$$ |
| 116 |
% A permutation $\sigma$ is a \textbf{cycle} and written |
| 117 |
% $\sigma=(x_1x_2\ldots x_k)$ |
| 118 |
% if and only if there are distinct numbers |
| 119 |
% $x_1,x_2,\ldots,x_k\in\{1,\ldots,n\}$ |
| 120 |
% satisfying |
| 121 |
% \begin{eqnarray*} |
| 122 |
% \sigma(x_i)&=&x_{i+1}\qquad\textrm{ for all }1\leq i<k\\ |
| 123 |
% \sigma(x_k)&=&x_1\\ |
| 124 |
% \sigma(x)&=&x\hphantom{\mbox{$_{i+1}$}}\qquad% |
| 125 |
% \textrm{ for all }x\in\{1,\ldots,n\}\setminus\{x_1,\ldots,x_k\}. |
| 126 |
% \end{eqnarray*} |
| 127 |
% This means that a cycle $(x_1x_2\ldots x_k)$ maps |
| 128 |
% $x_1$ to $x_2$, $x_2$ to $x_3$, \ldots, $x_k$ back to $x_1$, |
| 129 |
% and fixes all other elements. |
| 130 |
% Each permutation in $S_n$ can be written as a composition of cycles, for |
| 131 |
% example $\pmtv[12345]{12 21 35 43 54}=(12)\circ(354)=(12)(354)$---we leave |
| 132 |
% out the ``$\circ$''. |
| 133 |
% Note that $S_n$ is not commutative in general and that we compose from the |
| 134 |
% right to the left. |
| 135 |
% In the example 3 is mapped to 5 and then 5 stays 5 since unchanged by (12). |
| 136 |
% |
| 137 |
% \paragraph{Input formats.} |
| 138 |
% If you want to enter a permutation cycle based, just write the cycles after |
| 139 |
% each other. |
| 140 |
% |(12)(354)| would be legal; there must not be a |\circ| in between. |
| 141 |
% The verbose input format lists all pre-image/image pairs without any |
| 142 |
% separators, but a space is allowed in between. |
| 143 |
% The permutation above could also be entered as |12 21 35 43 54|. |
| 144 |
% The package distinguishes the two formats by looking at the first token: |
| 145 |
% If and only if it's a left parenthesis, the package accepts cycles. |
| 146 |
% |
| 147 |
% Now we drop the restriction $n\leq 9$ and the limitation of permuting |
| 148 |
% numbers; we can do it with nearly arbitrary (token) strings. |
| 149 |
% To enter a string as pre-image, image or inside a cycle, enclose |
| 150 |
% the string in braces. That's all! |
| 151 |
% For example, I typed |
| 152 |
% \begin{verbatim} |
| 153 |
% 1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}\end{verbatim} |
| 154 |
% for $\pmtv[12\ldots n]{1{f(1)} 2{f(2)}\ldots\ldots n{f(n)}}$, which actually |
| 155 |
% isn't a permutation at all. |
| 156 |
% |
| 157 |
% In the sequel \meta{pmt} means either a verbose sequence or a sequence of |
| 158 |
% cycles. |
| 159 |
% \emph{Do not use} |\empty| \emph{or} |\relax| \emph{or equivalent |
| 160 |
% definitions inside} \meta{pmt}. |
| 161 |
% |
| 162 |
% \paragraph{Output formats.} |
| 163 |
% The package provides a cycle based and two verbose output formats. |
| 164 |
% Some of the commands described below have an optional \meta{print order} |
| 165 |
% argument. |
| 166 |
% Now let \meta{print order} equal $n_1n_2\ldots n_k$ where each $n_i$ is a |
| 167 |
% single token or a braced string. |
| 168 |
% If $n_i$ and $n_{i+1}$ both appear in a permutation and appear in different |
| 169 |
% cycles, then the cycle containing $n_i$ is printed first. |
| 170 |
% Moreover the cycle starts with the element $n_i$. |
| 171 |
% Cycles not covered by \meta{print order} are printed as they appear in the |
| 172 |
% internal data format. |
| 173 |
% Some examples on printing (12)(34)(56): |
| 174 |
% \begin{center} |
| 175 |
% \begin{tabular}{ll@{\qquad\qquad}ll} |
| 176 |
% \meta{print order} & results in & \meta{print order} & results in\\ |
| 177 |
% no order & \pmt{(12)(34)(56)} & empty & \pmt[]{(12)(34)(56)}\\ |
| 178 |
% |2| & \pmt[2]{(12)(34)(56)} & |23| & \pmt[23]{(12)(34)(56)}\\ |
| 179 |
% |6| & \pmt[6]{(12)(34)(56)}\\ |
| 180 |
% \end{tabular} |
| 181 |
% \end{center} |
| 182 |
% All results represent the same permutation. |
| 183 |
% Note the difference between `no order' and `empty': |
| 184 |
% The package uses a standard order if you don't request a special one. |
| 185 |
% |
| 186 |
% There is some danger if you want to use a \emph{single token string} as |
| 187 |
% \meta{print order}. In this case you must enclose the string in |
| 188 |
% \emph{two level} of braces. Use \meta{print order}$=$|{{one}}| to control |
| 189 |
% |({one}{two})({two}{three})({three}{four})|, for example. Since \TeX\ |
| 190 |
% discards one group level, |{one}| would lead to the order |o|, |n|, |e|. |
| 191 |
% However, \meta{print order}$=$|{one}{two}| needs no extra braces. |
| 192 |
% |
| 193 |
% \medbreak |
| 194 |
% For the verbose output formats, \meta{print order} plays the role of domain. |
| 195 |
% The package uses exactly the elements and order, i.e.\ all pre-images not |
| 196 |
% appearing in \meta{print order} are not printed, and we assume image=pre-image |
| 197 |
% if pre-image appears in \meta{print order} but not in the permutation. |
| 198 |
% Some examples on printing |1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}|: |
| 199 |
% \begin{center} |
| 200 |
% \begin{tabular}{ll} |
| 201 |
% \meta{print order}&results in\\ |
| 202 |
% no order & \pmtv{1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}}\\ \noalign{\smallskip} |
| 203 |
% |n\ldots 21| & \pmtv[n\ldots21]{1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}}\\ \noalign{\smallskip} |
| 204 |
% |2\ldots n{n+1}|& \pmtv[2\ldots n{n+1}]{1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}}\\ \noalign{\smallskip} |
| 205 |
% empty & \pmtv[]{1{f(1)} 2{f(2)} \ldots\ldots n{f(n)}} |
| 206 |
% \end{tabular} |
| 207 |
% \end{center} |
| 208 |
% The first example doesn't print `$\ldots$' and `$f(n)$' since the pre-images |
| 209 |
% `$\ldots$' and `$n$' don't appear in the standard printing order (which is |
| 210 |
% the domain here). |
| 211 |
% But it shows image=pre-image pairs not in the permutation since the standard |
| 212 |
% domain defines the elements as pre-images. |
| 213 |
% |
| 214 |
% Note: |
| 215 |
% (a) The (full) verbose format uses math mode and the \TeX-primitive |\atop|. |
| 216 |
% The latter causes a warning if used together with \texttt{amsmath.sty}. |
| 217 |
% (b) The package defines a short verbose output format, too. |
| 218 |
% It prints the row of images only. |
| 219 |
% Don't take it for the cycle based format! |
| 220 |
% |
| 221 |
% \medbreak |
| 222 |
% Finally, some commands also have a star-form which separate the output like |
| 223 |
% this: \pmt*{(12)(23)(34)}. |
| 224 |
% It is useful if you use strings instead of numbers, for example the |
| 225 |
% permutation \pmt*[{{one}}]{({one}{two})({two}{three})({three}{four})} is |
| 226 |
% printed with a |*|-command. |
| 227 |
% |
| 228 |
% |
| 229 |
% \subsection{User commands} |
| 230 |
% |
| 231 |
% \begin{syntax} |
| 232 |
% \item |\pmt|[|*|][\oarg{print order}]\marg{pmt} |
| 233 |
% |
| 234 |
% calculates the composition of the cycles (if any) and prints the |
| 235 |
% permutation: |
| 236 |
% |\pmt{(12)(23)(34)}| prints \pmt{(12)(23)(34)} and |
| 237 |
% |\pmt{12 23 34 41}| gives \pmt{12 23 34 41}. |
| 238 |
% Note that this command outputs cycles only. |
| 239 |
% Some examples: |
| 240 |
% \begin{center} |
| 241 |
% \begin{tabular}{l@{\ prints\ }p{0.4\linewidth}} |
| 242 |
% |\pmt{(12)(34)(56)}|&\pmt{(12)(34)(56)}\\ |
| 243 |
% |\pmt*[2]{(12)(34)(56)}|&\pmt*[2]{(12)(34)(56)}\\ |
| 244 |
% |\pmt[23]{(12)(34)(56)}|&\pmt[23]{(12)(34)(56)}\\ |
| 245 |
% |\pmt*[6]{(12)(34)(56)}|&\pmt*[6]{(12)(34)(56)}\\ |
| 246 |
% \end{tabular} |
| 247 |
% \end{center} |
| 248 |
% The macro |\pmtprintorder| contains the standard printing order, |
| 249 |
% see \ref{uParameters}. |
| 250 |
% |
| 251 |
% \item |\pmtv|[|*|][\oarg{print order}]\marg{pmt} |
| 252 |
% |
| 253 |
% prints a verbose form of the permutation. |
| 254 |
% The commands |\pmtvshorttrue| and |\pmtvshortfalse| controls whether |
| 255 |
% the package prints only the row of images or the full pre-image/image |
| 256 |
% format. |
| 257 |
% |
| 258 |
% \item |\pmttable|[|*|][\oarg{print order}]\marg{list of pmts}\marg{list of pmts} |
| 259 |
% \item |\pmtvtable|[|*|][\oarg{print order}]\marg{list of pmts}\marg{list of pmts} |
| 260 |
% |
| 261 |
% The commands compose each $\sigma_1$ of the first list with each |
| 262 |
% $\sigma_2$ of the second list and write the result |
| 263 |
% $\sigma_1\circ\sigma_2$ in row $\sigma_1$ and column $\sigma_2$. |
| 264 |
% For example, |
| 265 |
% \begin{verbatim} |
| 266 |
% $$\pmttable{(),(12),(13),(23),(123),(132)} |
| 267 |
% {(),(12),(13),(23),(123),(132)}$$\end{verbatim} |
| 268 |
% creates |
| 269 |
% $$\pmttable{(),(12),(13),(23),(123),(132)} |
| 270 |
% {(),(12),(13),(23),(123),(132)}$$ |
| 271 |
% '()' stands for the identity map here. |
| 272 |
% \emph{Do not write} |\pmttable{,(12),...|. You may write |
| 273 |
% |\pmttable{(12),(123)}{(),(23),(123),(132)}| |
| 274 |
% to typeset a piece of the table or use |\pmtvtable| to print all |
| 275 |
% permutations verbose. The optional arguments effect all printed |
| 276 |
% permutations. |
| 277 |
% |
| 278 |
% If you create really big tables like the one of $S_5$, you surely want |
| 279 |
% to cut the whole table in pieces and produce subtables on different |
| 280 |
% pages. This leads to alignment problems since the first column on the |
| 281 |
% first page need not to have the width of the first column on the second |
| 282 |
% page. Bad luck! |
| 283 |
% \end{syntax} |
| 284 |
% \medbreak |
| 285 |
% Now we discuss how to calculate with the \textsf{permute} package. |
| 286 |
% Let \meta{current pmt} denote the (internal) current permutation and |
| 287 |
% \meta{name} another internal (stored) permutation. |
| 288 |
% \begin{syntax} |
| 289 |
% \item |\pmtload|\marg{name}\hphantom{mmmmmm}\qquad |
| 290 |
% \meta{current pmt} $\gets$ \meta{name} |
| 291 |
% |
| 292 |
% \item |\pmtsave|\marg{name}\hphantom{mmmmmm}\qquad |
| 293 |
% \meta{name} $\gets$ \meta{current pmt} |
| 294 |
% |
| 295 |
% \item |\pmtid|[\oarg{name}]\hphantom{\meta{pmt}\ttfamily mmmmmm}$\!$\qquad |
| 296 |
% \meta{current pmt} $\gets$ identity map |
| 297 |
% |
| 298 |
% \item |\pmtdo|[\oarg{name}]\marg{pmt}\hphantom{\ttfamily mmmm}$\!$\qquad |
| 299 |
% \meta{current pmt} $\gets$ \meta{pmt} $\circ$ \meta{current pmt} |
| 300 |
% |
| 301 |
% \item |\pmtcirc|[\oarg{name}]\marg{pmt}\hphantom{\ttfamily mm}$\!$\qquad |
| 302 |
% \meta{current pmt} $\gets$ \meta{current pmt} $\circ$ \meta{pmt} |
| 303 |
% |
| 304 |
% \item |\pmtprint|[|*|][\oarg{print order}]\hphantom{\ttfamily m}\qquad |
| 305 |
% prints \meta{current pmt}. |
| 306 |
% |
| 307 |
% \item |\pmtvprint|[|*|][\oarg{print order}]\qquad |
| 308 |
% prints \meta{current pmt}. |
| 309 |
% |
| 310 |
% \item |\pmtimageof|[\oarg{name}]\marg{pre-image} |
| 311 |
% |
| 312 |
% prints image of \meta{pre-image} under \meta{current pmt}. |
| 313 |
% |
| 314 |
% \item |\pmtpreimageof|[\oarg{name}]\marg{image} |
| 315 |
% |
| 316 |
% prints pre-image of \meta{image} under \meta{current pmt}. |
| 317 |
% \end{syntax} |
| 318 |
% If you use any optional \oarg{name}, this permutation replaces |
| 319 |
% \meta{current pmt}. |
| 320 |
% For example, |\pmtid[a]| makes the permutation $a$ to be the identity map |
| 321 |
% or |\pmtdo[a]|\marg{pmt} performs $a$ $\gets$ \meta{pmt} $\circ$ $a$. |
| 322 |
% |
| 323 |
% \medbreak |
| 324 |
% Finally examples which all print the result of |
| 325 |
% $\pmtv[1\ldots kl\ldots n]{1{f(1)} \ldots\ldots k{f(k)} l{f(l)}^^A |
| 326 |
% \ldots\ldots n{f(n)}}\circ \pmt{(kl)}$, |
| 327 |
% namely |
| 328 |
% \pmtid\pmtdo{(kl)}\pmtdo{1{f(1)} k{f(k)} l{f(l)} n{f(n)}} |
| 329 |
% \pmtvprint[1\ldots kl\ldots n]. |
| 330 |
% \begin{verbatim} |
| 331 |
% \pmtid |
| 332 |
% \pmtdo{1{f(1)} \ldots\ldots k{f(k)} l{f(l)} \ldots\ldots n{f(n)}} |
| 333 |
% \pmtcirc{(kl)} |
| 334 |
% \pmtvprint[1\ldots kl\ldots n] |
| 335 |
% |
| 336 |
% \pmtid |
| 337 |
% \pmtdo{(kl)} |
| 338 |
% \pmtdo{1{f(1)} k{f(k)} l{f(l)} n{f(n)}} |
| 339 |
% \pmtvprint[1\ldots kl\ldots n]\end{verbatim} |
| 340 |
% We can drop the two |\ldots| pairs (also in the first example) since image |
| 341 |
% and pre-image are equal. |
| 342 |
% |
| 343 |
% |
| 344 |
% \subsection{Parameters}\label{uParameters} |
| 345 |
% |
| 346 |
% \begin{syntax} |
| 347 |
% \item |\pmtprintorder| |
| 348 |
% |
| 349 |
% contains the standard printing order which is used whenever you leave |
| 350 |
% out or forget the optional \meta{print order} argument. By default it |
| 351 |
% contains the sequence |123456789abcdefghi|. You may adjust it to your |
| 352 |
% needs, for example, |\renewcommand*\pmtprintorder{123456}| if you work |
| 353 |
% with $S_6$. This is especially good if you use the verbose printing |
| 354 |
% format. You can forget the optional \meta{print order} in this case: |
| 355 |
% \begin{center} |
| 356 |
% \renewcommand*\pmtprintorder{123456} |
| 357 |
% \begin{tabular}{@{}ll@{}} |
| 358 |
% |\renewcommand*\pmtprintorder{123456}|\\ |
| 359 |
% |\pmtv{()}|&prints \pmtv{()}\\ \noalign{\medskip} |
| 360 |
% |\pmtv{(123)}|&prints \pmtv{(123)}\\ \noalign{\medskip} |
| 361 |
% |\pmtv{(12)(23)(16)(34)(45)}|&prints \pmtv{(12)(23)(16)(34)(45)} |
| 362 |
% \end{tabular} |
| 363 |
% \end{center} |
| 364 |
% |
| 365 |
% \item |\pmtseparator| |
| 366 |
% |
| 367 |
% contains the separator used for the optional star. By default it is a |
| 368 |
% space: |\newcommand*\pmtseparator{ }|. Since it's not a backslashed |
| 369 |
% space |\|\textvisiblespace, it is ignored in math mode, in particular |
| 370 |
% in the verbose output format. But you may write |
| 371 |
% |\renewcommand*\pmtseparator{\ }|. |
| 372 |
% |
| 373 |
% \item |\pmtidname| |
| 374 |
% |
| 375 |
% contains the string which is printed in the cycle based format |
| 376 |
% if a permutation is the identity map. It is predefined via |
| 377 |
% |\newcommand*\pmtidname{id}|. |
| 378 |
% |
| 379 |
% \item |\pmtldelim| |
| 380 |
% \item |\pmtrdelim| |
| 381 |
% |
| 382 |
% contain the left respectively right delimiter for the verbose format. |
| 383 |
% |\left(| and |\right)| are used by default. |
| 384 |
% |
| 385 |
% \item |\pmttableborders| |
| 386 |
% |
| 387 |
% contains |lt| which makes a left border column and a top border line. |
| 388 |
% You may redefine it to be empty or to contain |l|, |t|, |lt| or |tl|. |
| 389 |
% |
| 390 |
% \item |\pmtarraystretch| |
| 391 |
% |
| 392 |
% contains |2| and is used as |\arraystretch| for the table. You may |
| 393 |
% write |\renewcommand*\pmtarraystretch{1.3}| and get more compact |
| 394 |
% tables: |
| 395 |
% $$\def\pmtarraystretch{1.3} |
| 396 |
% \pmttable{(),(12),(23)}{(),(12),(23)}$$ |
| 397 |
% \end{syntax} |
| 398 |
% |
| 399 |
% |
| 400 |
% \StopEventually{} |
| 401 |
% |
| 402 |
% |
| 403 |
% \CheckSum{717} |
| 404 |
% |
| 405 |
% |
| 406 |
% \section{Implementation} |
| 407 |
% |
| 408 |
% |
| 409 |
% \subsection{General concept} |
| 410 |
% |
| 411 |
% Permutations, pre-images, and images are stored in macros. In the sequel we |
| 412 |
% use, for example, \meta{image} for an argument which must be a macro and |
| 413 |
% \marg{image} if the image is required explicitly. We define the following |
| 414 |
% internal commands, which make the definition of the user commands easier. |
| 415 |
% |
| 416 |
% \begin{syntax} |
| 417 |
% \item |\pmt@GetImageOf|\marg{pre-image}\meta{pmt} |
| 418 |
% |
| 419 |
% Defines |\pmt@preimage|, its image |\pmt@image|, and \emph{removes} the |
| 420 |
% pre-image/image pair from \meta{pmt}. |\pmt@iffound| equals |\iffalse| |
| 421 |
% if and only if the pair couldn't be removed (since never existent). |
| 422 |
% |
| 423 |
% \item |\pmt@GetPreimageOf|\marg{image}\meta{pmt} |
| 424 |
% |
| 425 |
% Defines |\pmt@image|, its pre-image |\pmt@preimage|, and leaves |
| 426 |
% \meta{pmt} \emph{unchanged}. |\pmt@iffound| equals |\iffalse| |
| 427 |
% if and only if such pair is not found. |
| 428 |
% |
| 429 |
% \item |\pmt@Whirl|\meta{a}\meta{b}\meta{c} |
| 430 |
% |
| 431 |
% \meta{a} $\gets$ \meta{b} $\circ$ \meta{c}. |
| 432 |
% Note that \meta{c} must not equal |\pmt@b|. |
| 433 |
% |
| 434 |
% \item |\pmt@GetPmt|\meta{macro}\marg{pmt} |
| 435 |
% |
| 436 |
% The cycle/verbose input format is converted to the internal data |
| 437 |
% format and assigned to \meta{macro}. |
| 438 |
% |
| 439 |
% \item |\pmt@PrintPmt|\meta{pmt}\qquad and\qquad |\pmt@PrintVPmt|\meta{pmt} |
| 440 |
% |
| 441 |
% print the permutation (verbose) with respect to |\pmt@order|. |
| 442 |
% \emph{Both destroy} |\pmt@a|,\ldots,|\pmt@c|, |\pmt@image|, |
| 443 |
% \emph{and so on.} |
| 444 |
% \end{syntax} |
| 445 |
% |
| 446 |
% |
| 447 |
% \subsection{Preliminaries} |
| 448 |
% |
| 449 |
% \begingroup |
| 450 |
% \begin{macrocode} |
| 451 |
%<*package> |
| 452 |
\ProvidesPackage{permute}[1999/11/10 v0.12 (aeio)(cdt)(knm)] |
| 453 |
% \end{macrocode} |
| 454 |
% I still wonder whether someone finds out what |(aeio)(cdt)(knm)| means. |
| 455 |
% \vskip\lineskip |
| 456 |
% \endgroup |
| 457 |
% |
| 458 |
% \begin{macro}{\pmt@iffirst} |
| 459 |
% \begin{macro}{\pmt@iffound} |
| 460 |
% \begin{macro}{\pmt@ifsep} |
| 461 |
% are each controlled by two simple definitions. |
| 462 |
% \begin{macrocode} |
| 463 |
\def\pmt@firsttrue{\let\pmt@iffirst\iftrue} |
| 464 |
\def\pmt@firstfalse{\let\pmt@iffirst\iffalse} |
| 465 |
% \end{macrocode} |
| 466 |
% \begin{macrocode} |
| 467 |
\def\pmt@foundtrue{\let\pmt@iffound\iftrue} |
| 468 |
\def\pmt@foundfalse{\let\pmt@iffound\iffalse} |
| 469 |
% \end{macrocode} |
| 470 |
% \begin{macrocode} |
| 471 |
\def\pmt@septrue{\let\pmt@ifsep\iftrue} |
| 472 |
\def\pmt@sepfalse{\let\pmt@ifsep\iffalse} |
| 473 |
% \end{macrocode} |
| 474 |
% \end{macro}\end{macro}\end{macro} |
| 475 |
% |
| 476 |
% |
| 477 |
% \subsection{The data format} |
| 478 |
% |
| 479 |
% We store a permutation as a list of pre-image/image pairs, but we drop all |
| 480 |
% with pre-image=image, e.g.\ |{1}{2}{2}{3}{3}{1}| represents (123) no matter |
| 481 |
% whether considered as element of $S_3$, $S_4$ or $S_6$. |
| 482 |
% The identity map is represented by an empty macro. |
| 483 |
% |
| 484 |
% \begin{macro}{\pmt@GetPreimageOf} |
| 485 |
% We define the image and get its pre-image from a submacro. |\pmt@firsttrue| |
| 486 |
% indicates that we are looking for the first of pre-image/image. |
| 487 |
% \begin{macrocode} |
| 488 |
\def\pmt@GetPreimageOf#1#2{% |
| 489 |
\def\pmt@image{#1}\pmt@firsttrue |
| 490 |
\expandafter\pmt@GIO@#2\relax\relax} |
| 491 |
% \end{macrocode} |
| 492 |
% \end{macro} |
| 493 |
% |
| 494 |
% \begin{macro}{\pmt@GetImageOf} |
| 495 |
% We assign the pre-image, empty |\pmt@gio| (which holds the rest of |#2|), get |
| 496 |
% the image, and assign the rest of the permutation to |#2|. |\pmt@firstfalse| |
| 497 |
% indicates that we are looking for the second of pre-image/image. |
| 498 |
% \begin{macrocode} |
| 499 |
\def\pmt@GetImageOf#1#2{% |
| 500 |
\def\pmt@preimage{#1}\let\pmt@gio\@empty \pmt@firstfalse |
| 501 |
\expandafter\pmt@GIO@#2\relax\relax |
| 502 |
\let#2\pmt@gio} |
| 503 |
% \end{macrocode} |
| 504 |
% Now we iterate down the list. |\pmt@image| or |\pmt@preimage| is used as |
| 505 |
% temporary macro. If we have found the correct (pre-)image, we can define it |
| 506 |
% and get the rest of the permutation (up to |\relax\relax|). |
| 507 |
% \begin{macrocode} |
| 508 |
\def\pmt@GIO@#1#2{% |
| 509 |
\pmt@iffirst \def\pmt@preimage{#2}\else |
| 510 |
\def\pmt@image{#1}\fi |
| 511 |
\ifx\pmt@image\pmt@preimage |
| 512 |
\def\pmt@preimage{#1}\def\pmt@image{#2}\pmt@foundtrue |
| 513 |
\expandafter\pmt@GIO@@ |
| 514 |
\else |
| 515 |
% \end{macrocode} |
| 516 |
% If we haven't found the correct (pre-)image: Image and pre-image must be |
| 517 |
% equal if we have reached the end of list; otherwise we probably extend |
| 518 |
% |\pmt@gio| and continue the loop. |
| 519 |
% \begin{macrocode} |
| 520 |
\ifx\relax#2% |
| 521 |
\pmt@foundfalse |
| 522 |
\pmt@iffirst \let\pmt@preimage\pmt@image |
| 523 |
\else \let\pmt@image\pmt@preimage \fi |
| 524 |
\expandafter\@gobbletwo |
| 525 |
\else |
| 526 |
\pmt@iffirst\else \pmt@AddTo\pmt@gio{{#1}{#2}}\fi |
| 527 |
\fi |
| 528 |
\expandafter\pmt@GIO@ |
| 529 |
\fi} |
| 530 |
% \end{macrocode} |
| 531 |
% The following macro gets the rest of permutation. |
| 532 |
% \begin{macrocode} |
| 533 |
\def\pmt@GIO@@#1\relax\relax{% |
| 534 |
\pmt@iffirst\else \pmt@AddTo\pmt@gio{#1}\fi} |
| 535 |
% \end{macrocode} |
| 536 |
% \end{macro} |
| 537 |
% |
| 538 |
% \begin{macro}{\pmt@AddTo} |
| 539 |
% \begin{macro}{\pmt@Extend} |
| 540 |
% |\pmt@AddTo| adds |#2| to the contents of the macro |#1|. |
| 541 |
% |\pmt@Extend| expands the first token of |#2| before doing the same. |
| 542 |
% \begin{macrocode} |
| 543 |
\def\pmt@AddTo#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} |
| 544 |
\def\pmt@Extend#1#2{% |
| 545 |
\expandafter\pmt@AddTo\expandafter#1\expandafter{#2}} |
| 546 |
% \end{macrocode} |
| 547 |
% \end{macro}\end{macro} |
| 548 |
% |
| 549 |
% |
| 550 |
% \subsection{Whirling things round}\label{iWhirlingThingsRound} |
| 551 |
% |
| 552 |
% \begin{macro}{\pmt@Whirl} |
| 553 |
% Init, whirl, assign. |
| 554 |
% \begin{macrocode} |
| 555 |
\def\pmt@Whirl#1#2#3{% |
| 556 |
\let\pmt@b#2\let\pmt@c#3\let\pmt@a\@empty |
| 557 |
\pmt@Whirl@ |
| 558 |
\let#1\pmt@a} |
| 559 |
% \end{macrocode} |
| 560 |
% If |\pmt@c| is empty, we only need to append the contents of |\pmt@b| to |
| 561 |
% |\pmt@a| since |\pmt@c| represents the identity map. |
| 562 |
% \begin{macrocode} |
| 563 |
\def\pmt@Whirl@{% |
| 564 |
\ifx\pmt@c\@empty |
| 565 |
\pmt@Extend\pmt@a\pmt@b |
| 566 |
\else |
| 567 |
% \end{macrocode} |
| 568 |
% Otherwise we append the first pre-image and its image under the composition, |
| 569 |
% and continue to check whether |\pmt@c| is empty. |
| 570 |
% \begin{macrocode} |
| 571 |
\expandafter\pmt@Whirl@@\pmt@c\relax |
| 572 |
\expandafter\pmt@Whirl@ |
| 573 |
\fi} |
| 574 |
% \end{macrocode} |
| 575 |
% |\pmt@c| becomes shorter, we get the `composed' image, \ldots |
| 576 |
% \begin{macrocode} |
| 577 |
\def\pmt@Whirl@@#1#2#3\relax{% |
| 578 |
\def\pmt@first{#1}\def\pmt@c{#3}% |
| 579 |
\pmt@GetImageOf{#2}\pmt@b |
| 580 |
% \end{macrocode} |
| 581 |
% and append the new pre-image/image pair if first$\neq$image. |
| 582 |
% There is only some trouble in making braces around the (pre-)image. |
| 583 |
% \begin{macrocode} |
| 584 |
\ifx\pmt@first\pmt@image\else |
| 585 |
\def\pmt@first{{#1}}% |
| 586 |
\pmt@Extend\pmt@first{\expandafter{\pmt@image}}% |
| 587 |
\pmt@Extend\pmt@a\pmt@first |
| 588 |
\fi} |
| 589 |
% \end{macrocode} |
| 590 |
% \end{macro} |
| 591 |
% |
| 592 |
% |
| 593 |
% \subsection{Getting input} |
| 594 |
% |
| 595 |
% \begin{macro}{\pmt@InputError} |
| 596 |
% gives an error message. |
| 597 |
% \begin{macrocode} |
| 598 |
\def\pmt@InputError#1{\PackageError{Permute}{#1}\@ehd} |
| 599 |
% \end{macrocode} |
| 600 |
% \end{macro} |
| 601 |
% |
| 602 |
% \begin{macro}{\pmt@GetPmt} |
| 603 |
% We initialize |\pmt@a|, do the conversion and assign the result to |#1|. |
| 604 |
% \begin{macrocode} |
| 605 |
\def\pmt@GetPmt#1#2{% |
| 606 |
\def\pmt@a{#2}% |
| 607 |
\pmt@foundtrue \pmt@firstfalse |
| 608 |
\@ifnextchar({\let\pmt@a\@empty \pmt@GetCPmt}% |
| 609 |
\pmt@GetVPmt |
| 610 |
#2\relax\relax |
| 611 |
\let#1\pmt@a} |
| 612 |
% \end{macrocode} |
| 613 |
% \end{macro} |
| 614 |
% |
| 615 |
% \begin{macro}{\pmt@GetVPmt} |
| 616 |
% For the verbose format we only test for an even number of arguments. |
| 617 |
% \begin{macrocode} |
| 618 |
\def\pmt@GetVPmt#1#2{% |
| 619 |
\ifx\relax#2% |
| 620 |
\ifx\relax#1\else |
| 621 |
\pmt@InputError{Odd number of tokens}% |
| 622 |
\let\pmt@a\@empty |
| 623 |
\fi |
| 624 |
\else |
| 625 |
\expandafter\pmt@GetVPmt |
| 626 |
\fi} |
| 627 |
% \end{macrocode} |
| 628 |
% \end{macro} |
| 629 |
% |
| 630 |
% \begin{macro}{\pmt@GetCPmt} |
| 631 |
% is called |\pmt@GetCPmt|\meta{cycles}|\relax| and |\pmt@a| becomes |\pmt@a| |
| 632 |
% $\circ$ \meta{cycles}. If we haven't found a right parenthesis and reach the |
| 633 |
% end of the cycles, we give an error message. Reaching |\relax| we terminate |
| 634 |
% the loop by gobbling a far away |\pmt@GetCPmt|. |
| 635 |
% \begin{macrocode} |
| 636 |
\def\pmt@GetCPmt#1{% |
| 637 |
\ifx#1\relax |
| 638 |
\pmt@iffound\else \pmt@InputError{Missing `)'}\fi |
| 639 |
\expandafter\@gobble |
| 640 |
\else |
| 641 |
% \end{macrocode} |
| 642 |
% If we find a right parenthesis, we either give an error message or use the |
| 643 |
% first element of the current cycle as image of the last element. In this case |
| 644 |
% we compose |\pmt@a| and |\pmt@c| via |\pmt@Whirl| defined in section |
| 645 |
% \ref{iWhirlingThingsRound}. |
| 646 |
% \begin{macrocode} |
| 647 |
\ifx#1)% |
| 648 |
\pmt@iffound |
| 649 |
\pmt@InputError{Extra `)'}% |
| 650 |
\else |
| 651 |
\pmt@iffirst\else |
| 652 |
\pmt@Extend\pmt@c\pmt@first |
| 653 |
\pmt@Whirl\pmt@a\pmt@a\pmt@c |
| 654 |
\fi |
| 655 |
\pmt@foundtrue |
| 656 |
\fi |
| 657 |
\else |
| 658 |
% \end{macrocode} |
| 659 |
% A left parenthesis might lead to an error, but in any case initializes two |
| 660 |
% \texttt{if}s. |
| 661 |
% \begin{macrocode} |
| 662 |
\ifx#1(% |
| 663 |
\pmt@iffound\else |
| 664 |
\pmt@InputError{Extra `(' or missing `)'}% |
| 665 |
\fi |
| 666 |
\pmt@firsttrue \pmt@foundfalse |
| 667 |
\else |
| 668 |
% \end{macrocode} |
| 669 |
% Now we handle all other tokens. If we are outside a cycle (i.e.\ a closing |
| 670 |
% parenthesis has been found), we give an error message. |
| 671 |
% \begin{macrocode} |
| 672 |
\pmt@iffound |
| 673 |
\pmt@InputError{Missing `('}% |
| 674 |
\else |
| 675 |
% \end{macrocode} |
| 676 |
% Otherwise we initialize or extend |\pmt@c|. |
| 677 |
% \begin{macrocode} |
| 678 |
\pmt@iffirst |
| 679 |
\pmt@firstfalse \def\pmt@first{{#1}}\def\pmt@c{{#1}}% |
| 680 |
\else |
| 681 |
\pmt@AddTo\pmt@c{{#1}{#1}}% |
| 682 |
\fi |
| 683 |
\fi\fi\fi |
| 684 |
\fi |
| 685 |
% \end{macrocode} |
| 686 |
% Continue the loop (if not gobbled). |
| 687 |
% \begin{macrocode} |
| 688 |
\pmt@GetCPmt} |
| 689 |
% \end{macrocode} |
| 690 |
% \end{macro} |
| 691 |
% |
| 692 |
% |
| 693 |
% \subsection{Doing output} |
| 694 |
% |
| 695 |
% \begin{macro}{\pmt@PrintVPmt} |
| 696 |
% Is easy. |
| 697 |
% \begin{macrocode} |
| 698 |
\def\pmt@PrintVPmt#1{% |
| 699 |
\let\pmt@a#1\pmt@sepfalse |
| 700 |
\ensuremath{\pmtldelim |
| 701 |
\expandafter\pmt@PrintVPmt@\pmt@order\relax |
| 702 |
\pmtrdelim}} |
| 703 |
% \end{macrocode} |
| 704 |
% While |\relax| is not reached, we define pre-image, get the image, and use |
| 705 |
% |\atop| to typeset the pre-image/image pair. |
| 706 |
% \begin{macrocode} |
| 707 |
\def\pmt@PrintVPmt@#1{% |
| 708 |
\ifx\relax#1\@empty \else |
| 709 |
\pmt@GetImageOf{#1}\pmt@a |
| 710 |
\pmt@ifsep \pmt@separator \else \pmt@septrue \fi |
| 711 |
\mkern1mu% |
| 712 |
\pmt@ifshort \pmt@image |
| 713 |
\else{\pmt@preimage\atop\pmt@image}\fi |
| 714 |
\mkern1mu% |
| 715 |
\expandafter\pmt@PrintVPmt@ |
| 716 |
\fi} |
| 717 |
% \end{macrocode} |
| 718 |
% \end{macro} |
| 719 |
% |
| 720 |
% \begin{macro}{\pmtshorttrue} |
| 721 |
% \begin{macro}{\pmtshortfalse} |
| 722 |
% The user accessible \texttt{if} used above. |
| 723 |
% \begin{macrocode} |
| 724 |
\def\pmtshorttrue{\let\pmt@ifshort\iftrue} |
| 725 |
\def\pmtshortfalse{\let\pmt@ifshort\iffalse} |
| 726 |
\pmtshortfalse |
| 727 |
% \end{macrocode} |
| 728 |
% \end{macro}\end{macro} |
| 729 |
% |
| 730 |
% \begin{macro}{\pmt@GetFirst} |
| 731 |
% defines |\pmt@first| and gobbles all tokens up to the next |\relax|. |
| 732 |
% \begin{macrocode} |
| 733 |
\def\pmt@GetFirst#1#2\relax{\def\pmt@first{#1}} |
| 734 |
% \end{macrocode} |
| 735 |
% \end{macro} |
| 736 |
% |
| 737 |
% \begin{macro}{\pmt@PrintPmt} |
| 738 |
% We print |\pmtidname| if necessary. |
| 739 |
% \begin{macrocode} |
| 740 |
\def\pmt@PrintPmt#1{% |
| 741 |
\let\pmt@a#1% |
| 742 |
\ifx\pmt@a\@empty \pmtidname \else |
| 743 |
\expandafter\pmt@PrintPmt@\pmt@order\relax |
| 744 |
\fi} |
| 745 |
% \end{macrocode} |
| 746 |
% While having an order, we define the first pre-image and print the cycle. |
| 747 |
% \begin{macrocode} |
| 748 |
\def\pmt@PrintPmt@#1{% |
| 749 |
\ifx\relax#1\@empty |
| 750 |
\expandafter\pmt@PrintPmt@@ |
| 751 |
\else |
| 752 |
\def\pmt@first{#1}\pmt@PrintCycle |
| 753 |
\expandafter\pmt@PrintPmt@ |
| 754 |
\fi} |
| 755 |
% \end{macrocode} |
| 756 |
% Having no order, we print the rest. |
| 757 |
% \begin{macrocode} |
| 758 |
\def\pmt@PrintPmt@@{% |
| 759 |
\ifx\pmt@a\@empty\else |
| 760 |
\expandafter\pmt@GetFirst\pmt@a\relax |
| 761 |
\pmt@PrintCycle |
| 762 |
\expandafter\pmt@PrintPmt@@ |
| 763 |
\fi} |
| 764 |
% \end{macrocode} |
| 765 |
% \end{macro} |
| 766 |
% |
| 767 |
% \begin{macro}{\pmt@PrintCycle} |
| 768 |
% We print the cycle containing (and beginning with) the contents of |
| 769 |
% |\pmt@first| if it appears as pre-image. |
| 770 |
% \begin{macrocode} |
| 771 |
\def\pmt@PrintCycle{% |
| 772 |
\expandafter\pmt@GetImageOf\expandafter{\pmt@first}\pmt@a |
| 773 |
\pmt@iffound |
| 774 |
(\pmt@preimage\pmt@separator\pmt@image |
| 775 |
\ifx\pmt@a\@empty\else \pmt@PrintCycle@\pmt@image \fi |
| 776 |
)% |
| 777 |
\fi} |
| 778 |
% \end{macrocode} |
| 779 |
% While we haven't found the end of the cycle, \ldots |
| 780 |
% \begin{macrocode} |
| 781 |
\def\pmt@PrintCycle@#1{% |
| 782 |
\expandafter\pmt@GetImageOf\expandafter{#1}\pmt@a |
| 783 |
\ifx\pmt@image\pmt@first\else |
| 784 |
% \end{macrocode} |
| 785 |
% we print the image and use the image as new pre-image if permutation is |
| 786 |
% not empty yet. |
| 787 |
% \begin{macrocode} |
| 788 |
\pmt@separator\pmt@image |
| 789 |
\ifx\pmt@a\@empty \expandafter\@gobblefour \fi |
| 790 |
\expandafter\pmt@PrintCycle@\expandafter\pmt@image |
| 791 |
\fi} |
| 792 |
% \end{macrocode} |
| 793 |
% \end{macro} |
| 794 |
% |
| 795 |
% |
| 796 |
% \subsection{User commands and parameters} |
| 797 |
% |
| 798 |
% \begin{macro}{\pmtidname} |
| 799 |
% \begin{macro}{\pmtprintorder} |
| 800 |
% \begin{macro}{\pmtseparator} |
| 801 |
% \begin{macro}{\pmtldelim} |
| 802 |
% \begin{macro}{\pmtrdelim} |
| 803 |
% \begin{macro}{\pmttableborders} |
| 804 |
% \begin{macro}{\pmtarraystretch} |
| 805 |
% Some predefined values. |
| 806 |
% \begin{macrocode} |
| 807 |
\newcommand*\pmtidname{id} |
| 808 |
\newcommand*\pmtprintorder{123456789abcdefghi} |
| 809 |
\newcommand*\pmtseparator{ } |
| 810 |
\newcommand*\pmtldelim{\left(} |
| 811 |
\newcommand*\pmtrdelim{\right)} |
| 812 |
\newcommand*\pmttableborders{lt} |
| 813 |
\newcommand*\pmtarraystretch{2} |
| 814 |
% \end{macrocode} |
| 815 |
% \end{macro}\end{macro}\end{macro}\end{macro} |
| 816 |
% \end{macro}\end{macro}\end{macro} |
| 817 |
% |
| 818 |
% \begin{macro}{\pmt@GetPrintArgs} |
| 819 |
% This helper executes |#1| after getting the optional printing arguments. |
| 820 |
% \begin{macrocode} |
| 821 |
\def\pmt@GetPrintArgs#1{% |
| 822 |
\let\pmt@order\pmtprintorder \def\pmt@next{#1}% |
| 823 |
\@ifstar{\let\pmt@separator\pmtseparator \pmt@GPA@}% |
| 824 |
{\let\pmt@separator\@empty \pmt@GPA@}} |
| 825 |
% \end{macrocode} |
| 826 |
% If there is no optional argument, we use |\pmtprintorder|, i.e.\ we don't |
| 827 |
% redefine |\pmt@order|. |
| 828 |
% \begin{macrocode} |
| 829 |
\def\pmt@GPA@{\@ifnextchar[\pmt@GPA@@\pmt@next} |
| 830 |
\def\pmt@GPA@@[#1]{\def\pmt@order{#1}\pmt@next} |
| 831 |
% \end{macrocode} |
| 832 |
% \end{macro} |
| 833 |
% |
| 834 |
% \begin{macro}{\pmt} |
| 835 |
% \begin{macro}{\pmtv} |
| 836 |
% \begin{macro}{\pmtprint} |
| 837 |
% \begin{macro}{\pmtvprint} |
| 838 |
% The first user commands in terms of known definitions. |
| 839 |
% \begin{macrocode} |
| 840 |
\newcommand*\pmt {\pmt@GetPrintArgs{\pmt@\pmt@PrintPmt}} |
| 841 |
\newcommand*\pmtv{\pmt@GetPrintArgs{\pmt@\pmt@PrintVPmt}} |
| 842 |
\def\pmt@#1#2{\pmt@GetPmt\pmt@a{#2}#1\pmt@a} |
| 843 |
% \end{macrocode} |
| 844 |
% \begin{macrocode} |
| 845 |
\newcommand*\pmtprint {\pmt@GetPrintArgs{\pmt@PrintPmt\pmt@curr}} |
| 846 |
\newcommand*\pmtvprint{\pmt@GetPrintArgs{\pmt@PrintVPmt\pmt@curr}} |
| 847 |
% \end{macrocode} |
| 848 |
% \end{macro}\end{macro}\end{macro}\end{macro} |
| 849 |
% |
| 850 |
% \begin{macro}{\pmt@OptName} |
| 851 |
% `executes' |#1| with argument |\pmt@curr| \ldots |
| 852 |
% \begin{macrocode} |
| 853 |
\def\pmt@OptName#1{\def\pmt@next##1{#1}% |
| 854 |
\@ifnextchar[\pmt@OptName@{\pmt@next\pmt@curr}} |
| 855 |
% \end{macrocode} |
| 856 |
% or |\pmt@s@|\meta{name} if an optional argument is given. |\pmt@LoadPmt| |
| 857 |
% ensures that the permuation |#1|$=$\meta{name} is defined. |
| 858 |
% \begin{macrocode} |
| 859 |
\def\pmt@OptName@[#1]{% |
| 860 |
\pmt@LoadPmt{#1}\pmt@a |
| 861 |
\expandafter\pmt@next\csname pmt@s@#1\endcsname} |
| 862 |
% \end{macrocode} |
| 863 |
% \end{macro} |
| 864 |
% |
| 865 |
% \begin{macro}{\pmt@LoadPmt} |
| 866 |
% loads the permutation with name |#1| to |#2|. |
| 867 |
% \begin{macrocode} |
| 868 |
\def\pmt@LoadPmt#1#2{% |
| 869 |
\@ifundefined{pmt@s@#1}% |
| 870 |
{\expandafter\let\csname pmt@s@#1\endcsname\@empty} |
| 871 |
\expandafter\let\expandafter#2\csname pmt@s@#1\endcsname} |
| 872 |
% \end{macrocode} |
| 873 |
% \end{macro} |
| 874 |
% |
| 875 |
% \begin{macro}{\pmtsave} |
| 876 |
% \begin{macro}{\pmtload} |
| 877 |
% \begin{macro}{\pmtid} |
| 878 |
% Some more user commands. |
| 879 |
% \begin{macrocode} |
| 880 |
\def\pmtsave#1{\expandafter\let\csname pmt@s@#1\endcsname\pmt@curr} |
| 881 |
\def\pmtload#1{\pmt@LoadPmt{#1}\pmt@curr} |
| 882 |
% \end{macrocode} |
| 883 |
% |##1| $\in$ \{|\pmt@curr|,|\pmt@s@|\meta{name}\} becomes empty. |
| 884 |
% \begin{macrocode} |
| 885 |
\newcommand*\pmtid{\pmt@OptName{\let##1\@empty \ignorespaces}} |
| 886 |
\pmtid |
| 887 |
% \end{macrocode} |
| 888 |
% \end{macro}\end{macro}\end{macro} |
| 889 |
% |
| 890 |
% \begin{macro}{\pmtdo} |
| 891 |
% \begin{macro}{\pmtcirc} |
| 892 |
% The only difference here is the order of |\pmt@a| and |##1|. |
| 893 |
% \begin{macrocode} |
| 894 |
\newcommand*\pmtdo{\pmt@OptName{\pmtdo@##1\pmt@a##1}} |
| 895 |
\newcommand*\pmtcirc{\pmt@OptName{\pmtdo@##1##1\pmt@a}} |
| 896 |
\def\pmtdo@#1#2#3#4{\pmt@GetPmt\pmt@a{#4}\pmt@Whirl#1#2#3\ignorespaces} |
| 897 |
% \end{macrocode} |
| 898 |
% \end{macro}\end{macro} |
| 899 |
% |
| 900 |
% \begin{macro}{\pmtimageof} |
| 901 |
% \begin{macro}{\pmtpreimageof} |
| 902 |
% We use different arguments to the submacro to get and print the (pre-)image. |
| 903 |
% \begin{macrocode} |
| 904 |
\newcommand*\pmtimageof{\pmtimageof@\pmt@GetImageOf\pmt@image} |
| 905 |
\newcommand*\pmtpreimageof{\pmtimageof@\pmt@GetPreimageOf\pmt@preimage} |
| 906 |
% \end{macrocode} |
| 907 |
% \begin{macrocode} |
| 908 |
\def\pmtimageof@#1#2{% |
| 909 |
\@ifnextchar[{\pmtimageof@@#1#2}{\pmtimageof@@#1#2[]}} |
| 910 |
\def\pmtimageof@#1#2[#3]#4{% |
| 911 |
\ifx\@empty#3\@empty |
| 912 |
\let\pmt@a\pmt@curr |
| 913 |
\else |
| 914 |
\pmt@LoadPmt{#3}\pmt@a |
| 915 |
\fi |
| 916 |
#1{#4}\pmt@a |
| 917 |
#2} |
| 918 |
% \end{macrocode} |
| 919 |
% TODO: These two user macros don't behave like |\pmtid|, |\pmtdo|, and so on. |
| 920 |
% An empty named permutation \meta{name} leads here to \meta{current pmt} and not |
| 921 |
% to |\pmt@s@|\meta{name}. |
| 922 |
% \end{macro}\end{macro} |
| 923 |
% |
| 924 |
% |
| 925 |
% \subsection{Making tables} |
| 926 |
% |
| 927 |
% \begin{macro}{\pmtvtable} |
| 928 |
% We use appropriate local redefinitions of |\pmtprint|. |
| 929 |
% \begin{macrocode} |
| 930 |
\newcommand*\pmttable |
| 931 |
{\begingroup |
| 932 |
\def\pmtprint{\let\pmt@order\pmt@porder\pmt@PrintPmt\pmt@curr}% |
| 933 |
\pmt@GetPrintArgs\pmt@PrintTable} |
| 934 |
% \end{macrocode} |
| 935 |
% \begin{macrocode} |
| 936 |
\newcommand*\pmtvtable |
| 937 |
{\begingroup |
| 938 |
\def\pmtprint{\let\pmt@order\pmt@porder\pmt@PrintVPmt\pmt@curr}% |
| 939 |
\pmt@GetPrintArgs\pmt@PrintTable} |
| 940 |
% \end{macrocode} |
| 941 |
% \end{macro} |
| 942 |
% |
| 943 |
% \begin{macro}{\pmt@PrintTable} |
| 944 |
% We use macros defined below to indicate the desired borders. |
| 945 |
% \begin{macrocode} |
| 946 |
\def\pmt@PrintTable#1#2{% |
| 947 |
\let\pmt@ifleft\iffalse |
| 948 |
\pmt@topfalse |
| 949 |
\expandafter\pmt@SetBorders\pmttableborders\relax |
| 950 |
% \end{macrocode} |
| 951 |
% \begin{macrocode} |
| 952 |
\let\pmt@porder\pmt@order |
| 953 |
\let\arraystretch\pmtarraystretch |
| 954 |
% \end{macrocode} |
| 955 |
% Determine how many columns the table will have, and choose the right |
| 956 |
% tabular call (according to the desired left border) |
| 957 |
% \begin{macrocode} |
| 958 |
\@tempcnta\z@ \pmt@for{\advance\@tempcnta\@ne}{#2}% |
| 959 |
% \end{macrocode} |
| 960 |
% Note: It's possible to write |\begin{tabular}{\pmt@ifleft c|\ldots, but the |
| 961 |
% construction here is independent of that. |
| 962 |
% \begin{macrocode} |
| 963 |
\edef\pmt@next{% |
| 964 |
\noexpand\begin{tabular}{\pmt@ifleft c|\else p{\z@}@{}\fi |
| 965 |
*{\the\@tempcnta}{@{\ }c@{\ }}}}% |
| 966 |
\pmt@next |
| 967 |
% \end{macrocode} |
| 968 |
% Print the top border if desired. |
| 969 |
% \begin{macrocode} |
| 970 |
\pmt@iftop |
| 971 |
\pmt@ifleft \ensuremath{\circ}\fi |
| 972 |
\pmt@for{&\pmtid\pmtdo{##1}\pmtprint}{#1}% |
| 973 |
\\ \hline |
| 974 |
\fi |
| 975 |
% \end{macrocode} |
| 976 |
% And process the rest of the table: we end the previous tabular line (if there |
| 977 |
% is any), print the left border (if desired) and print one line of the table. |
| 978 |
% \begin{macrocode} |
| 979 |
\gdef\pmt@topperms{#2}\pmt@toptrue |
| 980 |
\pmt@for{% |
| 981 |
\pmt@iftop \pmt@topfalse \else \expandafter\\\fi |
| 982 |
\pmt@ifleft \pmtid\pmtdo{##1}\pmtprint \fi |
| 983 |
\pmt@PrintTableLine{##1}}% |
| 984 |
{#1}% |
| 985 |
\end{tabular}\endgroup} |
| 986 |
% \end{macrocode} |
| 987 |
% \end{macro} |
| 988 |
% |
| 989 |
% \begin{macro}{\pmt@PrintTableLine} |
| 990 |
% is |\pmt@PrintTableLine@{#1}|$\langle$\textit{expansion of} |
| 991 |
% |\pmt@topperms|$\rangle$|,\relax,| |
| 992 |
% \begin{macrocode} |
| 993 |
\def\pmt@PrintTableLine#1{% |
| 994 |
\def\pmt@next{\pmt@PrintTableLine@{#1}}% |
| 995 |
\expandafter\pmt@next\pmt@topperms,\relax,} |
| 996 |
% \end{macrocode} |
| 997 |
% Now we get |#1| and (step by step) each permutation of |\pmt@topperms|, |
| 998 |
% and print the composition. |
| 999 |
% \begin{macrocode} |
| 1000 |
\def\pmt@PrintTableLine@#1#2,{% |
| 1001 |
\ifx\relax#2\else |
| 1002 |
\def\pmt@next{&\pmtid\pmtdo{#2}\pmtdo{#1}\pmtprint |
| 1003 |
\pmt@PrintTableLine@{#1}}% |
| 1004 |
\expandafter\pmt@next |
| 1005 |
\fi} |
| 1006 |
% \end{macrocode} |
| 1007 |
% \end{macro} |
| 1008 |
% |
| 1009 |
% \begin{macro}{\pmt@for} |
| 1010 |
% performs |#1| for each element of the comma separated list |#2|. |
| 1011 |
% \begin{macrocode} |
| 1012 |
\def\pmt@for#1#2{% |
| 1013 |
\gdef\pmt@for@##1,{% |
| 1014 |
\ifx\relax##1\else |
| 1015 |
\def\pmt@next{#1\expandafter\pmt@for@}% |
| 1016 |
\expandafter\pmt@next |
| 1017 |
\fi}% |
| 1018 |
\pmt@for@#2,\relax,} |
| 1019 |
% \end{macrocode} |
| 1020 |
% \end{macro} |
| 1021 |
% |
| 1022 |
% \begin{macro}{\pmt@SetBorders} |
| 1023 |
% \begin{macro}{\pmt@topfalse} |
| 1024 |
% \begin{macro}{\pmt@toptrue} |
| 1025 |
% \begin{macro}{\pmt@lefttrue} |
| 1026 |
% Get characters up to |\relax| and set \texttt{if}s. |
| 1027 |
% \begin{macrocode} |
| 1028 |
\def\pmt@SetBorders#1{% |
| 1029 |
\ifx\relax#1\else |
| 1030 |
\if l#1\pmt@lefttrue \fi |
| 1031 |
\if t#1\pmt@toptrue \fi |
| 1032 |
\expandafter\pmt@SetBorders |
| 1033 |
\fi} |
| 1034 |
% \end{macrocode} |
| 1035 |
% \begin{macrocode} |
| 1036 |
\def\pmt@topfalse{\global\let\pmt@iftop\iffalse} |
| 1037 |
\def\pmt@toptrue{\global\let\pmt@iftop\iftrue} |
| 1038 |
\def\pmt@lefttrue{\let\pmt@ifleft\iftrue} |
| 1039 |
% \end{macrocode} |
| 1040 |
% \end{macro}\end{macro}\end{macro}\end{macro} |
| 1041 |
% |
| 1042 |
% \begingroup |
| 1043 |
% \begin{macrocode} |
| 1044 |
%</package> |
| 1045 |
% \end{macrocode} |
| 1046 |
% \endgroup |
| 1047 |
% |
| 1048 |
% |
| 1049 |
% \subsection{To do} |
| 1050 |
% |
| 1051 |
% It would be nice to have commands |\pmtpartialtable| and |\pmtvpartialtable| |
| 1052 |
% which print a specified part of a whole table. If requested, these commands |
| 1053 |
% should determine the width of the columns such that the columns are aligned |
| 1054 |
% correctly if all parts are printed and put together. For this procedure it |
| 1055 |
% would be convenient either to store the lists of permutations so that the |
| 1056 |
% commands can access them, or to let the package take control and print the |
| 1057 |
% table on different pages (if necessary). |
| 1058 |
% |
| 1059 |
% Cycle substitution: After |\pmtsubstitute{(123)(45)}{a}| the permutation |
| 1060 |
% (123)(45) is replaced by $a$ in the output. Difficult to implement (due to |
| 1061 |
% \meta{print order} and |\pmtprintorder|) and even more difficult if this |
| 1062 |
% substitution should take place `inside' permutations. |
| 1063 |
% In general, the latter is not possible or not reasonable. |
| 1064 |
% But it is interesting in context with the next ``to do'' paragraph. |
| 1065 |
% |
| 1066 |
% Implement possibility to print (and store) permutations as they have been |
| 1067 |
% entered. |
| 1068 |
% This does not mean just to store the character sequence since composition |
| 1069 |
% with other permutations must be possible, of course. |
| 1070 |
% The internal data format (or an additional list) must represent the input. |
| 1071 |
% Storing an additional \meta{print order} is not sufficient. |
| 1072 |
% For example, (123)(321) is represented by an empty string, but we cannot |
| 1073 |
% recreate it from the empty string and \meta{print order}. |
| 1074 |
% Thus we might need two additional data: \meta{print order} and something |
| 1075 |
% like the original string. |
| 1076 |
% |
| 1077 |
% New command |\pmtinverse|[\oarg{name}] (easy) and its applications. |
| 1078 |
% |
| 1079 |
% |
| 1080 |
% \subsection{History} |
| 1081 |
% |
| 1082 |
% \renewcommand\labelitemi{--} |
| 1083 |
% \begin{itemize} |
| 1084 |
% \item[0.1] from 1997/11/08 (unpublished) |
| 1085 |
% \item commands |\pmt|, |\pmtloadid| (became |\pmtid|), |\pmtdo| (became |
| 1086 |
% |\pmtcirc|), |\pmtprint| and |\pmttable| support $S_1,\ldots,S_9$ |
| 1087 |
% \item[0.11] from 1998/12/17 |
| 1088 |
% \item restriction to $S_1,\ldots,S_9$ dropped |
| 1089 |
% \item new commands |\pmtv|, |\pmtvprint|, |\pmtvtable| provide verbose |
| 1090 |
% printing format and the old commands |\pmt|, |\pmtv|, |\pmtdo|, |
| 1091 |
% |\pmtcirc|, |\pmttable| and |\pmtvtable| now accept verbose input |
| 1092 |
% \item |\pmtprintorder|, |\pmtseparator|, |\pmtidname|, |\pmtldelim|, |
| 1093 |
% |\pmtrdelim|, |\pmttableborders| (prior optional argument), |
| 1094 |
% |\pmtarraystretch| are new parameters |
| 1095 |
% \item[0.12] from 1999/11/10 |
| 1096 |
% \item new commands |\pmtvshorttrue|, |\pmtvshortfalse|, |\pmtsave|, |
| 1097 |
% |\pmtload|, |\pmtimageof| and |\pmtpreimageof| |
| 1098 |
% \item enhanced commands |\pmtid|, |\pmtdo| and |\pmtcirc| |
| 1099 |
% \end{itemize} |
| 1100 |
% |
| 1101 |
% |
| 1102 |
% \Finale |
| 1103 |
% |
| 1104 |
\endinput |