Back to home page

Quest Cross Reference

 
 

    


0001 %%
0002 %% This is file `algorithmic.sty',
0003 %% generated with the docstrip utility.
0004 %%
0005 %% The original source files were:
0006 %%
0007 %% algorithms.dtx  (with options: `algorithmic')
0008 %% This is a generated file.
0009 %% 
0010 %% Copyright (C) 1994-2004   Peter Williams <pwil3058@bigpond.net.au>
0011 %% Copyright (C) 2005-2009   Rogério Brito <rbrito@ime.usp.br>
0012 %% 
0013 %% This document file is free software; you can redistribute it and/or
0014 %% modify it under the terms of the GNU Lesser General Public License as
0015 %% published by the Free Software Foundation; either version 2 of the
0016 %% License, or (at your option) any later version.
0017 %% 
0018 %% This document file is distributed in the hope that it will be useful, but
0019 %% WITHOUT ANY WARRANTY; without even the implied warranty of
0020 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
0021 %% General Public License for more details.
0022 %% 
0023 %% You should have received a copy of the GNU Lesser General Public License
0024 %% along with this document file; if not, write to the Free Software
0025 %% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
0026 %% USA.
0027 %% 
0028 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
0029 \ProvidesPackage{algorithmic}
0030    [2009/08/24 v0.1 Document Style `algorithmic']
0031 % The algorithmic.sty package:
0032 \RequirePackage{ifthen}
0033 \RequirePackage{keyval}
0034 \newboolean{ALC@noend}
0035 \setboolean{ALC@noend}{false}
0036 \newcounter{ALC@unique}    % new counter to make lines numbers be internally
0037 \setcounter{ALC@unique}{0} % different in different algorithms
0038 \newcounter{ALC@line}      % counter for current line
0039 \newcounter{ALC@rem}       % counter for lines not printed
0040 \newcounter{ALC@depth}
0041 \newlength{\ALC@tlm}
0042 %
0043 \DeclareOption{noend}{\setboolean{ALC@noend}{true}}
0044 %
0045 \ProcessOptions
0046 %
0047 % For keyval-style options
0048 \def\algsetup{\setkeys{ALG}}
0049 %
0050 % For indentation of algorithms
0051 \newlength{\algorithmicindent}
0052 \setlength{\algorithmicindent}{0pt}
0053 \define@key{ALG}{indent}{\setlength{\algorithmicindent}{#1}}
0054 \ifthenelse{\lengthtest{\algorithmicindent=0pt}}%
0055         {\setlength{\algorithmicindent}{1em}}{}
0056 %
0057 % For line numbers' delimiters
0058 \newcommand{\ALC@linenodelimiter}{:}
0059 \define@key{ALG}{linenodelimiter}{\renewcommand{\ALC@linenodelimiter}{#1}}
0060 %
0061 % For line numbers' size
0062 \newcommand{\ALC@linenosize}{\footnotesize}
0063 \define@key{ALG}{linenosize}{\renewcommand{\ALC@linenosize}{#1}}
0064 %
0065 % ALGORITHMIC
0066 \newcommand{\algorithmicrequire}{\textbf{Require:}}
0067 \newcommand{\algorithmicensure}{\textbf{Ensure:}}
0068 \newcommand{\algorithmiccomment}[1]{\{#1\}}
0069 \newcommand{\algorithmicend}{\textbf{end}}
0070 \newcommand{\algorithmicif}{\textbf{if}}
0071 \newcommand{\algorithmicthen}{\textbf{then}}
0072 \newcommand{\algorithmicelse}{\textbf{else}}
0073 \newcommand{\algorithmicelsif}{\algorithmicelse\ \algorithmicif}
0074 \newcommand{\algorithmicendif}{\algorithmicend\ \algorithmicif}
0075 \newcommand{\algorithmicfor}{\textbf{for}}
0076 \newcommand{\algorithmicforall}{\textbf{for all}}
0077 \newcommand{\algorithmicdo}{\textbf{do}}
0078 \newcommand{\algorithmicendfor}{\algorithmicend\ \algorithmicfor}
0079 \newcommand{\algorithmicwhile}{\textbf{while}}
0080 \newcommand{\algorithmicendwhile}{\algorithmicend\ \algorithmicwhile}
0081 \newcommand{\algorithmicloop}{\textbf{loop}}
0082 \newcommand{\algorithmicendloop}{\algorithmicend\ \algorithmicloop}
0083 \newcommand{\algorithmicrepeat}{\textbf{repeat}}
0084 \newcommand{\algorithmicuntil}{\textbf{until}}
0085 \newcommand{\algorithmicprint}{\textbf{print}}
0086 \newcommand{\algorithmicreturn}{\textbf{return}}
0087 \newcommand{\algorithmicand}{\textbf{and}}
0088 \newcommand{\algorithmicor}{\textbf{or}}
0089 \newcommand{\algorithmicxor}{\textbf{xor}}
0090 \newcommand{\algorithmicnot}{\textbf{not}}
0091 \newcommand{\algorithmicto}{\textbf{to}}
0092 \newcommand{\algorithmicinputs}{\textbf{inputs}}
0093 \newcommand{\algorithmicoutputs}{\textbf{outputs}}
0094 \newcommand{\algorithmicglobals}{\textbf{globals}}
0095 \newcommand{\algorithmicbody}{\textbf{do}}
0096 \newcommand{\algorithmictrue}{\textbf{true}}
0097 \newcommand{\algorithmicfalse}{\textbf{false}}
0098 \def\ALC@item[#1]{%
0099 \if@noparitem \@donoparitem
0100   \else \if@inlabel \indent \par \fi
0101          \ifhmode \unskip\unskip \par \fi
0102          \if@newlist \if@nobreak \@nbitem \else
0103                         \addpenalty\@beginparpenalty
0104                         \addvspace\@topsep \addvspace{-\parskip}\fi
0105            \else \addpenalty\@itempenalty \addvspace\itemsep
0106           \fi
0107     \global\@inlabeltrue
0108 \fi
0109 \everypar{\global\@minipagefalse\global\@newlistfalse
0110           \if@inlabel\global\@inlabelfalse \hskip -\parindent \box\@labels
0111              \penalty\z@ \fi
0112           \everypar{}}\global\@nobreakfalse
0113 \if@noitemarg \@noitemargfalse \if@nmbrlist \refstepcounter{\@listctr}\fi \fi
0114 \sbox\@tempboxa{\makelabel{#1}}%
0115 \global\setbox\@labels
0116  \hbox{\unhbox\@labels \hskip \itemindent
0117        \hskip -\labelwidth \hskip -\ALC@tlm
0118        \ifdim \wd\@tempboxa >\labelwidth
0119                 \box\@tempboxa
0120           \else \hbox to\labelwidth {\unhbox\@tempboxa}\fi
0121        \hskip \ALC@tlm}\ignorespaces}
0122 %
0123 \newenvironment{algorithmic}[1][0]{
0124 \setcounter{ALC@depth}{\@listdepth}%
0125 \let\@listdepth\c@ALC@depth%
0126 \let\@item\ALC@item%
0127   \newcommand{\ALC@lno}{%
0128 \ifthenelse{\equal{\arabic{ALC@rem}}{0}}
0129 {{\ALC@linenosize \arabic{ALC@line}\ALC@linenodelimiter}}{}%
0130 }
0131 \let\@listii\@listi
0132 \let\@listiii\@listi
0133 \let\@listiv\@listi
0134 \let\@listv\@listi
0135 \let\@listvi\@listi
0136 \let\@listvii\@listi
0137   \newenvironment{ALC@g}{
0138     \begin{list}{\ALC@lno}{ \itemsep\z@ \itemindent\z@
0139     \listparindent\z@ \rightmargin\z@
0140     \topsep\z@ \partopsep\z@ \parskip\z@\parsep\z@
0141     \leftmargin \algorithmicindent%1em
0142     \addtolength{\ALC@tlm}{\leftmargin}
0143     }
0144   }
0145   {\end{list}}
0146   \newcommand{\ALC@it}{%
0147     \stepcounter{ALC@rem}%
0148     \ifthenelse{\equal{\arabic{ALC@rem}}{#1}}{\setcounter{ALC@rem}{0}}{}%
0149     \stepcounter{ALC@line}%
0150     \refstepcounter{ALC@unique}%
0151     \item\def\@currentlabel{\theALC@line}%
0152   }
0153   \newcommand{\ALC@com}[1]{\ifthenelse{\equal{##1}{default}}%
0154 {}{\ \algorithmiccomment{##1}}}
0155   \newcommand{\REQUIRE}{\item[\algorithmicrequire]}
0156   \newcommand{\ENSURE}{\item[\algorithmicensure]}
0157   \newcommand{\PRINT}{\ALC@it\algorithmicprint{} \ }
0158   \newcommand{\RETURN}{\ALC@it\algorithmicreturn{} \ }
0159   \newcommand{\TRUE}{\algorithmictrue{}}
0160   \newcommand{\FALSE}{\algorithmicfalse{}}
0161   \newcommand{\AND}{\algorithmicand{} }
0162   \newcommand{\OR}{\algorithmicor{} }
0163   \newcommand{\XOR}{\algorithmicxor{} }
0164   \newcommand{\NOT}{\algorithmicnot{} }
0165   \newcommand{\TO}{\algorithmicto{} }
0166   \newcommand{\STATE}{\ALC@it}
0167   \newcommand{\STMT}{\ALC@it}
0168   \newcommand{\COMMENT}[1]{\algorithmiccomment{##1}}
0169   \newenvironment{ALC@inputs}{\begin{ALC@g}}{\end{ALC@g}}
0170   \newenvironment{ALC@outputs}{\begin{ALC@g}}{\end{ALC@g}}
0171   \newenvironment{ALC@globals}{\begin{ALC@g}}{\end{ALC@g}}
0172   \newenvironment{ALC@body}{\begin{ALC@g}}{\end{ALC@g}}
0173   \newenvironment{ALC@if}{\begin{ALC@g}}{\end{ALC@g}}
0174   \newenvironment{ALC@for}{\begin{ALC@g}}{\end{ALC@g}}
0175   \newenvironment{ALC@whl}{\begin{ALC@g}}{\end{ALC@g}}
0176   \newenvironment{ALC@loop}{\begin{ALC@g}}{\end{ALC@g}}
0177   \newenvironment{ALC@rpt}{\begin{ALC@g}}{\end{ALC@g}}
0178   \renewcommand{\\}{\@centercr}
0179   \newcommand{\INPUTS}[1][default]{\ALC@it\algorithmicinputs\ \ALC@com{##1}\begin{ALC@inputs}}
0180   \newcommand{\ENDINPUTS}{\end{ALC@inputs}}
0181   \newcommand{\OUTPUTS}[1][default]{\ALC@it\algorithmicoutputs\ \ALC@com{##1}\begin{ALC@outputs}}
0182   \newcommand{\ENDOUTPUTS}{\end{ALC@outputs}}
0183   \newcommand{\GLOBALS}{\ALC@it\algorithmicglobals\ }
0184   \newcommand{\BODY}[1][default]{\ALC@it\algorithmicbody\ \ALC@com{##1}\begin{ALC@body}}
0185   \newcommand{\ENDBODY}{\end{ALC@body}}
0186   \newcommand{\IF}[2][default]{\ALC@it\algorithmicif\ ##2\ \algorithmicthen%
0187 \ALC@com{##1}\begin{ALC@if}}
0188   \newcommand{\ELSE}[1][default]{\end{ALC@if}\ALC@it\algorithmicelse%
0189 \ALC@com{##1}\begin{ALC@if}}
0190   \newcommand{\ELSIF}[2][default]%
0191 {\end{ALC@if}\ALC@it\algorithmicelsif\ ##2\ \algorithmicthen%
0192 \ALC@com{##1}\begin{ALC@if}}
0193   \newcommand{\FOR}[2][default]{\ALC@it\algorithmicfor\ ##2\ \algorithmicdo%
0194 \ALC@com{##1}\begin{ALC@for}}
0195   \newcommand{\FORALL}[2][default]{\ALC@it\algorithmicforall\ ##2\ %
0196 \algorithmicdo%
0197 \ALC@com{##1}\begin{ALC@for}}
0198   \newcommand{\WHILE}[2][default]{\ALC@it\algorithmicwhile\ ##2\ %
0199 \algorithmicdo%
0200 \ALC@com{##1}\begin{ALC@whl}}
0201   \newcommand{\LOOP}[1][default]{\ALC@it\algorithmicloop%
0202 \ALC@com{##1}\begin{ALC@loop}}
0203   \newcommand{\REPEAT}[1][default]{\ALC@it\algorithmicrepeat%
0204 \ALC@com{##1}\begin{ALC@rpt}}
0205   \newcommand{\UNTIL}[1]{\end{ALC@rpt}\ALC@it\algorithmicuntil\ ##1}
0206   \ifthenelse{\boolean{ALC@noend}}{
0207     \newcommand{\ENDIF}{\end{ALC@if}}
0208     \newcommand{\ENDFOR}{\end{ALC@for}}
0209     \newcommand{\ENDWHILE}{\end{ALC@whl}}
0210     \newcommand{\ENDLOOP}{\end{ALC@loop}}
0211   }{
0212     \newcommand{\ENDIF}{\end{ALC@if}\ALC@it\algorithmicendif}
0213     \newcommand{\ENDFOR}{\end{ALC@for}\ALC@it\algorithmicendfor}
0214     \newcommand{\ENDWHILE}{\end{ALC@whl}\ALC@it\algorithmicendwhile}
0215     \newcommand{\ENDLOOP}{\end{ALC@loop}\ALC@it\algorithmicendloop}
0216   }
0217   \renewcommand{\@toodeep}{}
0218   \begin{list}{\ALC@lno}{\setcounter{ALC@rem}{0}\setcounter{ALC@line}{0}%
0219     \itemsep\z@ \itemindent\z@ \listparindent\z@%
0220     \partopsep\z@ \parskip\z@ \parsep\z@%
0221     \labelsep 0.5em \topsep 0.2em%
0222 \ifthenelse{\equal{#1}{0}}
0223   {\labelwidth 0.5em }
0224   {\labelwidth  1.2em }
0225 \leftmargin\labelwidth \addtolength{\leftmargin}{\labelsep}
0226     \ALC@tlm\labelsep
0227   }
0228 }
0229 {\end{list}}
0230 \endinput
0231 %%
0232 %% End of file `algorithmic.sty'.