summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/tex/latex/bardiag/barddoc.sty39
-rw-r--r--Master/texmf-dist/tex/latex/bardiag/bardiag.bar82
-rw-r--r--Master/texmf-dist/tex/latex/bardiag/bardiag.cfg126
-rw-r--r--Master/texmf-dist/tex/latex/bardiag/bardiag.sty699
-rw-r--r--Master/texmf-dist/tex/latex/bardiag/pstfp.sty1137
5 files changed, 2083 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/bardiag/barddoc.sty b/Master/texmf-dist/tex/latex/bardiag/barddoc.sty
new file mode 100644
index 00000000000..b7c7ca78b4c
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/bardiag/barddoc.sty
@@ -0,0 +1,39 @@
+\usepackage[a4paper,nohead]{geometry}
+\usepackage{bardiag}
+%\usepackage{showkeys}
+
+\usepackage{graphicx}
+\usepackage{subfigure}
+
+\usepackage{verbatim}
+
+\usepackage{makeidx}
+
+\usepackage{listings}
+
+\lstset{
+ %language=[LaTeX]TeX,
+ basicstyle=\small\ttfamily,
+ numbers=left,
+ numberstyle=\small,
+ stringstyle=\ttfamily,
+ commentstyle=\itshape,
+ stepnumber=1
+}
+
+%\usepackage{xr}
+%\externaldocument{bardiag2}
+
+
+\renewcommand \thefigure {\thesection.\arabic{figure}}
+\newcommand{\mysection}[1]{\section{{#1}}\setcounter{figure}{0}}
+%-------------------------------------------------------
+\newcommand{\barvers}{0.5 }
+
+\newcommand{\bard}{{ \texttt{bardiag} }}
+\newcommand{\pst}{{ \texttt{PSTricks} }}
+\newcommand{\figref}[1]{Fig.\ref{#1}}
+\newcommand{\pac}[1]{{\texttt{#1}}}
+
+\date{December 10, 2003}
+\author{R. Stepanyan\\rstepanyan@yahoo.com}
diff --git a/Master/texmf-dist/tex/latex/bardiag/bardiag.bar b/Master/texmf-dist/tex/latex/bardiag/bardiag.bar
new file mode 100644
index 00000000000..be523f105e2
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/bardiag/bardiag.bar
@@ -0,0 +1,82 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% bar primitives
+\newcommand{\barRect}[6][fillstyle=solid]
+{
+ {\psframe[linestyle=none,fillcolor=#6,#1](#2,#3)(#4,#5)}
+}
+% - - - - - -
+\newcommand{\xtd}{0}
+\newcommand{\ytd}{0}
+\newcommand{\xtda}{0}
+\newcommand{\ytda}{0}
+\newcommand{\xtdb}{0}
+\newcommand{\ytdb}{0}
+
+\newcommand{\barTDRect}[6][fillstyle=solid]
+{
+%
+ \psframe[linestyle=solid,fillcolor=#6,#1](#2,#3)(#4,#5)
+
+ % let's draw polygons: left and upper
+ % left-> (#4;#3)(#4+\bdar\tdhor;#3+\dbar\tdver)
+ % (#4+\dbar\tdhor;#5+\dbar\tdver)(#4;#5)
+ % right->(#4;#5)(#4+\dbar\tdhor;#5+\dbar\tdver)
+ % (#3+\dbar\tdhor;#5+\dbar\tdver)(#2;#3)
+ %
+
+ \FPmul{\xtd}{\dbar}{\tdhor}
+ \FPmul{\ytd}{\dbar}{\tdver}
+
+ \FPfadd{\xtda}{#2}{\xtd}
+ \FPfadd{\xtdb}{#4}{\xtd}
+ \FPfadd{\ytda}{#3}{\ytd}
+ \FPfadd{\ytdb}{#5}{\ytd}
+
+ \pspolygon[linestyle=solid,fillcolor=#6,#1](#4,#3)(\xtdb,\ytda)(\xtdb,\ytdb)(#4,#5)(#4,#3)
+ \pspolygon[linestyle=solid,fillcolor=#6,#1](#4,#5)(\xtdb,\ytdb)(\xtda,\ytdb)(#2,#5)(#4,#5)
+}
+
+\newcommand{\elRx}{0}
+\newcommand{\elRy}{0}
+\newcommand{\barCylinder}[6][none]
+{
+ \FPmul{\xtd}{\dbar}{\tdx}
+ \FPmul{\ytd}{\dbar}{\tdy}
+
+ \FPdiv{\elRx}{\dbar}{2}
+ \FPdiv{\elRy}{\ytd}{2}
+
+ \ifthenelse{\bdorientation = \bdvert}
+ {
+ \FPfadd{\tmpvar}{#2}{#4}
+ \FPdiv{\xtda}{\tmpvar}{2} % Xcenter of the bottom ellipse
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\ytda}{\tmpvar}{#3} % Ycenter of the bottom ellipse
+ % Draw the bottom ellipse
+ \psellipse[fillstyle=solid,fillcolor=#6](\xtda,\ytda)(\elRx,\elRy)
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\ytdb}{\tmpvar}{#5} % Ycenter of the top ellipse
+ % Draw the rectangle
+ \psframe[fillstyle=solid,fillcolor=#6,linecolor=#6](#2,\ytda)(#4,\ytdb)
+ \psline(#2,\ytda)(#2,\ytdb)
+ \psline(#4,\ytda)(#4,\ytdb)
+ % Draw the top ellipse
+ \psellipse[fillstyle=solid,fillcolor=#6](\xtda,\ytdb)(\elRx,\elRy)
+ }
+ { \FPfadd{\tmpvar}{#3}{#5}
+ \FPdiv{\ytda}{\tmpvar}{2}
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\xtda}{\tmpvar}{#2}
+ % Draw the left ellipse
+ \psellipse[fillstyle=solid,fillcolor=#6](\xtda,\ytda,)(\elRy,\elRx)
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\ytdb}{\tmpvar}{#4}
+ % Draw the rectangle
+ \psframe[fillstyle=solid,fillcolor=#6,linecolor=#6](\xtda,#3)(\ytdb,#5)
+ \psline(\xtda,#3)(\ytdb,#3)
+ \psline(\xtda,#5)(\ytdb,#5)
+ % Draw the right ellipse
+ \psellipse[fillstyle=solid,fillcolor=#6](\ytdb,\ytda)(\elRy,\elRx)
+ }
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/Master/texmf-dist/tex/latex/bardiag/bardiag.cfg b/Master/texmf-dist/tex/latex/bardiag/bardiag.cfg
new file mode 100644
index 00000000000..b5910c14424
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/bardiag/bardiag.cfg
@@ -0,0 +1,126 @@
+% New colors defined
+\definecolor{brown}{rgb}{.65, .16, .16}
+
+\definecolor{lightblue}{rgb}{.68, .85, .9}
+\definecolor{lightred}{rgb}{1.0, .65, .65}
+
+\definecolor{darkyellow}{rgb}{0.6, 0.6, 0.3}
+
+\definecolor{palegreen}{rgb}{.6, .98, .6}
+\definecolor{pink}{rgb}{1, .75, .8}
+\definecolor{wheat}{rgb}{.96, .87, .7}
+\definecolor{verylightgray}{gray}{0.95}
+
+
+\newcommand{\arrowheight}{\dbar}
+\newcommand{\arrowwidth}{\dbar}
+
+\newcommand{\ARbot}{0}
+\newcommand{\RECTmid}{0}
+\newcommand{\RECTwidth}{0.7} % 70% from \dbar
+\newcommand{\RECTleft}{0}
+\newcommand{\RECTright}{0}
+
+\newcommand{\mytempx}{0}
+\newcommand{\mytempxx}{0}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Additional bar primitives %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand{\barArrowRect}[6][fillstyle=solid]
+{\ifthenelse{\bdorientation = \bdvert}
+ {\FPfadd{\mytempx}{#2}{#4}
+ \FPdiv{\RECTmid}{\mytempx}{2}
+
+ \FPfsub{\ARbot}{#5}{\arrowheight}
+
+ \FPmul{\mytempx}{\dbar}{\RECTwidth}
+ \FPdiv{\mytempxx}{\mytempx}{2}
+ \FPfsub{\RECTleft}{\RECTmid}{\mytempxx}
+ \FPfadd{\RECTright}{\RECTmid}{\mytempxx}
+
+ \psframe[linestyle=none,fillcolor=#6,linecolor=#6,#1](\RECTleft,#3)(\RECTright,\ARbot)
+ \pspolygon[fillcolor=#6,linecolor=#6,#1](#2,\ARbot)(\RECTmid,#5)(#4,\ARbot)(#2,\ARbot)
+ }
+ {\FPfadd{\mytempx}{#3}{#5}
+ \FPdiv{\RECTmid}{\mytempx}{2}
+ \FPfsub{\ARbot}{#4}{\arrowheight}
+ \FPmul{\mytempx}{\dbar}{\RECTwidth}
+ \FPdiv{\mytempxx}{\mytempx}{2}
+ \FPfsub{\RECTleft}{\RECTmid}{\mytempxx}
+ \FPfadd{\RECTright}{\RECTmid}{\mytempxx}
+ \psframe[linestyle=none,fillcolor=#6,linecolor=#6,#1](#2,\RECTleft)(\ARbot,\RECTright)
+ \pspolygon[fillcolor=#6,linecolor=#6,#1](\ARbot,#3)(#4,\RECTmid)(\ARbot,#5)(\ARbot,#3)
+ }
+}
+%---------------------------------------
+\newcommand{\barGradRect}[6][fillstyle=gradient]
+{\ifthenelse{\bdorientation = \bdvert}
+ {\psframe[gradbegin=#6,gradend=white,gradmidpoint=1,gradangle=45,
+ fillstyle=gradient,linestyle=none,linecolor=#6](#2,#3)(#4,#5)
+ }
+ {\psframe[gradbegin=#6,gradend=white,gradmidpoint=1,gradangle=-45,
+ fillstyle=gradient,linestyle=none,linecolor=#6](#2,#3)(#4,#5)
+ }
+}
+
+\newcommand{\barGradMidRect}[6][fillstyle=gradient]
+{\ifthenelse{\bdorientation = \bdvert}
+ {\psframe[gradbegin=#6,gradend=white,gradmidpoint=0.3,gradangle=90,
+ fillstyle=gradient,linestyle=none,linecolor=#6](#2,#3)(#4,#5)
+ }
+ {\psframe[gradbegin=#6,gradend=white,gradmidpoint=0.3,gradangle=0,
+ fillstyle=gradient,linestyle=none,linecolor=#6](#2,#3)(#4,#5)
+ }
+}
+%---------------------------------------
+\newcommand{\barGradCylinder}[6][fillstyle=gradient]
+{ \FPmul{\xtd}{\dbar}{\tdx}
+ \FPmul{\ytd}{\dbar}{\tdy}
+
+ \FPdiv{\elRx}{\dbar}{2}
+ \FPdiv{\elRy}{\ytd}{2}
+
+ \ifthenelse{\bdorientation = \bdvert}
+ {
+ \FPfadd{\tmpvar}{#2}{#4}
+ \FPdiv{\xtda}{\tmpvar}{2} % Xcenter of the bottom ellipse
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\ytda}{\tmpvar}{#3} % Ycenter of the bottom ellipse
+ \newpsstyle{gradcylstyle}{gradbegin=#6,gradend=white,gradmidpoint=0.25,gradangle=90,fillstyle=gradient,linestyle=none,linecolor=#6}
+ % Draw the bottom ellipse
+ \psellipse[style=gradcylstyle](\xtda,\ytda)(\elRx,\elRy)
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\ytdb}{\tmpvar}{#5} % Ycenter of the top ellipse
+ % Draw the rectangle
+ \psframe[style=gradcylstyle](#2,\ytda)(#4,\ytdb)
+ % Draw the top ellipse
+ \psellipse[fillstyle=solid,fillcolor=#6,linecolor=#6](\xtda,\ytdb)(\elRx,\elRy)
+ }
+ { \FPfadd{\tmpvar}{#3}{#5}
+ \FPdiv{\ytda}{\tmpvar}{2}
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\xtda}{\tmpvar}{#2}
+ \newpsstyle{gradcylstyle}{gradbegin=#6,gradend=white,gradmidpoint=0.25,gradangle=0,fillstyle=gradient,linestyle=none,linecolor=#6}
+ % Draw the left ellipse
+ \psellipse[style=gradcylstyle](\xtda,\ytda,)(\elRy,\elRx)
+ \FPdiv{\tmpvar}{\ytd}{2}
+ \FPfadd{\ytdb}{\tmpvar}{#4}
+ % Draw the rectangle
+ \psframe[style=gradcylstyle](\xtda,#3)(\ytdb,#5)
+ % Draw the right ellipse
+ \psellipse[fillstyle=solid,fillcolor=#6,linecolor=#6](\ytdb,\ytda)(\elRy,\elRx)
+ }
+}
+%---------------------------------------
+\newcommand{\barCoil}[6][qq]
+{\ifthenelse{\bdorientation = \bdvert}
+ {\FPfadd{\mytempx}{#2}{#4}
+ \FPdiv{\RECTmid}{\mytempx}{2}
+ \pscoil[linecolor=#6,linewidth=3pt]{->}(\RECTmid,#3)(\RECTmid,#5)
+ }
+ {\FPfadd{\mytempx}{#3}{#5}
+ \FPdiv{\RECTmid}{\mytempx}{2}
+ \pscoil[linecolor=#5,linewidth=3pt]{->}(#2,\RECTmid)(#4,\RECTmid)
+ }
+}
diff --git a/Master/texmf-dist/tex/latex/bardiag/bardiag.sty b/Master/texmf-dist/tex/latex/bardiag/bardiag.sty
new file mode 100644
index 00000000000..2fad655f838
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/bardiag/bardiag.sty
@@ -0,0 +1,699 @@
+%% =============================================
+%% IMPORTANT NOTICE:
+%%
+%% This program can be redistributed and/or modified under the terms
+%% of the LaTeX Project Public License Distributed from CTAN
+%% archives in directory macros/latex/base/lppl.txt; either
+%% version 1 of the License, or any later version.
+%%
+%% Only a few abbreviated comments remain here to describe the usage.
+%% Documentation can be found in bardiag.ps or/and bardiag.tex files
+%% =============================================
+%% Copyright 2003 Roman Stepanyan
+%% E-mail: rstepanyan@yahoo.com
+
+
+%TODO
+% Error ``whiskers'': do NOT work with \subtopbaritem !!!!
+
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%
+\ProvidesPackage{bardiag}[2003/12/10 version 0.5]
+\def\bardiag{BagDiag}
+% This package allows to draw bar diagrams.
+% It is inspired by and build on top of PSTricks
+%
+%
+% Changelog
+% 2003/12/10 version 0.5 (compatible with 0.4, but "shapes"-macroses
+% (bars) have to accept an optional argument!)
+% "fillstyle" can be supplied to \baritem and friends
+% as an optional argument: \baritem[fillstyle=vlines*,linecolor=red]{}...
+% bardiag DOES NOT load pst-all anymore, only the necessary stuff
+% use \barspergroup{N} to make life easier (thanks to Kris Dumont)
+%
+%
+% 2003/06/29 version 0.4 (compatible with 0.3)
+% Error ``whiskers'' are added
+%
+% 2003/06/20 version 0.3 (compatible with 0.2)
+% ``Horizontal bars'' mode is added.
+%
+% 2003/05/23 version 0.2 (not compatible with 0.1)
+% Code is completely rewritten.
+% All parameters can be real numbers (not integers) thanks to fp.sty
+% A lot of changes in the interface.
+%
+% 2003/05/10 version 0.1
+% 0.first version :)
+
+
+\RequirePackage{calc}
+\RequirePackage{pstfp}
+\RequirePackage{fp-snap}
+
+
+\RequirePackage{pstricks}
+\RequirePackage{pstcol}
+\RequirePackage{pst-grad}
+\RequirePackage{multido}
+
+\RequirePackage{ifthen}
+
+% * what should be changed through \renewcommand or \setlength
+% @ arguments of functions
+% + internal variables
+
+
+%----------------------------------------
+% Horizontal or vertical bars
+\newcommand{\bdvert}{0}
+\newcommand{\bdhor}{1}
+\newcommand{\bdorientation}{\bdvert}
+
+% Each group is assumed to consist of this number of bars
+% (subtopbars not included)
+% use \barspergroup{N} to change
+\newcommand{\nbarsingroup}{1}
+\newcommand{\barspergroup}[1]{\renewcommand{\nbarsingroup}{#1}}
+% Sizes of the diag
+%
+\newcommand{\diagheight}{10} % units @
+\newcommand{\diagwidth}{10} % units @
+\newlength{\bottomheight} % cm @
+% units of length
+\newlength{\xunitlength} % cm @
+\newlength{\yunitlength} % cm @
+% of the bar
+\newcommand{\dbar}{1} % units @
+\newcommand{\dx}{2} % units @
+%-----------------------------------------
+% Sizes related to ticks and levellines
+%
+\newcommand{\betweenticks}{1} % units *
+\newcommand{\numberofticks}{1}% +
+\newcommand{\MAXnumberofticks}{20}% *
+%
+% frame and stuff
+\newlength{\ticklength} %
+\setlength{\ticklength}{2mm} % cm *
+\newlength{\leftshift}
+\setlength{\leftshift}{\ticklength+2mm}
+ % cm *
+\newlength{\frameXleft}
+\setlength{\frameXleft}{\leftshift}
+\newlength{\frameYbottom}
+\setlength{\frameYbottom}{0pt}
+\newlength{\tickrightedge} % cm +
+% text
+\newlength{\textoffset} %
+\setlength{\textoffset}{-0.2cm}%cm *
+%caption
+\newlength{\captionoffset}
+\setlength{\captionoffset}{1.5cm}
+%-----------------------------------------
+% ``Counter''-like variables for bars
+\newcommand{\xval}{1} % units +
+\newcommand{\xxval}{1} % units +
+\newcommand{\xhalf}{1} % units +
+%
+% and subbars
+\newcounter{subbar}
+%
+% Number on bars
+% numbers (0,1)
+\newcommand\shownumbers{1} % *
+ % otherwise no numbers will appear
+\newcommand\numbercolor{\black\bf} % *
+\newcommand{\belowtop}{0} % constant
+\newcommand{\overtop}{1} % constant
+\newcommand{\bottom}{2} % constant
+\newcommand\placenumber{\belowtop} % *
+ % can be: \belowtop, \overtop, \bottom
+\newlength{\numberoffset}
+\setlength{\numberoffset}{2\textoffset} % cm *
+\newlength{\lefttextoffset}
+\setlength{\lefttextoffset}{\leftshift+2mm} % cm *
+% Angle of the text written below (if vertical bars)
+% or to the left (if horizontal) of the item-bars
+\newcommand{\barlabelangle}{90} % *
+% The same, but for label next to the level line
+\newcommand{\ticklabelangle}{0} % *
+%----------------------------------------
+% Legend-related vars
+\newcommand{\legendShadow}{0} % *
+ % shadow color
+\definecolor{legShCol}{gray}{.5}
+\newcommand{\legendShadowColor}{legShCol} % *
+%----------------------------------------
+% 3D related stuff
+\newcommand{\frameTD}{0} % 3D or not frame % *
+\newcommand{\tdx}{0.4} % depth of 3d % *
+\newcommand{\tdy}{1.0} % *
+\newcommand{\tdhor}{\tdx} % +
+\newcommand{\tdver}{\tdy} % +
+%-----------------------------------------
+% Error ``whiskers''
+\newcommand{\barerrorterm}{*-|} % *
+\newpsstyle{barerrorstyle}{linewidth=2pt,linecolor=black}
+%-----------------------------------------
+% Styles
+\definecolor{frameBGgray}{gray}{0.9}
+\newpsstyle{diagframestyle}{linewidth=1pt,linecolor=black,fillstyle=none}
+\newpsstyle{tickstyle}{linewidth=1pt,linecolor=black}
+\newpsstyle{levellinestyle}{linewidth=0.2pt,linecolor=blue}
+\newpsstyle{diagTDframestyle}{linewidth=1pt,linecolor=black,fillstyle=none}
+\newpsstyle{diagbgframestyle}{linewidth=1pt,linecolor=black,fillcolor=frameBGgray}
+%-----------------------------------------
+\newcommand{\tmpvar}{1}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Commands to begin a bar diagram
+% \bardiagbegin -> flat frame
+% \bardiagTDbegin -> 3D frame
+\newlength{\bgx} % +
+\newlength{\bgy} % +
+\newlength{\bgxa} % +
+\newlength{\bgya} % +
+%
+\newcommand{\bardiagrambegin}[7]
+{ % 1 2 3 4 5 6 7
+ % width, height,bottom(cm), dbar, dx, xunit, yunit
+ % height(#1) and width(#2) can be any real numbers,
+ % they are in units of (#6) & (#7)
+
+ \renewcommand{\nbarsingroup}{1}
+
+ % Default \tdy is 5% from the height of the diag
+ \FPdiv{\tmpvar}{#2}{\dbar}%
+ \FPmul{\tdy}{0.05}{\tmpvar}%
+ %
+ \ifthenelse{\bdorientation = \bdvert}%
+ { \renewcommand{\diagheight}{#2}%
+ \renewcommand{\diagwidth}{#1}%
+ \setlength{\bottomheight}{#3}%
+ \renewcommand{\dbar}{#4}%
+ \renewcommand{\dx}{#5}%
+ \setlength{\xunitlength}{#6}%
+ \setlength{\yunitlength}{#7}%
+ %
+ \renewcommand{\tdhor}{\tdx}%
+ \renewcommand{\tdver}{\tdy}%
+ %
+ \setlength{\frameXleft}{\leftshift}
+ \setlength{\frameYbottom}{0pt}
+ %
+ \renewcommand{\barlabelangle}{90}
+ %\renewcommand{\ticklabelangle}{0}
+ }%
+ { \renewcommand{\diagheight}{#1}%
+ \renewcommand{\diagwidth}{#2}%
+ \setlength{\bottomheight}{#3}%
+ \renewcommand{\dbar}{#4}%
+ \renewcommand{\dx}{#5}%
+ \setlength{\xunitlength}{#7}%
+ \setlength{\yunitlength}{#6}%
+ %
+ \renewcommand{\tdhor}{\tdy}%
+ \renewcommand{\tdver}{\tdx}%
+ %
+ \setlength{\frameXleft}{0pt}
+ \setlength{\frameYbottom}{\leftshift}
+ %
+ \renewcommand{\barlabelangle}{0}
+ %\renewcommand{\ticklabelangle}{0}
+ }%
+ %
+ %- - - - - - - - - - - - - - - - - - - -
+ % Take care of ticks (not to draw)
+ \ifthenelse{\bdorientation = \bdvert}%
+ { \FPdiv{\tmpvar}{\diagheight}{\betweenticks}}%
+ { \FPdiv{\tmpvar}{\diagwidth}{\betweenticks}}%
+ \FPtrunc{\numberofticks}{\tmpvar}{0}%
+ \ifthenelse{\numberofticks > \MAXnumberofticks}%
+ { \typeout{----- \bardiag WARNING: }%
+ \typeout{Too LARGE number of ticks: \numberofticks. Falling back to \MAXnumberofticks.}%
+ \typeout{TIP: try to change the betweenticks parameter.}%
+ \typeout{If you DO want such a large number of ticks,}%
+ \typeout{change the MAXnumberofticks parameter.}%
+ \typeout{Ignore this warning if you do not use ticks.}%
+ \typeout{-----}%
+ \renewcommand{\numberofticks}{\MAXnumberofticks}%
+ \FPdiv{\betweenticks}{\diagheight}{\numberofticks}%
+ }%
+ {}%
+ %- - - - - - - - - - - - - - - - - - - -
+ % Compute center of the diagram
+ \FPdiv{\hordiagcenter}{\diagwidth}{2}%
+ \FPdiv{\vertdiagcenter}{\diagheight}{2}%
+ %
+ %- - - - - - - - - - - - - - - - - - - -
+ %
+ \psset{xunit=\xunitlength,yunit=\yunitlength}%
+ \ifthenelse{\frameTD = 0}
+ {\begin{pspicture}(-\captionoffset,-\bottomheight)(\diagwidth,\diagheight)}
+ {\setlength{\bgya}{\yunitlength*\real{\diagheight}+\yunitlength*\real{\dbar}*\real{\tdver}}
+ \begin{pspicture}(-\captionoffset,-\bottomheight)(\diagwidth,\bgya)
+ }
+ %\showgrid %#For debug purposes
+ \psset{fillstyle=solid}%
+ \renewcommand{\xval}{0}%
+ \setlength{\tickrightedge}{-\leftshift+\ticklength}%
+ \ifthenelse{\frameTD = 0}%
+ {\renewcommand{\legendShadow}{0}%
+ % let's draw a frame
+ \psframe[style=diagframestyle](-\frameXleft,-\frameYbottom)(\diagwidth,\diagheight)%
+ }%
+ {\renewcommand{\legendShadow}{1}%
+ % background frame
+ \setlength{\bgx}{-\frameXleft+\xunitlength*\real{\dbar}*\real{\tdhor}}%
+ \setlength{\bgxa}{\frameXleft+\bgx+\xunitlength*\real{\diagwidth}}%
+ \setlength{\bgy}{\yunitlength*\real{\dbar}*\real{\tdver}-\frameYbottom}%
+ \setlength{\bgya}{\bgy+\yunitlength*\real{\diagheight}+\frameYbottom}
+ % let's draw it
+ \psframe[style=diagbgframestyle](\bgx,\bgy)(\bgxa,\bgya)%
+ \psline(-\frameXleft,\diagheight)(\bgx,\bgya)%
+ \psline(-\frameXleft,-\frameYbottom)(\bgx,\bgy)%
+ \psline(\diagwidth,-\frameYbottom)(\bgxa,\bgy)%
+ \psline(\diagwidth,\diagheight)(\bgxa,\bgya)%
+ % let's draw the foreground frame
+ \psframe[style=diagTDframestyle](-\frameXleft,-\frameYbottom)(\diagwidth,\diagheight)%
+ }%
+}%
+% - - - - - - - - - - - - - - - - - -
+\newcommand{\bardiagramend}[2]
+{ \ifthenelse{\frameTD = 1}
+ { % let's draw the frame ones again
+ \psframe[style=diagTDframestyle](-\frameXleft,-\frameYbottom)(\diagwidth,\diagheight)
+ }{}
+ \ifthenelse{\bdorientation = \bdvert}
+ { \rput[c](\hordiagcenter,-0.9\bottomheight){{#1}}
+ \rput[c]{90}(-\captionoffset,\vertdiagcenter){{#2}} % ???? -2cm ?
+ }
+ { \rput[c](\hordiagcenter,-0.9\bottomheight){{#2}}
+ \rput[c]{90}(-\captionoffset,\vertdiagcenter){{#1}} % ???? -2cm ?
+ }
+ \end{pspicture}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% BARITEMS:
+\newcommand{\ActiveBarPrimitive}{\barRect}
+
+\newcommand{\subtopx}{0}
+\newcommand{\subtopy}{0}
+
+\newcommand{\baritem}[4][fillstyle=solid]{%
+ % the first (optional) argument is "psstyle options": default=solid
+ % [style], name, value, color
+ %
+ % \xval and \xxval are left and right edges of a bar
+ % \xhalf is its center
+ %
+ \FPfadd{\xxval}{\xval}{\dbar}
+ \FPfadd{\tmpvar}{\xval}{\xxval}
+ \FPdiv{\xhalf}{\tmpvar}{2}% ?????????? Get rid of it?
+
+
+ %
+ % Now we call smth, which draws a ``bar''
+ % it can be rectangular, cylindrical, 2 or 3d - we do not know
+ % I plan \barRect; \barTDRect; \barCylinder; more???
+ % It takes 5 arguments:
+ % \something{\xval}{\yval}{\xxval}{\yyval}{color}
+ %
+ %
+ \ifthenelse{\bdorientation = \bdvert}%is it vertical or horizontal?
+ {\ActiveBarPrimitive[#1]{\xval}{0}{\xxval}{#3}{#4}}%
+ {\ActiveBarPrimitive[#1]{0}{\xval}{#3}{\xxval}{#4}}%
+ %
+ %
+ \printnumber{\xhalf}{#3}{0}{#3}
+ %
+ \FPset{\subtopx}{\xval}
+ \FPset{\subtopy}{#3}
+ %
+ \FPfadd{\tmpvar}{\xval}{\dx}
+ \FPset{\xval}{\tmpvar}
+ %
+ % \xhalf := \xhalf + \dbar * (\nbarsingroup - 1)/2
+
+ \FPfsub{\tmpvar}{\nbarsingroup}{1}
+ \FPdiv{\tmpvar}{\tmpvar}{2}
+ \FPmul{\tmpvar}{\tmpvar}{\dbar}
+ \FPfadd{\xhalf}{\xhalf}{\tmpvar}
+
+ \ifthenelse{\bdorientation = \bdvert}%is it vertical or horizontal?
+ {\printbarlabel{\xhalf}{\textoffset}{\barlabelangle}{#2}}%
+ {\printbarlabel{\textoffset}{\xhalf}{\barlabelangle}{#2}}%
+ \setcounter{subbar}{1}
+}
+
+\newcommand{\barmidx}{0}
+\newcommand{\barerrormargins}[2] % To make asymmetric margins
+% 1st = upper Dy; 2nd = bottom Dy
+{%
+ \ifthenelse{\bdorientation = \bdvert}%is it vertical or horizontal?
+ { \FPdiv{\tmpvar}{\dbar}{2}
+ \FPfadd{\barmidx}{\subtopx}{\tmpvar}
+ \FPfadd{\tmpvar}{\subtopy}{#1}
+ \psline[style=barerrorstyle]{\barerrorterm}(\barmidx,\subtopy)(\barmidx,\tmpvar)
+ %
+ \FPdiv{\tmpvar}{\dbar}{2}
+ \FPfadd{\barmidx}{\subtopx}{\tmpvar}
+ \FPfsub{\tmpvar}{\subtopy}{#2}
+ \psline[style=barerrorstyle]{\barerrorterm}(\barmidx,\subtopy)(\barmidx,\tmpvar)
+ }
+ { \FPdiv{\tmpvar}{\dbar}{2}
+ \FPfadd{\barmidx}{\subtopx}{\tmpvar}
+ \FPfadd{\tmpvar}{\subtopy}{#1}
+ \psline[style=barerrorstyle]{\barerrorterm}(\subtopy,\barmidx)(\tmpvar,\barmidx)
+ %
+ \FPdiv{\tmpvar}{\dbar}{2}
+ \FPfadd{\barmidx}{\subtopx}{\tmpvar}
+ \FPfsub{\tmpvar}{\subtopy}{#2}
+ \psline[style=barerrorstyle]{\barerrorterm}(\subtopy,\barmidx)(\tmpvar,\barmidx)
+ }
+}
+%%%%%%%%%%%%%
+\newcommand{\barerror}[1] % To make symmetric margins
+{
+ \barerrormargins{#1}{#1}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% SUBITEMS
+\newcommand{\subxval}{0}
+\newcommand{\subxxval}{0}
+
+
+\newcommand{\subbaritem}[4][fillstyle=solid]{
+ % [style], name, value, color
+ %
+ % \subxval and \subxxval are left and right edges of a bar
+ % \subxhalf is its center
+ %
+ \FPfsub{\subxxval}{\xval}{\dx}
+ \FPmul{\tmpvar}{\dbar}{\thesubbar}
+ \FPfadd{\subxval}{\subxxval}{\tmpvar}
+
+ \FPfadd{\subxxval}{\subxval}{\dbar}
+
+ \FPfadd{\tmpvar}{\subxval}{\subxxval}
+ \FPdiv{\subxhalf}{\tmpvar}{2}% ?????????? Get rid of it?
+ %
+ % Now we call smth, which draws a ``bar''
+ % it can be rectangular, cylindrical, 2 or 3d - we do not know
+ % I plan \barRect; \barTDRect; \barCylinder; ???
+ % It takes 5 arguments:
+ % \something{\xval}{\yval}{\xxval}{\yyval}{color}
+ %
+ \ifthenelse{\bdorientation = \bdvert}%is it vertical or horizontal?
+ {\ActiveBarPrimitive[#1]{\subxval}{0}{\subxxval}{#3}{#4}}%
+ {\ActiveBarPrimitive[#1]{0}{\subxval}{#3}{\subxxval}{#4}}%
+ %
+ %
+ \printnumber{\subxhalf}{#3}{0}{#3}
+
+ \FPset{\subtopx}{\subxval}
+ \FPset{\subtopy}{#3}
+
+ %\rput[r]{90}(\subxhalf,\textoffset){#2}
+ \ifthenelse{\bdorientation = \bdvert}%is it vertical or horizontal?
+ {\printbarlabel{\subxhalf}{\textoffset}{\barlabelangle}{#2}}%
+ {\printbarlabel{\textoffset}{\subxhalf}{\barlabelangle}{#2}}%
+ \addtocounter{subbar}{1}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% TOP SUBITEMS
+
+\newcommand{\subtopxx}{0} % +
+\newcommand{\subtopyy}{0} % +
+\newcommand{\subtopxhalf}{0}% +
+
+\newcommand{\subtopbaritem}[4][fillstyle=solid]{
+ % [style], name, value, color
+ %
+ %
+ % \subtopxhalf is the center
+ %
+ \FPfadd{\subtopxx}{\subtopx}{\dbar}
+
+ \FPfadd{\subtopyy}{\subtopy}{#3}
+
+ \FPfadd{\tmpvar}{\subtopx}{\subtopxx}
+ \FPdiv{\subtopxhalf}{\tmpvar}{2}%
+ %
+ \ifthenelse{\bdorientation = \bdvert}%is it vertical or horizontal?
+ {\ActiveBarPrimitive[#1]{\subtopx}{\subtopy}{\subtopxx}{\subtopyy}{#4}}%
+ {\ActiveBarPrimitive[#1]{\subtopy}{\subtopx}{\subtopyy}{\subtopxx}{#4}}%
+ %
+ %
+ \printnumber{\subtopxhalf}{#3}{\subtopy}{\subtopyy}
+ %
+ % it is not supposed to print any label, so,
+ % we do not need to tae care of it.
+ %\rput[r]{90}(\subxhalf,\textoffset){#1}
+ %\addtocounter{subbar}{1}
+ %
+ \FPset{\subtopy}{\subtopyy}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Bar primitives
+\input{bardiag.bar}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Legend
+\newlength{\legendXo} % this one is an argument of diagLegendbegin
+\newlength{\legendYo} % the same
+\newlength{\legendWidth} % the same
+\newlength{\legendHeight} % this will be computed
+%
+\newlength{\legenditemheight}\setlength{\legenditemheight}{7mm}
+\newlength{\legendspacer}\setlength{\legendspacer}{3mm}
+\newlength{\legendRectWidth}\setlength{\legendRectWidth}{6mm}
+\newlength{\legendRectHeight}\setlength{\legendRectHeight}{4mm}
+%
+\newcommand{\diagLegendoptions}[3]
+{ % 1 2 3
+ % bgcolor framecolor framelinewidth
+ \newpsstyle{diagLegenditemstyle}{fillstyle=solid,fillcolor=#1,linecolor=#1}
+ \newpsstyle{diagLegendframetyle}{fillstyle=none,linecolor=#2,linewidth=#3}
+}
+%First we call \diagLegendoptions
+\diagLegendoptions{white}{black}{0.5pt}
+%
+\newlength{\lixcoor}
+\newlength{\liycoor}
+\newlength{\lixxcoor}
+\newlength{\liyycoor}
+%
+\newlength{\liix} % where to put the rectangle with color
+\newlength{\liiix} % where to put the text
+%
+\newcommand{\diagLegendbegin}[3]
+{% 1 2 3
+ % Xo(units) Yo(un) Width(un)
+ % (Xo,Yo) are coordinates of the left-up corner
+ \ifthenelse{\bdorientation = \bdvert}%
+ {
+ \setlength{\legendXo}{\xunitlength*\real{#1}}
+ \setlength{\legendYo}{\yunitlength*\real{#2}}
+ \setlength{\legendWidth}{\xunitlength*\real{#3}}
+ \setlength{\legendHeight}{0cm}
+ %
+ \setlength{\lixcoor}{\legendXo}
+ \setlength{\lixxcoor}{\legendXo+\legendWidth}
+ \setlength{\liycoor}{\legendYo}
+ %
+ \setlength{\liix}{\lixcoor+\legendspacer}
+ \setlength{\liiix}{\liix+\legendRectWidth+\legendspacer}
+ }
+ {
+ \setlength{\legendXo}{\xunitlength*\real{#2}}
+ \setlength{\legendYo}{\yunitlength*\real{#1}}
+ \setlength{\legendWidth}{\yunitlength*\real{#3}}
+ \setlength{\legendHeight}{0cm}
+ %
+ \setlength{\lixcoor}{\legendXo}
+ \setlength{\lixxcoor}{\legendXo+\legendWidth}
+ \setlength{\liycoor}{\legendYo}
+ %
+ \setlength{\liix}{\lixcoor+\legendspacer}
+ \setlength{\liiix}{\liix+\legendRectWidth+\legendspacer}
+ }
+}
+
+\newlength{\lShX}
+\newlength{\lShXxx}
+\newlength{\lShY}
+\newlength{\lShYyy}
+
+\newcommand{\diagLegendend}
+{ \ifthenelse{\legendShadow = 1}
+ {\setlength{\lShX}{\legendXo+\xunitlength*\dbar*\real{\tdhor}}
+ \setlength{\lShXxx}{\lixxcoor+\xunitlength*\dbar*\real{\tdhor}}
+ \setlength{\lShY}{\liycoor+\yunitlength*\dbar*\real{\tdver}}
+ \setlength{\lShYyy}{\legendYo+\yunitlength*\dbar*\real{\tdver}}
+ \psframe[fillstyle=solid,linecolor=\legendShadowColor,fillcolor=\legendShadowColor](\lShX,\legendYo)(\lShXxx,\lShYyy)
+ \psframe[fillstyle=solid,linecolor=\legendShadowColor,fillcolor=\legendShadowColor](\lixxcoor,\lShY)(\lShXxx,\lShYyy)
+ }
+ {}
+ \psframe[style=diagLegendframetyle](\legendXo,\liycoor)(\lixxcoor,\legendYo)
+}
+
+
+\newlength{\legendRectXo}
+\newlength{\legendRectX}
+\newlength{\legendRectYo}
+\newlength{\legendRectY}
+%
+\newcommand{\legendPutRect}[2][fillstyle=solid]
+{
+ \setlength{\legendRectXo}{\liix}
+ \setlength{\legendRectYo}{(\liyycoor+\liycoor-\legendRectHeight)/2}
+ %\setlength{\legendRectYo}{(\liyycoor+\liycoor)/2-\legendRectHeight}
+ \setlength{\legendRectX}{\legendRectXo+\legendRectWidth}
+ \setlength{\legendRectY}{\legendRectYo+\legendRectHeight}
+ \psframe[fillcolor=#2,#1](\legendRectXo,\legendRectYo)(\legendRectX,\legendRectY)
+}
+
+
+\newlength{\legendiyc}
+\newcommand{\diagLegenditem}[3][fillstyle=solid]
+{% [1] 2 3
+ % style item_text color
+ \addtolength{\legendHeight}{\legenditemheight}
+ \setlength{\liyycoor}{\liycoor}
+ \addtolength{\liycoor}{-\legenditemheight}
+ \psframe[style=diagLegenditemstyle](\lixcoor,\liycoor)(\lixxcoor,\liyycoor)
+ \legendPutRect[#1]{#3}
+ \setlength{\legendiyc}{(\liycoor+\liyycoor)/2}
+ \rput[l](\liiix,\legendiyc){#2}
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Util
+\newcommand{\outputparameters}
+{\rput[lt](0,-2\bottomheight){\parbox{10cm}{
+ \begin{tabular}{p{5cm}p{5cm}}
+ Width: & \diagwidth \\\hline
+ Height: &\diagheight \\\hline
+ Width of a bar:& \dx \\\hline
+ Distance between bars:& \dbar\\\hline\hline
+ %X unit length: & \ratio{\xunitlength}{1cm}\\\hline
+ %Y unit length: & \ratio{\yunitlength}{1cm}\\\hline
+ TICKS:\\
+ Between ticks: & \betweenticks\\
+ Number of ticks:&\numberofticks (computed)\\ \hline\hline
+ LAST VALS:\\
+ xval: & \xval\\
+ dbar: & \dbar\\
+ xxval:& \xxval\\
+ xhalf:& \xhalf\\
+ tmpvar:&\tmpvar\\
+ \end{tabular}}}
+}
+%--------------------------------------------------------------------
+
+\newlength{\ycoordnum}
+%
+\newcommand\printnumber[4]
+{ % 1 2 3 4
+ % center of the bar, text(number) (will be centered), bottom y, top y
+ %
+ % we compute the y-position of the text depending on
+ % the value of the \placenumber parameter
+ % it can be: \belowtop, \overtop, \bottom
+\ifthenelse{\bdorientation = \bdvert}
+{
+ \ifthenelse{\placenumber = \overtop}
+ {\setlength{\ycoordnum}{\yunitlength*\real{#4}-\numberoffset}
+ \ifthenelse{\shownumbers = 1}
+ {\rput[bc](#1,\ycoordnum){\numbercolor #2}}{}
+ }
+ {%else
+ \ifthenelse{\placenumber = \bottom}
+ {\setlength{\ycoordnum}{\yunitlength*\real{#3}-\numberoffset}
+ \ifthenelse{\shownumbers = 1}
+ {\rput[bc](#1,\ycoordnum){\numbercolor #2}}
+ {}
+ }
+ % default->\belowtop
+ {\setlength{\ycoordnum}{{\yunitlength*\real{#4}}+\numberoffset}
+ \ifthenelse{\shownumbers = 1 \AND \lengthtest{\ycoordnum > -\numberoffset}}
+ {\rput[tc](#1,\ycoordnum){\numbercolor #2}}{}
+ }
+ }
+}
+{%else, i.e. if it is horisontal
+ %if fact, ``y-coordinate'' \ycoordnum is now along the horizontal axis
+ \ifthenelse{\placenumber = \overtop}
+ {
+ \setlength{\ycoordnum}{\xunitlength*\real{#4}-\numberoffset}
+ \ifthenelse{\shownumbers = 1}
+ {\rput[l](\ycoordnum,#1){\numbercolor #2}}{}
+ }
+ {%else
+ \ifthenelse{\placenumber = \bottom}
+ {\setlength{\ycoordnum}{\xunitlength*\real{#3}-\numberoffset}
+ \ifthenelse{\shownumbers = 1}
+ {\rput[l](\ycoordnum,#1){\numbercolor #2}}
+ {}
+ }
+ % default->\belowtop
+ {\setlength{\ycoordnum}{{\xunitlength*\real{#4}}+\numberoffset}
+ \ifthenelse{\shownumbers = 1 \AND \lengthtest{\ycoordnum > -\numberoffset}}
+ {\rput[r](\ycoordnum,#1){\numbercolor #2}}{}
+ } %\rput[tc](\ycoordnum,#1){\numbercolor #2}
+ }
+}
+}
+%--------------------------------------------------------------------
+
+\newlength{\ytick}
+\newcommand{\whattoprint}{0}
+%
+\newcommand{\drawlevellines}
+{\ifthenelse{\bdorientation = \bdvert}
+ {\rput[c]{\ticklabelangle}(-\lefttextoffset,0){0}}% this is 0
+ {\rput[c]{\ticklabelangle}(0,-\lefttextoffset){0}}
+ % let's draw ticks; then lines;
+ % they are controlled by \betweenticks variable
+ % on its basis we have computed \numberofticks above (in \diagbegin)
+ %
+ \multido{\n=1+1}{\numberofticks}{%
+ \ifthenelse{\bdorientation = \bdvert}
+ {\setlength{\ytick}{\yunitlength*\real{\betweenticks}*\n}
+ % tick itself
+ \psline[style=tickstyle](-\leftshift,\ytick)(\tickrightedge,\ytick)
+ % level lines
+ \psline[style=levellinestyle](\tickrightedge,\ytick)(\diagwidth,\ytick)
+ % numbers!
+ \FPmul{\whattoprint}{\n}{\betweenticks}
+ \FPclip{\whattoprint}{\whattoprint}
+ \rput[r](-\lefttextoffset,\ytick){\whattoprint}
+ }
+ {\setlength{\ytick}{\xunitlength*\real{\betweenticks}*\n}
+ \psline[style=tickstyle](\ytick,-\leftshift)(\ytick,\tickrightedge)
+ \psline[style=levellinestyle](\ytick,\tickrightedge)(\ytick,\diagheight)
+ \FPmul{\whattoprint}{\n}{\betweenticks}
+ \FPclip{\whattoprint}{\whattoprint}
+ \rput[c](\ytick,-\lefttextoffset){\whattoprint}
+ }
+ }
+}
+%- - - - - - - - - - - - - - - - - - - -
+\newcommand{\printbarlabel}[4]{
+ % x, y, angle, text
+ \ifthenelse{ #3 = 0 \AND \bdorientation = \bdvert}
+ {\rput[tc]{#3}(#1,#2){{#4}}}
+ {\rput[r]{#3}(#1,#2){{#4}}}
+}
+%--------------------------------------------------------------------
+%
+\InputIfFileExists{bardiag.cfg}
+ {\typeout{BarDiag: Local configuration file bardiag.cfg loaded}}
+ {\typeout{BarDiag: No local configuration loaded}}
+%
+%--------------------------------------------------------------------
diff --git a/Master/texmf-dist/tex/latex/bardiag/pstfp.sty b/Master/texmf-dist/tex/latex/bardiag/pstfp.sty
new file mode 100644
index 00000000000..a7785ac7dcd
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/bardiag/pstfp.sty
@@ -0,0 +1,1137 @@
+% This is (almost) exact copy of
+% fp-basic.sty package (Michael Mehlich)
+%
+% It is patched to work with multido.sty
+% FPadd -> FPfadd
+% FPsub -> FPfsub
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pstfp}[2003/05/10]
+
+
+
+%version information
+\def\FP@basicversion{1.2d}
+\message{%
+ `(Patched) Basic Fixed Point Arithmetic',\space\space%
+
+ Version \FP@basicversion%
+ \space(C) Michael Mehlich%
+
+ \space Patched by R. Stepanyan%
+ \space\space\space\space\space\space\space%
+ \space\space\space\space\space\space%
+}
+
+%fixed point arithmetic with values between (including)
+% -999999999999999999.999999999999999999
+% and +999999999999999999.999999999999999999
+
+
+% to suppress messages
+\let\FP@save@message\message
+\def\message#1{}
+
+
+%%%public area (macros which may be used)%%%
+
+%introduce and print new values
+\def\FPset#1#2{\FP@set[#1|#2]}
+\def\FPprint#1{\FP@print[#1]}
+
+%binary operations
+\def\FPfadd#1#2#3{\FP@callc\FP@add#1{#2}{#3}+\relax} % #1 := #2+#3
+\def\FPdiv#1#2#3{\FP@callc\FP@div#1{#2}{#3}} % #1 := #2/#3
+\def\FPmul#1#2#3{\FP@callc\FP@mul#1{#2}{#3}} % #1 := #2*#3
+\def\FPfsub#1#2#3{\FP@callc\FP@add#1{#2}{-#3}-\relax}% #1 := #2-#3
+%unary operations
+\def\FPabs#1#2{\FP@calld\FP@abs#1{#2}} % #1 := abs(#2)
+\def\FPneg#1#2{\FP@calld\FP@neg#1{#2}} % #1 := -#2
+\def\FPsgn#1#2{\FP@calld\FP@sgn#1{#2}} % #1 := sgn(#2)
+%binary relations
+\def\FPiflt#1#2{\FP@callb\FP@iflt{#1}{#2}+\relax} % #1 < #2 ?
+\def\FPifeq#1#2{\FP@callb\FP@ifeq{#1}{#2}} % #1 = #2 ?
+\def\FPifgt#1#2{\FP@callb\FP@iflt{#2}{#1}-\relax} % #1 > #2 ?
+%unary relations
+\def\FPifneg#1{\FP@calla\FP@ifneg{#1}} % #1 < 0 ?
+\def\FPifpos#1{\FP@calla\FP@ifpos{#1}} % #1 >= 0 ?
+\def\FPifzero#1{\FP@calla\FP@ifzero{#1}} % #1 = 0 ?
+\def\FPifint#1{\FP@calla\FP@ifint{#1}} % #1 is integer ?
+%repeat last test
+%\ifFPtest % repeat last test
+
+%%%private fp-area (don't use these macros)%%%
+
+% To debug FP functions (enable intermediate messages on computations)
+\newif\ifFPdebug
+\FPdebugfalse
+\def\FP@debug#1{\ifFPdebug\typeout{FP debug: #1}\fi}
+
+%conditional printing of messages (only if \FPmessagestrue defined)
+\newif\ifFPmessages
+\FPmessagestrue
+\def\FP@beginmessage#1{\ifFPmessages\message{( FP-#1}\fi}
+\def\FP@endmessage#1{\ifFPmessages\message{)}\fi}
+\def\FP@errmessage#1{\errmessage{FP error: #1!}}
+\def\FP@warnmessage#1{\message{FP warning: #1!}}
+
+%allocation of registers
+
+\countdef\FP@actcounter=10 % register 0 for counter
+\ifnum\FP@actcounter<60\relax%
+ \FP@actcounter=60%
+\fi
+
+\newcount\FP@xs %sign of 1st value
+\newcount\FP@xia%integer part of 1st value
+\newcount\FP@xib%integer part of 1st value
+\newcount\FP@xfa%fractional part of 1st value
+\newcount\FP@xfb%fractional part of 1st value
+
+\countdef\FP@ys=5 %sign of 2nd value
+\countdef\FP@yia=6%integer part of 2nd value
+\countdef\FP@yib=7%integer part of 2nd value
+\countdef\FP@yfa=8%fractional part of 2nd value
+\countdef\FP@yfb=9%fractional part of 2nd value
+
+\countdef\FP@xk=10 %registers for splitting 1st value
+\countdef\FP@xl=11
+\countdef\FP@xm=12
+\countdef\FP@xn=13
+\countdef\FP@xo=14
+\countdef\FP@xp=15
+\countdef\FP@xq=16
+\countdef\FP@xr=17
+\countdef\FP@xz=18
+\countdef\FP@xt=19
+\countdef\FP@xu=20
+\countdef\FP@xv=21
+
+\countdef\FP@yk=22 %registers for splitting 2nd value
+\countdef\FP@yl=23
+\countdef\FP@ym=24
+\countdef\FP@yn=25
+\countdef\FP@yo=26
+\countdef\FP@yp=27
+\countdef\FP@yq=28
+\countdef\FP@yr=29
+\countdef\FP@yz=30
+\countdef\FP@yt=31
+\countdef\FP@yu=32
+\countdef\FP@yv=33
+
+\newcount\FP@rega %auxiliary registers
+\newcount\FP@regb
+\countdef\FP@regc=36
+\countdef\FP@regd=37
+\countdef\FP@rege=38
+
+\countdef\FP@rs=39 %result registers
+\countdef\FP@ria=40
+\countdef\FP@rib=41
+\countdef\FP@rfa=42
+\countdef\FP@rfb=43
+
+\newcount\FP@regs %local auxiliary registers
+\countdef\FP@count=45
+\countdef\FP@res=46
+\countdef\FP@shift=47
+\newcount\FP@times
+\countdef\FP@prod=49
+
+%set values
+\def\FP@set[#1#2|#3#4]{%
+ \ifx#3\@undefined%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\FP@tmp\expandafter\expandafter\expandafter{\csname #3#4\endcsname}%
+ \else\ifcat\noexpand#3\relax%
+ \expandafter\def\expandafter\FP@tmp\expandafter{#3#4}%
+ \else\ifcat#32\relax%
+ \expandafter\def\expandafter\FP@tmp\expandafter{#3#4}%
+ \else%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\FP@tmp\expandafter\expandafter\expandafter{\csname #3#4\endcsname}%
+ \fi\fi\fi%
+ \ifx#1\@undefined%
+ \let#1\FP@tmp%
+ \else\ifcat\noexpand#1\relax%
+ \let#1\FP@tmp%
+ \else%
+ \expandafter\let\csname #1#2\endcsname\FP@tmp%
+ \fi\fi%
+}
+
+%print values
+\def\FP@print[#1#2]{%
+ \ifx#1\@undefined%
+ \csname #1#2\endcsname%
+ \else\ifcat\noexpand#1\relax%
+ #1#2%
+ \else\ifcat#12\relax%
+ #1#2%
+ \else%
+ \csname #1#2\endcsname%
+ \fi\fi\fi%
+}
+
+%auxiliary macros which may be used in all of the following macros
+\newif\ifFP@test
+
+\def\FP@ignorenext#1{}
+\def\FP@first#1#2\relax{#1}
+\def\FP@swallow#1\relax{}
+
+\def\ifFP@zero#1{%
+ \ifnum%
+ \expandafter\ifnum\csname FP@#1ia\endcsname=0 0\else1\fi%
+ \expandafter\ifnum\csname FP@#1ib\endcsname=0 0\else1\fi%
+ \expandafter\ifnum\csname FP@#1fa\endcsname=0 0\else1\fi%
+ \expandafter\ifnum\csname FP@#1fb\endcsname=0 0\else1\fi%
+ =0\relax%
+}
+
+%read value
+
+\def\FP@correctintcounter#1\relax{%
+ {\edef\FP@tmp{#1}%
+ \FP@count=0\relax%
+ \loop%
+ \edef\FP@tmpa{\expandafter\FP@first\FP@tmp\noexpand\relax}%
+ \expandafter\ifx\FP@tmpa0\relax%
+ \advance\FP@count1\relax%
+ \edef\FP@tmp{\expandafter\FP@ignorenext\FP@tmp}%
+ \repeat%
+ \ifnum\FP@count>18\relax%
+ \FP@errmessage{Overflow}%
+ \fi%
+ \expandafter\if!\FP@tmp!%
+ \advance\FP@count-18\relax%
+ \FP@count=-\FP@count%
+ \loop%
+ \ifnum\FP@count>0\relax%
+ \FP@regc=\FP@rega%
+ \divide\FP@rega10\relax\multiply\FP@rega10\relax%
+ \advance\FP@regc-\FP@rega\multiply\FP@regc100000000\relax%
+ \divide\FP@rega10\relax%
+ \divide\FP@regb10\relax\advance\FP@regb\FP@regc%
+ \advance\FP@count-1\relax%
+ \repeat%
+ \global\FP@rega=\FP@rega%
+ \global\FP@regb=\FP@regb%
+ \else%
+ \FP@errmessage{Number too big}%
+ \fi%
+ }%
+}
+\def\FP@@setintcounter#1#2#3#4#5#6#7#8#9{%
+ \FP@regb=#1#2#3#4#5#6#7#8#9\relax%
+ \FP@correctintcounter%
+}
+\def\FP@setintcounter#1#2#3#4#5#6#7#8#9{%
+ \FP@rega=#1#2#3#4#5#6#7#8#9\relax%
+ \FP@@setintcounter%
+}
+
+\def\FP@@setfractcounter#1#2#3#4#5#6#7#8#9{%
+ \FP@regb=#1#2#3#4#5#6#7#8#9\relax%
+ \FP@swallow%
+}
+\def\FP@setfractcounter#1#2#3#4#5#6#7#8#9{%
+ \FP@rega=#1#2#3#4#5#6#7#8#9\relax%
+ \FP@@setfractcounter%
+}
+
+\def\FP@getsign#1\relax{%
+ {\FP@regs=1\relax%
+ \edef\FP@tmp{#1}%
+ \loop%
+ \edef\FP@tmpa{\expandafter\FP@first\FP@tmp\noexpand\relax}%
+ \expandafter\ifx\FP@tmpa-\relax%
+ \multiply\FP@regs-1\relax%
+ \fi%
+ \ifnum\expandafter\ifx\FP@tmpa-1\else0\fi\expandafter\ifx\FP@tmpa+1\else0\fi>0%
+ \edef\FP@tmp{\expandafter\FP@ignorenext\FP@tmp}%
+ \repeat%
+ \global\let\FP@tmp\FP@tmp%
+ \global\FP@regs=\FP@regs%
+ }%
+}
+
+\def\FP@removeleadingzeros#1\relax{%
+ {\edef\FP@tmp{#1}%
+ \loop%
+ \edef\FP@tmpa{\expandafter\FP@first\FP@tmp\noexpand\relax}%
+ \expandafter\ifx\FP@tmpa0\relax%
+ \edef\FP@tmp{\expandafter\FP@ignorenext\FP@tmp}%
+ \repeat%
+ \global\let\FP@tmp\FP@tmp%
+ }%
+}
+
+\newif\ifFP@nonstop
+\def\FP@strip#1{%
+ {\edef\FP@tmp{#1}%
+ \edef\FP@tmpb{}%
+ \ifx\FP@tmp\@empty\else%
+ \FP@nonstoptrue%
+ \loop%
+ \edef\FP@tmpa{\expandafter\FP@first\FP@tmp\noexpand\relax}%
+ \expandafter\ifx\FP@tmpa-\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa+\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa0\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa1\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa2\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa3\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa4\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa5\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa6\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa7\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa8\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \expandafter\ifx\FP@tmpa9\relax\edef\FP@tmpb{\FP@tmpb\FP@tmpa}\else%
+ \ifx\FP@tmpa\@empty\FP@nonstopfalse\else%
+ \ifx\FP@tmpa\space\FP@nonstopfalse\else%
+ \FP@errmessage{Illegal character \FP@tmpa\space found in float number}%
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
+ \edef\FP@tmp{\expandafter\FP@ignorenext\FP@tmp}%
+ \ifx\FP@tmp\@empty\FP@nonstopfalse\fi%
+ \ifFP@nonstop%
+ \repeat%
+ \fi%
+ \global\let\FP@tmp\FP@tmpb%
+ }%
+}
+
+\def\FP@readvalue#1#2#3{%
+ % #1 macro family to catch the value
+ % #2.#3 value
+ %
+ % regular expression [+|-]*[d]_0^18.[d]*
+ %
+ \FP@strip{#2}%
+ %sign
+ \expandafter\FP@getsign\FP@tmp\relax%
+ \csname FP@#1s\endcsname=\FP@regs%
+ %
+ %integer part
+ \FP@removeleadingzeros\FP@tmp\relax%
+ \expandafter\FP@setintcounter\FP@tmp000000000000000000\relax%
+ \csname FP@#1ia\endcsname=\FP@rega%
+ \csname FP@#1ib\endcsname=\FP@regb%
+ %
+ %fractional part
+ \FP@strip{#3}%
+ \expandafter\FP@setfractcounter\FP@tmp000000000000000000\relax%
+ \csname FP@#1fa\endcsname=\FP@rega%
+ \csname FP@#1fb\endcsname=\FP@regb%
+ %
+ %correct sign
+ \ifnum\FP@rega=0\relax%
+ \ifnum\FP@regb=0\relax%
+ \expandafter\ifnum\csname FP@#1ib\endcsname=0\relax%
+ \expandafter\ifnum\csname FP@#1ia\endcsname=0\relax%
+ \csname FP@#1s\endcsname=1\relax%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+}
+
+%store value in macro
+
+\def\FP@store#1#2{%
+ % #1 macro
+ % #2 macro family (value) to store
+ %
+ \ifFP@zero{#2}%
+ \csname FP@#2s\endcsname=1\relax%
+ \fi%
+ \expandafter\ifnum\csname FP@#2s\endcsname<0\relax%
+ \edef#1{-}%
+ \else%
+ \edef#1{}%
+ \fi%
+ \expandafter\ifnum\csname FP@#2ia\endcsname=0\relax%
+ \expandafter\ifnum\csname FP@#2ib\endcsname=0\relax%
+ \edef#1{#10}%
+ \else%
+ \edef#1{#1\expandafter\the\csname FP@#2ib\endcsname}%
+ \fi%
+ \else%
+ \expandafter\advance\csname FP@#2ib\endcsname1000000000\relax%
+ \edef#1{#1\expandafter\the\csname FP@#2ia\endcsname\expandafter\FP@ignorenext\the\csname FP@#2ib\endcsname}%
+ \fi%
+ \expandafter\advance\csname FP@#2fa\endcsname1000000000\relax%
+ \expandafter\advance\csname FP@#2fb\endcsname1000000000\relax%
+ \edef#1{#1\noexpand.\expandafter\FP@ignorenext\the\csname FP@#2fa\endcsname\expandafter\FP@ignorenext\the\csname FP@#2fb\endcsname}%
+}
+
+%macros to expand some arguments
+
+\def\FP@calla#1#2{%
+ % #1 macro to call
+ % #2 value
+ % expand the value and split them into the integer and the fractional part
+ \edef\next{\noexpand#1#2..\noexpand\relax}%
+ \next%
+}
+
+\def\FP@callb#1#2#3{%
+ % #1 macro to call
+ % #2 1st value
+ % #3 2nd value
+ % expand the values and split them into the integer and the fractional parts
+ \edef\next{\noexpand#1#2..\noexpand\relax#3..\noexpand\relax}%
+ \next%
+}
+
+\def\FP@callc#1#2#3#4{%
+ % #1 macro to call
+ % #2 macro, which gets the result
+ % #3 1st value
+ % #4 2nd value
+ % expand the values and split them into the integer and the fractional parts
+ \edef\next{\noexpand#1\noexpand#2#3..\noexpand\relax#4..\noexpand\relax}%
+ \next%
+}
+
+\def\FP@calld#1#2#3{%
+ % #1 macro to call
+ % #2 macro, which gets the result
+ % #3 value
+ \edef\next{\noexpand#1\noexpand#2#3..\noexpand\relax}%
+ \next%
+}
+
+\def\FP@calle#1#2#3#4{%
+ % #1 macro to call
+ % #2 macro, which gets the first result
+ % #3 macro, which gets the second result
+ % #4 value
+ \edef\next{\noexpand#1\noexpand#2\noexpand#3#4..\noexpand\relax}%
+ \next%
+}
+
+%add two values
+
+\def\FP@add#1#2.#3.#4\relax#5.#6.#7\relax#8\relax{%
+ % #1 macro, which gets the result
+ % #2 integer part of 1st value
+ % #3 fractional part of 1st value
+ % #4 dummy to swallow everthing after the 2nd '.'
+ % #5 integer part of 2nd value
+ % #6 fractional part of 2nd value
+ % #7 dummy to swallow everthing after the 2nd '.'
+ %
+ {\ifx#8+\relax%
+ \FP@beginmessage{ADD}%
+ \else%
+ \FP@beginmessage{SUB}%
+ \fi%
+ %
+ \FP@readvalue{x}{#2}{#3}%
+ \FP@readvalue{y}{#5}{#6}%
+ %
+ \ifnum\FP@xs=\FP@ys%
+ \advance\FP@xfb\FP@yfb%
+ \advance\FP@xfa\FP@yfa%
+ \ifnum\FP@xfb<1000000000\relax\else%
+ \advance\FP@xfb-1000000000\relax%
+ \advance\FP@xfa1\relax%
+ \fi%
+ \advance\FP@xib\FP@yib%
+ \ifnum\FP@xfa<1000000000\relax\else%
+ \advance\FP@xfa-1000000000\relax%
+ \advance\FP@xib1\relax%
+ \fi%
+ \advance\FP@xia\FP@yia%
+ \ifnum\FP@xib<1000000000\relax\else%
+ \advance\FP@xib-1000000000\relax%
+ \advance\FP@xia1\relax%
+ \fi%
+ \ifnum\FP@xia<1000000000\relax\else%
+ \FP@errmessage{Overflow}%
+ \fi%
+ \FP@store\FP@tmp{x}%
+ \else%
+ \advance\FP@xfb-\FP@yfb%
+ \ifnum\FP@xfb<0\relax%
+ \advance\FP@yfa1\relax%
+ \advance\FP@xfb1000000000\relax%
+ \fi%
+ \advance\FP@xfa-\FP@yfa%
+ \ifnum\FP@xfa<0\relax%
+ \advance\FP@yib1\relax%
+ \advance\FP@xfa1000000000\relax%
+ \fi%
+ \advance\FP@xib-\FP@yib%
+ \ifnum\FP@xib<0\relax%
+ \advance\FP@yia1\relax%
+ \advance\FP@xib1000000000\relax%
+ \fi%
+ \advance\FP@xia-\FP@yia%
+ \ifnum\FP@xia<0\relax%
+ \FP@xs=-\FP@xs%
+ \ifnum\FP@xfb=0\relax\else%
+ \advance\FP@xfb-1000000000\relax\FP@xfb=-\FP@xfb%
+ \advance\FP@xfa1\relax%
+ \fi%
+ \ifnum\FP@xfa=0\relax\else%
+ \advance\FP@xfa-1000000000\relax\FP@xfa=-\FP@xfa%
+ \advance\FP@xib1\relax%
+ \fi%
+ \ifnum\FP@xib=0\relax\else%
+ \advance\FP@xib-1000000000\relax\FP@xib=-\FP@xib%
+ \advance\FP@xia1\relax%
+ \fi%
+ \relax\FP@xia=-\FP@xia%
+ \fi%
+ \FP@store\FP@tmp{x}%
+ \fi%
+ %
+ \global\let\FP@tmp\FP@tmp%
+ %
+ \FP@endmessage{}%
+ }%
+ \let#1\FP@tmp%
+}
+
+%multiply two values
+
+\def\FP@firstnine#1#2#3#4#5#6#7#8#9{%
+ \FP@res=#1#2#3#4#5#6#7#8#9\relax%
+}
+\def\FP@@ninesplit#1\relax#2\end#3{%
+ #1%
+ \edef#3{#2}%
+}
+\def\FP@ninesplit#1{%
+ \edef#1{\expandafter\FP@firstnine\FP@rd}%
+ \expandafter\FP@@ninesplit#1\end#1\relax%
+}
+
+\def\FP@split#1#2#3#4{%
+ % #1 highest three digits
+ % #2 medium three digits
+ % #3 least three digits
+ % #4 counter
+ \FP@regc=#4%
+ \divide\FP@regc1000000\relax%
+ #1=\FP@regc%
+ \multiply\FP@regc-1000000\relax\advance\FP@regc#4%
+ #3=\FP@regc%
+ \divide\FP@regc1000\relax%
+ #2=\FP@regc%
+ \multiply\FP@regc-1000\relax\advance\FP@regc#3%
+ #3=\FP@regc%
+}
+
+\def\FP@@mul#1#2#3{%
+ \FP@regc=\csname FP@x#1\endcsname%
+ \multiply\FP@regc\csname FP@y#2\endcsname%
+ \advance\FP@prod\FP@regc%
+ %
+ \ifx#3\relax%
+ \let\next=\relax%
+ \else%
+ \let\next=\FP@@mul%
+ \fi%
+ \next#3%
+}
+
+\def\FP@saveshift{%
+ % save rightmost three digits
+ \FP@regc=\FP@prod%
+ \divide\FP@prod1000\relax%
+ \multiply\FP@prod1000\relax%
+ \advance\FP@regc-\FP@prod%
+ \advance\FP@regc1000\relax%
+ \edef\FP@rd{\expandafter\FP@ignorenext\the\FP@regc\FP@rd}%
+ %
+ \divide\FP@prod1000\relax%
+}
+
+\def\FP@mul#1#2.#3.#4\relax#5.#6.#7\relax{%
+ % #1 macro, which gets the result
+ % #2 integer part of 1st value
+ % #3 fractional part of 1st value
+ % #4 dummy to swallow everthing after the 2nd '.'
+ % #5 integer part of 2nd value
+ % #6 fractional part of 2nd value
+ % #7 dummy to swallow everthing after the 2nd '.'
+ %
+ % split value in various parts
+ % x y = 123 456 789 123 456 789 . 123 456 789 123 456 789
+ % -> xk xl xm xn xo xp xq xr xs xt xu xv
+ % -> yk yl ym yn yo yp yq yr ys yt yu yv
+ % multiply these parts and save the result wrt the necessary shifts
+ %
+ {\FP@beginmessage{MUL}%
+ %
+ \FP@readvalue{x}{#2}{#3}%
+ \FP@readvalue{y}{#5}{#6}%
+ %
+ %sign
+ \multiply\FP@xs\FP@ys%
+ \FP@rs=\FP@xs%
+ %
+ % split parts
+ \FP@split\FP@xk\FP@xl\FP@xm\FP@xia\FP@split\FP@xn\FP@xo\FP@xp\FP@xib%
+ \FP@split\FP@xq\FP@xr\FP@xz\FP@xfa\FP@split\FP@xt\FP@xu\FP@xv\FP@xfb%
+ \FP@split\FP@yk\FP@yl\FP@ym\FP@yia\FP@split\FP@yn\FP@yo\FP@yp\FP@yib%
+ \FP@split\FP@yq\FP@yr\FP@yz\FP@yfa\FP@split\FP@yt\FP@yu\FP@yv\FP@yfb%
+ %
+ \FP@prod=0\relax%
+ \edef\FP@rd{}%
+ %
+ %compute result
+ \FP@@mul vv \relax\FP@saveshift%
+ \FP@@mul vu uv \relax\FP@saveshift%
+ \FP@@mul uu vt tv \relax\FP@saveshift%
+ \FP@@mul ut tu vz zv \relax\FP@saveshift%
+ \FP@@mul tt zu uz rv vr \relax\FP@saveshift%
+ \FP@@mul zt tz ur ru vq qv \relax\FP@saveshift%
+ \FP@@mul zz rt tr uq qu vp pv \relax\FP@saveshift%
+ \FP@@mul zr rz tq qt up pu vo ov \relax\FP@saveshift%
+ \FP@@mul rr qz zq tp pt uo ou vn nv \relax\FP@saveshift%
+ \FP@@mul rq qr zp pz to ot un nu vm mv \relax\FP@saveshift%
+ \FP@@mul qq rp pr zo oz tn nt um mu vl lv \relax\FP@saveshift%
+ \FP@@mul qp pq ro or zn nz tm mt ul lu kv vk \relax\FP@saveshift%
+ \FP@@mul pp oq qo rn nr zm mz tl lt ku uk \relax\FP@saveshift%
+ \FP@@mul op po nq qn rm mr zl lz tk kt \relax\FP@saveshift%
+ \FP@@mul oo pn np mq qm rl lr kz zk \relax\FP@saveshift%
+ \FP@@mul no on mp pm lq ql kr rk \relax\FP@saveshift%
+ \FP@@mul nn mo om pl lp qk kq \relax\FP@saveshift%
+ \FP@@mul mn nm lo ok pk kp \relax\FP@saveshift%
+ \FP@@mul mm ln nl ko ok \relax\FP@saveshift%
+ \FP@@mul lm ml kn nk \relax\FP@saveshift%
+ \FP@@mul ll km mk \relax\FP@saveshift%
+ \FP@@mul kl lk \relax\FP@saveshift%
+ \FP@@mul kk \relax\FP@saveshift\FP@saveshift%
+ \FP@ninesplit\FP@rd%
+ \ifnum\FP@res=0\relax%
+ \FP@ninesplit\FP@rd%
+ \ifnum\FP@res=0\relax%
+ \FP@ninesplit\FP@rd\FP@ria=\FP@res%
+ \FP@ninesplit\FP@rd\FP@rib=\FP@res%
+ \FP@ninesplit\FP@rd\FP@rfa=\FP@res%
+ \FP@ninesplit\FP@rd\FP@rfb=\FP@res%
+ \FP@store\FP@tmp{r}%
+ \else%
+ \FP@errmessage{Overflow}%
+ \fi%
+ \else%
+ \FP@errmessage{Overflow}%
+ \fi%
+ %
+ \global\let\FP@tmp\FP@tmp%
+ %
+ \FP@endmessage{}%
+ }%
+ %
+ \let#1\FP@tmp%
+}
+
+%divide one value by another one
+
+\def\FP@divten#1{%
+ \expandafter\FP@regc\csname FP@#1ia\endcsname%
+ \expandafter\divide\csname FP@#1ia\endcsname10\relax%
+ \expandafter\FP@regb\csname FP@#1ia\endcsname%
+ \multiply\FP@regb10\relax%
+ \advance\FP@regc-\FP@regb%
+ \multiply\FP@regc100000000\relax%
+ %
+ \expandafter\FP@rega\csname FP@#1ib\endcsname%
+ \expandafter\divide\csname FP@#1ib\endcsname10\relax%
+ \expandafter\FP@regb\csname FP@#1ib\endcsname%
+ \multiply\FP@regb10\relax%
+ \advance\FP@rega-\FP@regb%
+ \multiply\FP@rega100000000\relax%
+ \expandafter\advance\csname FP@#1ib\endcsname\FP@regc%
+ %
+ \expandafter\FP@regc\csname FP@#1fa\endcsname%
+ \expandafter\divide\csname FP@#1fa\endcsname10\relax%
+ \expandafter\FP@regb\csname FP@#1fa\endcsname%
+ \multiply\FP@regb10\relax%
+ \advance\FP@regc-\FP@regb%
+ \multiply\FP@regc100000000\relax%
+ \expandafter\advance\csname FP@#1fa\endcsname\FP@rega%
+ %
+ \expandafter\divide\csname FP@#1fb\endcsname10\relax%
+ \expandafter\advance\csname FP@#1fb\endcsname\FP@regc%
+}
+
+\def\FP@multen#1{%
+ \expandafter\multiply\csname FP@#1ia\endcsname10\relax%
+ \expandafter\ifnum\csname FP@#1ib\endcsname<100000000\relax%
+ \else%
+ \expandafter\FP@regc\csname FP@#1ib\endcsname%
+ \divide\FP@regc100000000%
+ \expandafter\advance\csname FP@#1ia\endcsname\FP@regc%
+ \multiply\FP@regc100000000%
+ \expandafter\advance\csname FP@#1ib\endcsname-\FP@regc%
+ \fi%
+ \expandafter\multiply\csname FP@#1ib\endcsname10\relax%
+ \expandafter\ifnum\csname FP@#1fa\endcsname<100000000\relax%
+ \else%
+ \expandafter\FP@regc\csname FP@#1fa\endcsname%
+ \divide\FP@regc100000000%
+ \expandafter\advance\csname FP@#1ib\endcsname\FP@regc%
+ \multiply\FP@regc100000000%
+ \expandafter\advance\csname FP@#1fa\endcsname-\FP@regc%
+ \fi%
+ \expandafter\multiply\csname FP@#1fa\endcsname10\relax%
+ \expandafter\ifnum\csname FP@#1fb\endcsname<100000000\relax%
+ \else%
+ \expandafter\FP@regc\csname FP@#1fb\endcsname%
+ \divide\FP@regc100000000%
+ \expandafter\advance\csname FP@#1fa\endcsname\FP@regc%
+ \multiply\FP@regc100000000%
+ \expandafter\advance\csname FP@#1fb\endcsname-\FP@regc%
+ \fi%
+ \expandafter\multiply\csname FP@#1fb\endcsname10\relax%
+}
+
+\def\FP@counttimes{%
+ {\global\FP@times=0\relax%
+ \loop%
+ \ifnum%
+ \ifnum\FP@xia>\FP@yia1%
+ \else\ifnum\FP@xia<\FP@yia0%
+ \else%
+ \ifnum\FP@xib>\FP@yib1%
+ \else\ifnum\FP@xib<\FP@yib0%
+ \else%
+ \ifnum\FP@xfa>\FP@yfa1%
+ \else\ifnum\FP@xfa<\FP@yfa0%
+ \else%
+ \ifnum\FP@xfb>\FP@yfb1%
+ \else\ifnum\FP@xfb<\FP@yfb0%
+ \else%
+ 1%
+ \fi\fi%
+ \fi\fi%
+ \fi\fi%
+ \fi\fi%
+ =1\relax%
+ \global\advance\FP@times1\relax%
+ \global\advance\FP@xfb-\FP@yfb%
+ \ifnum\FP@xfb<0\relax%
+ \global\advance\FP@xfb1000000000\relax%
+ \global\advance\FP@xfa-1\relax%
+ \fi%
+ \global\advance\FP@xfa-\FP@yfa%
+ \ifnum\FP@xfa<0\relax%
+ \global\advance\FP@xfa1000000000\relax%
+ \global\advance\FP@xib-1\relax%
+ \fi%
+ \global\advance\FP@xib-\FP@yib%
+ \ifnum\FP@xib<0\relax%
+ \global\advance\FP@xib1000000000\relax%
+ \global\advance\FP@xia-1\relax%
+ \fi%
+ \global\advance\FP@xia-\FP@yia%
+ \repeat%
+ }%
+}
+
+\def\FP@div#1#2.#3.#4\relax#5.#6.#7\relax{%
+ % #1 macro, which gets the result
+ % #2 integer part of 1st value
+ % #3 fractional part of 1st value
+ % #4 dummy to swallow everthing after the 2nd '.'
+ % #5 integer part of 2nd value
+ % #6 fractional part of 2nd value
+ % #7 dummy to swallow everthing after the 2nd '.'
+ %
+ % algorithmic idea (for x>0, y>0)
+ % - %determine \FP@shift such that y*10^\FP@shift <100000000<=y*10^(\FP@shift+1)
+ % - %determine \FP@shift' such that x*10^\FP@shift'<100000000<=x*10^(\FP@shift+1)
+ % - x=x*\FP@shift'
+ % - y=y*\FP@shift
+ % - \FP@shift=\FP@shift-\FP@shift'
+ % - res=0
+ % - while y>0 %fixed-point representation!
+ % - \FP@times=0
+ % - while x>y
+ % - \FP@times=\FP@times+1
+ % - x=x-y
+ % - end
+ % - y=y/10
+ % - res=10*res+\FP@times/1000000000
+ % - end
+ % - %shift the result according to \FP@shift
+ %
+ {\FP@beginmessage{DIV}%
+ %
+ \FP@readvalue{x}{#2}{#3}%
+ \FP@readvalue{y}{#5}{#6}%
+ %
+ %sign
+ \multiply\FP@xs\FP@ys%
+ \FP@rs=\FP@xs%
+ %
+ %compute division
+ \ifFP@zero{y}%
+ \FP@errmessage{Division by zero}%
+ \else%
+ \ifFP@zero{x}\def\next##1{\edef\FP@tmp{0}}\else\def\next##1{##1}\fi%
+ \next%
+ {\FP@shift=0\relax%
+ \loop%
+ \ifnum\FP@yia<100000000\relax%
+ \FP@multen{y}%
+ \advance\FP@shift1\relax%
+ \repeat%
+ \loop%
+ \ifnum\FP@xia<100000000\relax%
+ \FP@multen{x}%
+ \advance\FP@shift-1\relax%
+ \repeat%
+ \FP@ria=0\FP@rib=0\FP@rfa=0\FP@rfb=0\relax%
+ \loop%
+ \ifFP@zero{y}\else%
+ \FP@counttimes%divides x by \FP@times*y
+ \FP@divten{y}%
+ \FP@multen{r}%
+ \advance\FP@rfb\FP@times%
+ \ifnum\FP@rfb<1000000000\relax\else%
+ \advance\FP@rfa1\advance\FP@rfb-1000000000\relax%
+ \ifnum\FP@rfa<1000000000\relax\else%
+ \advance\FP@rib1\advance\FP@rfa-1000000000\relax%
+ \ifnum\FP@rib<1000000000\relax\else%
+ \advance\FP@ria1\advance\FP@rib-1000000000\relax%
+ \fi%
+ \fi%
+ \fi%
+ \repeat%
+ \loop%
+ \ifnum\FP@shift>17%
+ \advance\FP@shift-1\relax%
+ \ifnum\FP@ria<100000000\else\FP@ria=-1\fi%
+ \ifnum\FP@ria<0\FP@ria=-1\fi%
+ \FP@multen{r}%
+ \repeat%
+ \ifnum\FP@ria<1000000000\else\FP@ria=-1\fi%
+ \loop%
+ \ifnum\FP@shift<17%
+ \advance\FP@shift1\relax%
+ \FP@divten{r}%
+ \repeat%
+ \ifnum\FP@ria<0\relax%
+ \FP@errmessage{Overflow}%
+ \else%
+ \FP@store\FP@tmp{r}%
+ \fi%
+ }%
+ \fi%
+ %
+ \global\let\FP@tmp=\FP@tmp%
+ %
+ \FP@endmessage{}%
+ }%
+ \let#1\FP@tmp%
+}
+
+%absolute value
+
+\def\FP@abs#1#2.#3.#4\relax{%
+ % #1 macro, which gets the result
+ % #2 integer part of value
+ % #3 fractional part of value
+ % #4 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{ABS}%
+ %
+ \FP@readvalue{x}{#2}{#3}%
+ \FP@xs=1\relax%
+ \FP@store\FP@tmp{x}%
+ %
+ \global\let\FP@tmp\FP@tmp%
+ %
+ \FP@endmessage{}%
+ }%
+ \let#1\FP@tmp%
+}
+
+%negate value
+
+\def\FP@neg#1#2.#3.#4\relax{%
+ % #1 macro, which gets the result
+ % #2 integer part of value
+ % #3 fractional part of value
+ % #4 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{NEG}%
+ %
+ \FP@readvalue{x}{#2}{#3}%
+ \multiply\FP@xs-1\relax%
+ \FP@store\FP@tmp{x}%
+ %
+ \global\let\FP@tmp\FP@tmp%
+ %
+ \FP@endmessage{}%
+ }%
+ \let#1\FP@tmp%
+}
+
+%sign of value
+
+\def\FP@sgn#1#2.#3.#4\relax{%
+ % #1 macro, which gets the result
+ % #2 integer part of value
+ % #3 fractional part of value
+ % #4 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{SGN}%
+ %
+ \FP@readvalue{x}{#2}{#3}%
+ %
+ \ifFP@zero{x}%
+ \edef\FP@tmp{0}%
+ \else%
+ \edef\FP@tmp{\the\FP@xs}%
+ \fi%
+ %
+ \global\let\FP@tmp\FP@tmp%
+ %
+ \FP@endmessage{}%
+ }%
+ \let#1\FP@tmp%
+}
+
+%test if 1st value is less than 2nd value
+
+\def\FP@iflt#1.#2.#3\relax#4.#5.#6\relax#7\relax{%
+ % #1 integer part of 1st value
+ % #2 fractional part of 1st value
+ % #3 dummy to swallow everthing after the 2nd '.'
+ % #4 integer part of 2nd value
+ % #5 fractional part of 2nd value
+ % #6 dummy to swallow everthing after the 2nd '.'
+ %
+ {\ifx#7+\relax%
+ \FP@beginmessage{LT?}%
+ \else%
+ \FP@beginmessage{GT?}%
+ \fi%
+ %
+ \FP@readvalue{x}{#1}{#2}%
+ \FP@readvalue{y}{#4}{#5}%
+ %
+ \ifnum\FP@xs<\FP@ys%
+ \FP@testtrue%
+ \else\ifnum\FP@xs>\FP@ys%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xs>0\relax%
+ \ifnum\FP@xia<\FP@yia%
+ \FP@testtrue%
+ \else\ifnum\FP@xia>\FP@yia%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xib<\FP@yib%
+ \FP@testtrue%
+ \else\ifnum\FP@xib>\FP@yib%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xfa<\FP@yfa%
+ \FP@testtrue%
+ \else\ifnum\FP@xfa>\FP@yfa%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xfb<\FP@yfb%
+ \FP@testtrue%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \fi\fi%
+ \fi\fi%
+ \fi\fi%
+ \else%
+ \ifnum\FP@xia>\FP@yia%
+ \FP@testtrue%
+ \else\ifnum\FP@xia<\FP@yia%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xib>\FP@yib%
+ \FP@testtrue%
+ \else\ifnum\FP@xib<\FP@yib%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xfa>\FP@yfa%
+ \FP@testtrue%
+ \else\ifnum\FP@xfa<\FP@yfa%
+ \FP@testfalse%
+ \else%
+ \ifnum\FP@xfb>\FP@yfb%
+ \FP@testtrue%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \fi\fi%
+ \fi\fi%
+ \fi\fi%
+ \fi%
+ \fi\fi%
+ %
+ \global\let\ifFP@test\ifFP@test%
+ %
+ \FP@endmessage{}%
+ }%
+ \let\ifFPtest\ifFP@test%
+ %
+ \ifFPtest%
+}
+
+%test if two values are equal
+
+\def\FP@ifeq#1.#2.#3\relax#4.#5.#6\relax{%
+ % #1 integer part of 1st value
+ % #2 fractional part of 1st value
+ % #3 dummy to swallow everthing after the 2nd '.'
+ % #4 integer part of 2nd value
+ % #5 fractional part of 2nd value
+ % #6 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{EQ?}%
+ %
+ \FP@readvalue{x}{#1}{#2}%
+ \FP@readvalue{y}{#4}{#5}%
+ %
+ \ifnum\FP@xs=\FP@ys%
+ \ifnum\FP@xia=\FP@yia%
+ \ifnum\FP@xib=\FP@yib%
+ \ifnum\FP@xfa=\FP@yfa%
+ \ifnum\FP@xfb=\FP@yfb%
+ \FP@testtrue%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \else%
+ \FP@testfalse%
+ \fi%
+ %
+ \global\let\ifFP@test\ifFP@test%
+ %
+ \FP@endmessage{}%
+ }%
+ \let\ifFPtest\ifFP@test%
+ %
+ \ifFPtest%
+}
+
+%test if value is negative
+
+\def\FP@ifneg#1.#2.#3\relax{%
+ % #1 integer part of value
+ % #2 fractional part of value
+ % #3 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{NEG?}%
+ %
+ \FP@readvalue{x}{#1}{#2}%
+ %
+ \ifnum\FP@xs<0\relax%
+ \FP@testtrue%
+ \else%
+ \FP@testfalse%
+ \fi%
+ %
+ \global\let\ifFP@test\ifFP@test%
+ %
+ \FP@endmessage{}%
+ }%
+ \let\ifFPtest\ifFP@test%
+ %
+ \ifFPtest%
+}
+
+%test if value is positive
+
+\def\FP@ifpos#1.#2.#3\relax{%
+ % #1 integer part of value
+ % #2 fractional part of value
+ % #3 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{POS?}%
+ %
+ \FP@readvalue{x}{#1}{#2}%
+ %
+ \ifnum\FP@xs<0\relax%
+ \FP@testfalse%
+ \else%
+ \FP@testtrue%
+ \fi%
+ %
+ \global\let\ifFP@test\ifFP@test%
+ %
+ \FP@endmessage{}%
+ }%
+ \let\ifFPtest\ifFP@test%
+ %
+ \ifFPtest%
+}
+
+%test if value is equal to zero
+
+\def\FP@ifzero#1.#2.#3\relax{%
+ % #1 integer part of value
+ % #2 fractional part of value
+ % #3 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{ZERO?}%
+ %
+ \FP@readvalue{x}{#1}{#2}%
+ %
+ \ifFP@zero{x}%
+ \FP@testtrue%
+ \else%
+ \FP@testfalse%
+ \fi%
+ %
+ \global\let\ifFP@test\ifFP@test%
+ %
+ \FP@endmessage{}%
+ }%
+ \let\ifFPtest\ifFP@test%
+ %
+ \ifFPtest%
+}
+
+%test if value is an integer
+
+\def\FP@ifint#1.#2.#3\relax{%
+ % #1 integer part of value
+ % #2 fractional part of value
+ % #3 dummy to swallow everthing after the 2nd '.'
+ %
+ {\FP@beginmessage{INT?}%
+ %
+ \FP@readvalue{x}{#1}{#2}%
+ %
+ \ifnum\FP@xfa=0\relax%
+ \ifnum\FP@xfb=0\relax%
+ \FP@testtrue%
+ \else%
+ \FP@testfalse%
+ \fi%
+ \else%
+ \FP@testfalse%
+ \fi%
+ %
+ \global\let\ifFP@test\ifFP@test%
+ %
+ \FP@endmessage{}%
+ }%
+ \let\ifFPtest\ifFP@test%
+ %
+ \ifFPtest%
+}