diff options
Diffstat (limited to 'graphics/pgf/base/tex/generic/math')
16 files changed, 8858 insertions, 0 deletions
diff --git a/graphics/pgf/base/tex/generic/math/pgfint.code.tex b/graphics/pgf/base/tex/generic/math/pgfint.code.tex new file mode 100644 index 0000000000..8921ee5fbd --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfint.code.tex @@ -0,0 +1,126 @@ +% Copyright 2019 by Henri Menke +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +% Guard against reading twice +\ifx\pgfintloaded\pgfutil@undefined + \let\pgfintloaded=\relax +\else + \expandafter\endinput +\fi + +% This module is pretty much a rip-off of the LaTeX3 l3int module for integer +% calculations. Since PGF supports e-TeX now, we can make use of those +% extended facilities. + +% In contrast to l3int we will just admit that integers are regular TeX \count +% register and will not implement an extra "integer datatype". + +% Evaluate an integer expression using \numexpr +\def\pgfinteval#1{\number\numexpr#1\relax} + +% Get the absolute value of an integer by stripping off a leading minus sign +\def\pgfintabs#1{\number\expandafter\pgfint@abs\number\numexpr#1\relax} +\def\pgfint@abs#1{\ifx-#1\else\expandafter#1\fi} + +% Minimum and maximum +\def\pgfintmax#1#2{% + \number\expandafter\pgfint@minmax + \number\numexpr#1\expandafter;% + \number\numexpr#2;% + > +} +\def\pgfintmin#1#2{% + \number\expandafter\pgfint@minmax + \number\numexpr#1\expandafter;% + \number\numexpr#2;% + < +} +\def\pgfint@minmax#1;#2;#3{% + \ifnum#1#3#2 + #1% + \else + #2% + \fi +} + +% \numexpr has the annoying property to round divisions rather than truncating +% (as you would expect for integer arithmetic). Therefore we need a truncating +% division function. +\def\pgfintdivtruncate#1#2{% + \number\numexpr\expandafter\pgfint@divtruncate + \number\numexpr#1\expandafter;% + \number\numexpr#2;% + \relax +} +\def\pgfint@divtruncate#1#2;#3#4;{% + \ifx0#1 + 0% + \else + (#1#2% + \ifx-#1 +\else-\fi + (\ifx-#3 -\fi#3#4-1)/2% + )% + \fi + /#3#4% +} + +% \pgfintdivtruncate always truncates the result which leads to a rounding +% towards zero. Donald Knuth defines in TAoCP, Vol 1, 3rd Ed, Section 1.2.4 +% that the modulo operation is +% +% x mod y = x - y * floor(x/y) +% +% In contrast to truncated division, floored division always rounds towards +% -inf, i.e. floor(1/2) = 0 and floor(-1/2) = -1. This is also how integer +% division is done in Lua. +\def\pgfintdivfloor#1#2{% + \number\numexpr\expandafter\pgfint@divfloor + \number\numexpr#1\expandafter;% + \number\numexpr#2;% + \relax +} +\def\pgfint@divfloor#1#2;#3#4;{% + \ifx0#1 + 0% + \else + \ifnum + 0\ifx-#1\ifx#3-\else1\fi\fi + 0\ifx-#3\ifx#1-\else1\fi\fi + >0 + \pgfint@@divfloor#1#2;#3#4;-+% + \else + \pgfint@@divfloor#1#2;#3#4;+-% + \fi + \fi + /#3#4% +} +\def\pgfint@@divfloor#1#2;#3#4;#5#6{% + (#1#2% + \ifx-#1 #5\else#6\fi + (\ifx-#3 -\fi#3#4#61)/2% + )% +} + +% Round +\def\pgfintdivround#1#2{\number\numexpr(#1)/(#2)\relax} + +% Modulo +\def\pgfintmod#1#2{% + \number\numexpr\expandafter\pgfint@mod% + \number\numexpr#1\expandafter;% + \number\numexpr#2;% + \relax +} +\def\pgfint@mod#1;#2;{#1-(\pgfint@divfloor#1;#2;)*#2} + +% Setter function so we don't always have to write \pgfinteval +\def\pgfintset#1#2{#1 \numexpr#2\relax} + +\endinput diff --git a/graphics/pgf/base/tex/generic/math/pgfmath.code.tex b/graphics/pgf/base/tex/generic/math/pgfmath.code.tex new file mode 100644 index 0000000000..fd40a36d59 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmath.code.tex @@ -0,0 +1,37 @@ +% Copyright 2019 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +% Guard against reading twice +\ifx\pgfmathloaded\pgfutil@undefined + \let\pgfmathloaded=\relax +\else + \expandafter\endinput +\fi + +% We need keys: +\ifx\pgfkeysloaded\pgfutil@undefined + \input pgfkeys.code.tex +\fi + +\input pgfmathutil.code.tex +\input pgfmathparser.code.tex +\input pgfmathfunctions.code.tex +\input pgfmathfunctions.basic.code.tex +\input pgfmathfunctions.trigonometric.code.tex +\input pgfmathfunctions.random.code.tex +\input pgfmathfunctions.comparison.code.tex +\input pgfmathfunctions.base.code.tex +\input pgfmathfunctions.round.code.tex +\input pgfmathfunctions.misc.code.tex +\input pgfmathfunctions.integerarithmetics.code.tex +\input pgfmathcalc.code.tex +\input pgfmathfloat.code.tex + +\endinput diff --git a/graphics/pgf/base/tex/generic/math/pgfmathcalc.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathcalc.code.tex new file mode 100644 index 0000000000..1e854864d8 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathcalc.code.tex @@ -0,0 +1,537 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file loads all the parsing, functions and operator stuff +% +% Version 1.414213 29/9/2007 + +% \pgfmathsetlength, \pgfmathaddtolength +% +% #1 = dimension register +% #2 = expression +% +% Description: +% +% These functions work similar to \setlength and \addtolength. Only, +% they allow #2 to contain an expression, which is evaluated before +% assignment. Furthermore, the font is setup before the assignment is +% done, so that dimensions like 1em are evaluated correctly. +% +% If #2 starts with "+", then a simple assignment is done (but the +% font is still setup). This is orders of magnitude faster than a +% parsed assignment. + +\def\pgfmathsetlength#1#2{% + \expandafter\pgfmath@onquick#2\pgfmath@% + {% + % Ok, quick version: + \begingroup% + \pgfmath@selectfont% + #1#2\unskip% + \expandafter\endgroup% + \expandafter#1\the#1\relax% + }% + {% + \pgfmathparse{#2}% + \ifpgfmathmathunitsdeclared% + #1\pgfmathresult mu\relax% + \else% + #1\pgfmathresult pt\relax% + \fi% + }% + \ignorespaces% +} + +% \pgfmathaddtolength +% +% Add to #1 the result of evaluating #2. +% +% #1 - a dimension register +% #2 - an expression +% +\def\pgfmathaddtolength#1#2{% + \expandafter\pgfmath@onquick#2\pgfmath@% + {% + \begingroup% + \pgfmath@selectfont% + \advance#1#2\unskip% + \expandafter% + \endgroup% + \expandafter#1\the#1\relax% + }% + {% + \pgfmathparse{#2}% + \ifpgfmathmathunitsdeclared% + \advance#1\pgfmathresult mu\relax% + \else% + \advance#1\pgfmathresult pt\relax% + \fi% + }% + \ignorespaces% +} + +% \pgfmathsetcount +% +% Assign #1 the truncated evaluation of #2. +% +% #1 - a count register +% #2 - an expression +% +\def\pgfmathsetcount#1#2{% + \expandafter\pgfmath@onquick#2\pgfmath@% + {% + \afterassignment\pgfmath@gobbletilpgfmath@% + #1#2\relax\pgfmath@% + }% + {% + \pgfmathparse{#2}% + \afterassignment\pgfmath@gobbletilpgfmath@% + #1\pgfmathresult\relax\pgfmath@% + }% + \ignorespaces% +} + +% \pgfmathaddtocount +% +% Add to #1 the truncated evaluation of #2. +% +% #1 - a count register +% #2 - an expression +% +\def\pgfmathaddtocount#1#2{% + \expandafter\pgfmath@onquick#2\pgfmath@% + {% + \edef\pgfmath@addtocounttemp{\the#1}% + \afterassignment\pgfmath@gobbletilpgfmath@% + #1#2\relax\pgfmath@% + \advance#1\pgfmath@addtocounttemp\relax% + }% + {% + \edef\pgfmath@addtocounttemp{\the#1}% + \pgfmathparse{#2}% + \afterassignment\pgfmath@gobbletilpgfmath@% + #1\pgfmathresult\relax\pgfmath@% + \advance#1\pgfmath@addtocounttemp\relax% + }% + \ignorespaces% +} + +% \pgfmathnewcounter +% +% LaTeX style counter which also works in plain TeX. Defines +% \c@<name> as a count register and also defines \the<name>. +% +% #1 the name of the counter. +% +% Example: +% +% \pgfmathnewcounter{counter} +% \pgfmathsetcounter{counter}{12} +% \thecounter (same as \the\c@counter) +% +\def\pgfmathnewcounter#1{% + \expandafter\ifx\csname c@#1\endcsname\relax% + \def\pgfmath@marshal{\csname newcount\endcsname}% Ha! Who cares about \outer? + \expandafter\pgfmath@marshal\csname c@#1\endcsname% + \expandafter\def\csname the#1\endcsname{\expandafter\the\csname c@#1\endcsname}% + \fi% +} + +% \pgfmathsetcounter +% +% Set the counter #1 to the evaluation of #2. +% +% #1 - a counter name +% #2 - an expression +% +\def\pgfmathsetcounter#1#2{% + \expandafter\pgfmathsetcount\csname c@#1\endcsname{#2}% +} + +% \pgfmathaddtocounter +% +% Add the counter #1 to the evaluation of #2. +% +% #1 - a counter name +% #2 - an expression +% +\def\pgfmathaddtocounter#1#2{% + \expandafter\pgfmathaddtocount\csname c@#1\endcsname{#2}% +} + +% \pgfmathmakecounterglobal +% +% Make the current value of a counter globally defined. +% +% #1 - a (valid) counter name. +% +\def\pgfmath@pgftext{pgf} +\def\pgfmath@tikztext{tikz} +\def\pgfmathmakecounterglobal#1{% + \pgfmath@ifundefined{c@#1}{}{% + \expandafter\pgfmath@in@\expandafter{\pgfmath@pgftext}{#1}% + \ifpgfmath@in@% + \else% + \expandafter\pgfmath@in@\expandafter{\pgfmath@tikztext}{#1}% + \ifpgfmath@in@% + \else% + \expandafter\global\csname c@#1\endcsname\csname c@#1\endcsname\relax% + \fi% + \fi% + }% +} + +% \pgfmathsetmacro +% +% \edef#1 as the result of evaluating #2. +% +% #1 - a macro +% #2 - an expression +% +\def\pgfmathsetmacro#1#2{% + \begingroup% + \pgfmathparse{#2}% + \let#1=\pgfmathresult + \pgfmath@smuggleone{#1}% + \endgroup% +} + +% \pgfmathsetlengthmacro +% +% \edef#1 as the result of evaluating #2 with pt. +% +% #1 - a macro +% #2 - an expression +% +\def\pgfmathsetlengthmacro#1#2{% + \begingroup% + \pgfmathsetlength\pgfmath@x{#2}% + \edef#1{\the\pgfmath@x}% + \pgfmath@smuggleone{#1}% + \endgroup% +} + +% \pgfmathtruncatemacro +% +% \edef#1 as the truncated result of evaluating #2. +% +% #1 - a macro +% #2 - an expression +% +\def\pgfmathtruncatemacro#1#2{% + \begingroup% + \pgfmathsetcount\c@pgfmath@counta{#2}% + \edef#1{\the\c@pgfmath@counta}% + \pgfmath@smuggleone{#1}% + \endgroup% +} + +% Check whether a given parameter starts with quick. +% +% The command should be followed by nonempty text, ending with +% \pgfmath@ as a stop-token. Then should follow +% +% #1 - code to execute if text starts with + +% #2 - code to execute if text does not +% +% Example: +% +% \pgfmath@onquick+0pt\pgfmath@{is quick}{is slow} + +\def\pgfmath@onquick{% + \futurelet\pgfmath@next% + \pgfmath@@onquick} +\def\pgfmath@@onquick#1\pgfmath@{% + \ifx\pgfmath@next+% + \let\pgfmath@next=\pgfmath@firstoftwo% + \else% + \let\pgfmath@next=\pgfmath@secondoftwo% + \fi% + \pgfmath@next% +} + +% *** The following commands DO NOT WORK without the rest of PGF *** +% +% (a dumping ground for stuff that doesn't really belong anywhere else) + +% \pgfmathanglebetweenpoints +% +% Define \pgfmathresult as the angle between points #1 and #2 +% Should get the quadrants right as well. +% +\def\pgfmathanglebetweenpoints#1#2{% + \begingroup% + \pgf@process{\pgfpointdiff{#1}{#2}}% + \edef\pgf@marshall{\expandafter\noexpand\csname pgfmathatan2@\endcsname{\expandafter\Pgf@geT\the\pgf@y}{\expandafter\Pgf@geT\the\pgf@x}}% + \pgf@marshall% + \ifdim\pgfmathresult pt<0pt% + \pgfmathparse{\pgfmathresult+360}% + \fi% + \expandafter% + \endgroup\expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult}% +} + +% +% \pgfmathrotatepointaround +% +% Rotate point #1 about point #2 by #3 degrees. +% +\def\pgfmathrotatepointaround#1#2#3{% + \pgf@process{% + \pgf@process{#1}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{#2}% + \pgf@xa\pgf@x% + \pgf@ya\pgf@y% + \pgf@xb\pgf@x% + \pgf@yb\pgf@y% + \pgf@x=\pgf@xc% + \pgf@y=\pgf@yc% + \advance\pgf@x-\pgf@xa% + \advance\pgf@y-\pgf@ya% + \pgfmathsetmacro\angle{#3}% + \pgfmathsin@{\angle}% + \let\sineangle\pgfmathresult% + \pgfmathcos@{\angle}% + \let\cosineangle\pgfmathresult% + \pgf@xa\cosineangle\pgf@x% + \advance\pgf@xa-\sineangle\pgf@y% + \pgf@ya\sineangle\pgf@x% + \advance\pgf@ya\cosineangle\pgf@y% + \pgf@x\pgf@xb% + \pgf@y\pgf@yb% + \advance\pgf@x\pgf@xa% + \advance\pgf@y\pgf@ya% + }% +} + +% \pgfmathanglebetweenlines +% +% Calculate the clockwise angle between a line from point #1 +% to point #2 and a line from #3 to point #4. +% +\def\pgfmathanglebetweenlines#1#2#3#4{% + \begingroup% + \pgfmathanglebetweenpoints{#1}{#2}% + \let\firstangle\pgfmathresult% + \pgfmathanglebetweenpoints{#3}{#4}% + \let\secondangle\pgfmathresult% + \ifdim\firstangle pt>\secondangle pt\relax% + \pgfmathadd@{\secondangle}{360}% + \let\secondangle\pgfmathresult% + \fi% + \pgfmathsubtract@{\secondangle}{\firstangle}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% \pgfmathpointreflectalongaxis +% +% Reflects point #1 around an axis centered on #2 at an angle #3. +% +\def\pgfmathreflectpointalongaxis#1#2#3{% + \pgf@process{% + \pgfmathanglebetweenpoints{#2}{#1}% + \pgfmath@tempdima\pgfmathresult pt\relax% + \pgfmathparse{#3}% + \advance\pgfmath@tempdima-\pgfmathresult pt\relax% + \pgfmath@tempdima-2.0\pgfmath@tempdima% + \pgfmathrotatepointaround{#1}{#2}{\pgfmath@tonumber{\pgfmath@tempdima}}% + }% +} + + + +% \pgfmathpointintersectionoflineandarc +% +% A bit experimental at the moment: +% +% Locates the point where a line crosses an eliptical arc. If the line +% does not cross the arc, a meaningless point will result. +% +% #1 the point of the line on the "convex" side of the arc. +% #2 the point of the line on the "concave" side of the arc. +% #3 the center of the eliptical arc. +% #4 start angle of the arc. +% #5 end angle of the arc. +% #6 radii of the arc. +% +\def\pgfmathpointintersectionoflineandarc#1#2#3#4#5#6{% + \pgf@process{% + % + % Get the required angle. + % + \pgfmathanglebetweenpoints{#2}{#1}% + \let\x\pgfmathresult% + % + % Get the radii of the arc. + % + \pgfmath@in@{and }{#6}% + \ifpgfmath@in@% + \pgf@polar@#6\@@% + \else% + \pgf@polar@#6 and #6\@@% + \fi% + \edef\xarcradius{\the\pgf@x}% + \edef\yarcradius{\the\pgf@y}% + % + % Get the start and end angles of the arc... + % + \pgfmathsetmacro\s{#4}% + \pgfmathsetmacro\e{#5}% + % + % ...and also with rounding. + % + \pgfmathmod@{\s}{360}% + \ifdim\pgfmathresult pt<0pt\relax% + \pgfmathadd@{\pgfmathresult}{360}% + \fi% + \let\ss\pgfmathresult% + \pgfmathmod@{\e}{360}% + \ifdim\pgfmathresult pt<0pt\relax% + \pgfmathadd@{\pgfmathresult}{360}% + \fi% + \let\ee\pgfmathresult% + % + % Hackery for when arc straddles zero. + % + \ifdim\ee pt<\ss pt\relax% + \pgfmathadd@{\x}{180}% + \pgfmathmod@{\pgfmathresult}{360}% + \let\x\pgfmathresult% + \fi% + \def\m{360}% Measure of nearness. + \pgfmathadd@{\s}{\e}% + \pgfmathdivide@{\pgfmathresult}{2}% + \let\n\pgfmathresult% The best estimate (default to middle of arc). + \pgfmathloop% + \pgfmathadd@{\s}{\e}% + \pgfmathdivide@{\pgfmathresult}{2}% + \let\p\pgfmathresult% + \ifdim\p pt=\s pt\relax% + \else% + \pgfmathanglebetweenpoints{#2}{% + \pgfpointadd{#3}{% + \pgf@x\xarcradius\relax% + \pgfmathcos@{\p}% + \pgf@x\pgfmathresult\pgf@x% + \pgf@y\yarcradius\relax% + \pgfmathsin@{\p}% + \pgf@y\pgfmathresult\pgf@y% + }% + }% + % + % Hackery for when arc straddles zero. + % + \ifdim\ee pt<\ss pt\relax% + \pgfmathadd@{\pgfmathresult}{180}% + \pgfmathmod@{\pgfmathresult}{360}% + \fi% + \let\q\pgfmathresult% + % + % More hackery... + % + \ifdim\x pt>335pt\relax% + \ifdim\q pt<45pt\relax% + \pgfmathadd@{\q}{360}% + \let\q\pgfmathresult% + \fi% + \fi% + \ifdim\x pt=\q pt% Found it! + \pgfmathbreakloop% Breaks after current iteration is complete. + \else + \ifdim\x pt<\q pt\relax% + \let\e\p% + \else% + \let\s\p% + \fi% + \fi% + \pgfmathsubtract@{\x}{\q}% + \pgfmathabs@{\pgfmathresult}% + % + % Save the estimate if it is better than any previous estimate. + % + \ifdim\pgfmathresult pt<\m pt\relax% + \let\m\pgfmathresult% + \let\n\p% + \fi% + \repeatpgfmathloop% + \pgfpointadd{#3}{\pgfpointpolar{\n}{\xarcradius and \yarcradius}}% + }% +} + +% \pgfmathangleonellipse +% +% Find the angle corresponding to a point on the border of an ellispe. +% +% #1 - the point on the border. +% #2 - the radii of the ellipse. +% +\def\pgfmathangleonellipse#1#2{% + \begingroup% + \pgfmath@in@{and }{#2}% + \ifpgfmath@in@% + \pgf@polar@#2\@@% + \else% + \pgf@polar@#2 and #2\@@% + \fi% + \pgf@xa\pgf@x% + \pgf@ya\pgf@y% + \pgf@process{#1}% + \ifdim\pgf@x=0pt\relax% + \pgfutil@tempdima1pt\relax% + \else% + \pgfutil@tempdima\pgf@x% + \pgfmathdivide@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgfutil@tempdima}}% + \pgfutil@tempdima\pgfmathresult pt\relax% + \fi% + \ifdim\pgf@y=0pt\relax% + \pgfutil@tempdima1pt\relax% + \else% + \pgfmathdivide@{\pgfmath@tonumber{\pgf@y}}{\pgfmath@tonumber{\pgf@ya}}% + \pgfutil@tempdima\pgfmathresult\pgfutil@tempdima% + \pgfmathatan@{\pgfmath@tonumber{\pgfutil@tempdima}}% + \fi% + % + \pgfutil@tempdima\pgfmathresult pt\relax% + \ifdim\pgfutil@tempdima<0pt\relax% + \advance\pgfutil@tempdima360pt\relax% + \fi% + \ifdim\pgf@x<0pt\relax% + \ifdim\pgf@y=0pt\relax% + \pgfutil@tempdima180pt\relax% + \else% + \ifdim\pgf@y<0pt\relax% + \advance\pgfutil@tempdima180pt\relax% + \else% + \advance\pgfutil@tempdima-180pt\relax% + \fi% + \fi% + \else% + \ifdim\pgf@x=0pt\relax% + \ifdim\pgf@y<0pt\relax% + \pgfutil@tempdima270pt\relax% + \else% + \pgfutil@tempdima90pt\relax% + \fi% + \else% + \ifdim\pgf@y=0pt\relax% + \pgfutil@tempdima0pt\relax% + \fi% + \fi% + \fi% + \pgfmath@returnone\pgfutil@tempdima% + \endgroup% +} + + +% Local Variables: +% tab-width: 2 +% End: diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfloat.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfloat.code.tex new file mode 100644 index 0000000000..f133c6d495 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfloat.code.tex @@ -0,0 +1,2669 @@ +% Copyright 2019 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% +% This file contains methods for basic floating point arithmetics, rounding +% to arbitrary precision and number pretty printing. +% + + +\pgfkeys{ + % The bug 3430171 (wrong minus sign spacing in pgfmathprintnumber) + % has been fixed in 2.10 CVS. Since it changes the spacing, its + % effects can be undone with this compatibility switch. + /pgf/compat/number printer/.is choice, + /pgf/compat/number printer/2.10/.code={% + \def\pgfmathprintnumber@begingroup{\bgroup}% + \def\pgfmathprintnumber@endgroup{\egroup}% + }, + % I do not know the version number of the next release at this + % time. Please be so kind and KEEP THIS NAME INTACT. Add an alias + % if needed. + /pgf/compat/number printer/next after 2.10/.code={% + \def\pgfmathprintnumber@begingroup{\begingroup}% + \def\pgfmathprintnumber@endgroup{\endgroup}% + }, + % activate the fix by default. + /pgf/compat/number printer/next after 2.10,% +} + + +\newif\ifpgfmathfloatcomparison +\newif\ifpgfmathfloatroundhasperiod +\newif\ifpgfmathprintnumberskipzeroperiod + + +% used internally in grouped macros: +\toksdef\pgfmathfloat@tmptoks=1 +\newif\ifpgfmathfloat@fixed@digits@after@period +\newif\ifpgfmathfloatroundmayneedrenormalize +\toksdef\pgfmathfloat@a@Mtok=0 + +%% WARNING: avoid conflicting register names! +\let\pgfmathfloat@a@S=\c@pgf@counta +\let\pgfmathfloat@a@M=\pgf@xa +\let\pgfmathfloat@a@E=\c@pgf@countb +\let\pgfmathfloat@b@S=\c@pgf@countc +\let\pgfmathfloat@b@M=\pgf@xb +\let\pgfmathfloat@b@E=\c@pgf@countd + +% can be changed with options. +\def\pgfmathfloat@round@precision{2} + +% I introduced this to access the "original" precision in case a +% formatted changes it locally... in this case, the formatter may +% overwrite \pgfmathfloat@round@precision@orig to provide the original +% one. +% The default implementation here does nothing: +\def\pgfmathfloat@round@precision@orig{\pgfmathfloat@round@precision}% + +\gdef\pgfmathfloat@glob@TMP{} + + +% Computes a normalised floating point representation for #1 of the +% form +% [FLAGS] MANTISSE EXPONENT +% meaning +% [+-]X.XXXXXXX*10^C +% where +% X.XXXXXX is a mantissa with first number != 0, C is an integer and +% FLAGS contains the sign and some other special cases. +% +% This method does NOT use TeX Registers to represent the numbers! The +% computation is COMPLETELY STRING BASED. +% This allows numbers such at 10000000 or 5.23e-10 to be represented +% properly, although TeX-registers would produce overflow/underflow +% errors in these cases. +% +% It is to be used to compute logs, because log(X*10^Y) = log(X) + log(10)*Y +% +% Arguments: +% #1: an arbitrary number which shall be parsed. Maybe a macro. +% Examples: +% [+-]XXXXX.XXXXXX +% [+-]XXXXX.XXXXXXeXXXX +% [+-]0.0000XXXXXX +% [+-]0.0000XXXXXXeXXXX +% [+-]inf +% nan +% Maybe a macro containing such a number. +% +% Return value: +% \pgfmathresult will be \def'ed to +% FLAGS MANTISSE 'e' EXPONENT +% where +% FLAGS is a number in [0-5] where +% 0 == '0' (the number is +- 0.0), +% 1 == '+', +% 2 == '-', +% 3 == 'not a number' +% 4 == '+ infinity' +% 5 == '- infinity' +% +% MANTISSE is a normalised number 1 <= M < 10. It always contains a +% period and at least one digit after the period. +% +% EXPONENT is an integer value. +% +% Example: +% \pgfmathfloatparsenumber{1} +% -> \pgfmathresult = 11.0e0 +% \pgfmathfloatparsenumber{141.212} +% -> \pgfmathresult = 11.41212e2 +\def\pgfmathfloatparsenumber#1{% + \begingroup + \edef\pgfmathresult{#1}% + \expandafter\pgfflt@impl\pgfmathresult\pgfflt@EOI + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.0}% + \fi + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% The same as \pgfmathfloatparsenumber, but does not perform sanity checking. +% FIXME: there is no longer any difference here. +\let\pgfmathfloatqparsenumber=\pgfmathfloatparsenumber + +% Takes a floating point number #1 as input and writes flags to count +% register #2, mantissa to dimen register #3 and exponent to count +% register #4. +\def\pgfmathfloattoregisters#1#2#3#4{% + \expandafter\pgfmathfloat@decompose#1\relax{#2}{#3}{#4}% +} + +% the same, but writes the mantissa into a token register. +\def\pgfmathfloattoregisterstok#1#2#3#4{% + \expandafter\pgfmathfloat@decompose@tok#1\relax{#2}{#3}{#4}% +} + +% Extracts the flags of #1 into the count register #2. +\def\pgfmathfloatgetflags#1#2{% + \expandafter\pgfmathfloat@decompose@F#1\relax{#2}% +} +% Extracts the flags of #1 into the macro #2. +\def\pgfmathfloatgetflagstomacro#1#2{% + \expandafter\pgfmathfloat@decompose@Fmacro#1\relax{#2}% +}% + +% Extracts the mantissa of #1 into the dimen register #2. +\def\pgfmathfloatgetmantissa#1#2{% + \expandafter\pgfmathfloat@decompose@M#1\relax{#2}% +} +\let\pgfmathfloatgetmantisse=\pgfmathfloatgetmantissa +% Extracts the mantissa of #1 into the token register #2. +\def\pgfmathfloatgetmantissatok#1#2{% + \expandafter\pgfmathfloat@decompose@Mtok#1\relax{#2}% +} +\let\pgfmathfloatgetmantissetok=\pgfmathfloatgetmantissatok +% Extracts the exponent of #1 into the count register #2. +\def\pgfmathfloatgetexponent#1#2{% + \expandafter\pgfmathfloat@decompose@E#1\relax{#2}% +} + + +% Assigns \pgfmathresult to be a float encoded as +% <FLAGS><MANTISSE>e<EXPONENT> +% +% example: +% \pgfmathfloatcreate{1}{2.0}{10} +% \pgfmathfloat@to@FMeE@style\pgfmathresult +% -> +% \pgfmathresult is now '12.0e10' regardless of the internal float +% format. +\def\pgfmathfloat@to@FMeE@style#1{\expandafter\pgfmathfloat@to@FMeE@style@#1\relax\relax}% +\def\pgfmathfloat@to@FMeE@style@#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@to@FMeE@style@@% + \else + \expandafter\pgfmathfloat@to@FMeE@style@error% + \fi + #1#2% +}% +\def\pgfmathfloat@to@FMeE@style@@#1Y#2e#3]\relax\relax{\def\pgfmathresult{#1#2e#3}}% +\def\pgfmathfloat@to@FMeE@style@error#1\relax\relax{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{% + \noexpand\pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + }% + \endgroup + \pgfmathfloat@decompose@TMP +}% + + +% decomposes a lowlevel floating point representation into flags, +% mantissa and exponent. +% +% #4: integer register for the flags. +% #5: dimen registers for the mantissa. +% #6: integer register for the exponent. +% +% \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E +% -> the three temp registers contain flags, mantissa and exponent +\def\pgfmathfloat@decompose#1#2{% sanitize! + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@% + \else + \expandafter\pgfmathfloat@decompose@error% + \fi + #1#2% +} +\def\pgfmathfloat@decompose@#1Y#2e#3]\relax#4#5#6{% + #4=#1\relax + #5=#2pt % keep space here. + #6=#3\relax% +} + +% overloaded, #5 needs to be a token register for the mantissa. +% @see also \pgfmathfloatvalueof which does also employ the load +% level repr. +% \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E +% -> the three temp registers contain flags, mantissa and exponent +\def\pgfmathfloat@decompose@tok#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@tok@% + \else + \expandafter\pgfmathfloat@decompose@tok@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@tok@#1Y#2e#3]\relax#4#5#6{% + #4=#1\relax + #5={#2}% + #6=#3\relax% +} +% overloaded, returns only ONE of the three components into #4: +% \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S +% -> \pgfmathfloat@a@S contains the flags field. +\def\pgfmathfloat@decompose@F#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@F@% + \else + \expandafter\pgfmathfloat@decompose@F@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@Fmacro#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@Fmacro@% + \else + \expandafter\pgfmathfloat@decompose@F@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@M#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@M@% + \else + \expandafter\pgfmathfloat@decompose@M@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@E#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@E@% + \else + \expandafter\pgfmathfloat@decompose@E@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@Mtok#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@Mtok@% + \else + \expandafter\pgfmathfloat@decompose@Mtok@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@F@#1Y#2e#3]\relax#4{#4=#1\relax}% +\def\pgfmathfloat@decompose@Fmacro@#1Y#2e#3]\relax#4{\def#4{#1}}% +\def\pgfmathfloat@decompose@M@#1Y#2e#3]\relax#4{#4=#2pt}% +\def\pgfmathfloat@decompose@Mtok@#1Y#2e#3]\relax#4{#4={#2}}% +\def\pgfmathfloat@decompose@E@#1Y#2e#3]\relax#4{#4=#3\relax}% + +\def\pgfmathfloat@decompose@error#1\relax#2#3#4{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{% + \noexpand#2=\the\pgfmathfloat@a@S\space + \noexpand#3=\the\pgfmathfloat@a@Mtok pt + \noexpand#4=\the\pgfmathfloat@a@E\space + }% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@tok@error#1\relax#2#3#4{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{% + \noexpand#2=\the\pgfmathfloat@a@S\space + \noexpand#3={\the\pgfmathfloat@a@Mtok}% + \noexpand#4=\the\pgfmathfloat@a@E\space + }% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@F@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2=\the\pgfmathfloat@a@S\space}% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@M@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2=\the\pgfmathfloat@a@Mtok pt }% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@Mtok@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2={\the\pgfmathfloat@a@Mtok}}% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@E@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2=\the\pgfmathfloat@a@E\space}% + \endgroup + \pgfmathfloat@decompose@TMP +}% +% Takes a floating point number #1 as input and writes flags to macro +% #2, mantissa to macro #3 and exponent to macro #4. +\def\pgfmathfloattomacro#1#2#3#4{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \xdef\pgfmathfloat@glob@TMP{% + \noexpand\def\noexpand#2{\the\pgfmathfloat@a@S}% + \noexpand\def\noexpand#3{\the\pgfmathfloat@a@Mtok}% + \noexpand\def\noexpand#4{\the\pgfmathfloat@a@E}% + }% + \endgroup + \pgfmathfloat@glob@TMP +} + + +% Defines \pgfmathresult as the floating point number encoded by +% the flags #1, mantissa #2 and exponent #3. +% +% All arguments are characters and will be expanded using '\edef'. +\def\pgfmathfloatcreate#1#2#3{% + \edef\pgfmathresult{#1Y#2e#3]}% +}% +% This is the character present in any low-level floating point +% number. It is assumed to be the SECOND character of a float (after +% the flags integer). +\def\pgfmathfloat@POSTFLAGSCHAR{Y} + + + +% Converts a composed floating point representation to fixed point. +% +% Example: +% \pgfmathfloattofixed{142e1} +% -> \pgfmathresult = 42.0 +\def\pgfmathfloattofixed@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + \def\pgfmathresult{0.0}% + \or + \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax + \or + \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax + \pgfmathfloat@a@Mtok=\expandafter{\pgfmathresult}% + \edef\pgfmathresult{-\the\pgfmathfloat@a@Mtok}% + \or\def\pgfmathresult{nan}% + \or\def\pgfmathresult{inf}% + \or\def\pgfmathresult{-inf}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloattofixed=\pgfmathfloattofixed@ + +% Converts a float to an integer (in integer format). +% +% @see \pgfmathfloatint +\def\pgfmathfloattoint#1{% + \pgfmathfloattofixed{#1}% + \expandafter\pgfmathfloattoint@@\pgfmathresult\relax +}% +\def\pgfmathfloattoint@@#1.#2\relax{% + \def\pgfmathresult{#1}% +}% + +% Converts a floating point number to scientific format 1.234e5. +% +% This operation is very fast. +\def\pgfmathfloattosci@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + \def\pgfmathresult{0.0e0}% + \or + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \or + \edef\pgfmathresult{-\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \or\def\pgfmathresult{nan}% + \or\def\pgfmathresult{inf}% + \or\def\pgfmathresult{-inf}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloattosci=\pgfmathfloattosci@ + +% Expands a floating point number to scientific format 1.234e5. +% +% This operation is very fast. +\def\pgfmathfloatvalueof#1{\expandafter\pgfmathfloatvalueof@@#1@@}% + +% Make it fool proof such that the following arguments work: +% \pgfmathfloatvalueof{1Y1.0e1} -> 1.0e1 +% \pgfmathfloatvalueof{2Y1.0e1} -> -1.0e1 +% and wrong arguments as well: +% \pgfmathfloatvalueof{1} -> 1 +% \pgfmathfloatvalueof{1e2} -> 1e2 +\def\pgfmathfloatvalueof@@#1#2{% + \if#2Y% + % keep in mind that \pgfmathfloatvalueof should be expandable! + % We must not use \let here. Let's hope that #1 and #2 are + % single tokens (not something which was enclosed by curly + % braces...) + \expandafter\pgfmathfloatvalueof@@@\expandafter#1\expandafter#2% + \else + % Oh - no float!? Ok, we cannot report errors in this context. + % So: make it a feature and return the input argument as-is. + % Might be useful, in fact... + \expandafter\pgfmathfloatvalueof@abort\expandafter#1\expandafter#2% + \fi +} +\def\pgfmathfloatvalueof@@@#1Y#2e#3]@@{% + \ifcase#1 % + 0.0e0% + \or + #2e#3% + \or + -#2e#3% + \or nan% + \or inf% + \or -inf% + \fi +}% +\def\pgfmathfloatvalueof@abort#1@@{#1}% + + + +% Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns +% the result into \pgfmathresult. +% +% Any trailing zeros after the period are discarded. +% See \pgfmathroundtozerofill if you want trailing zeros and fixed +% width. +% +% This method is PURELY text based and can work with arbitrary +% precision (well, limited to TeX's stack size and integer size). +% +% Examples: +% \pgfmathroundto{1} +% -> \pgfmathresult = '1' +% +% \pgfmathroundto{19999.9996} +% -> \pgfmathresult = '20000' +% +% Arguments: +% #1 may be either a number or a macro (\pgfmathresult is allowed) expanding to a number. +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set. +\def\pgfmathroundto#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodfalse + \pgfmathroundto@impl{#1}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + + +% Overloaded method. +% +% This variant always uses a FIXED number behind the period and fills +% in zeros if necessary. +% Examples: +% \pgfmathroundtozerofill{1} +% -> \pgfmathresult = '1.00' +% +% \pgfmathroundtozerofill{19999.9996} +% -> \pgfmathresult = '20000.00' +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set. +\def\pgfmathroundtozerofill#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodtrue + \pgfmathroundto@impl{#1}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% see \pgfmathprintnumber@fixed@style for docs +\def\pgfmathprintnumber@fixed@styleDEFAULT#1#2#3e#4\relax{% + \begingroup + \pgfkeysgetvalue{/pgf/number format/set decimal separator}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP + \pgfkeysgetvalue{/pgf/number format/@dec sep mark}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK + \pgfkeysgetvalue{/pgf/number format/set thousands separator}\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP + \c@pgf@counta=#4\relax % it is the exponent here. + \ifnum#2=0 + \c@pgf@counta=0 + \fi + \def\pgfmathresult{}% + \ifpgfmathfloatroundhasperiod + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@period#1\pgfmathfloat@EOI + \else + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI% + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@period#1.#2\pgfmathfloat@EOI{% + \ifpgfmathprintnumberskipzeroperiod + \def\pgfmathfloat@loc@TMPb{#1}% + \ifx\pgfmathfloatparsenumber@tok@ZERO\pgfmathfloat@loc@TMPb + \else + \def\pgfmathfloat@loc@TMPc{-0}% + \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb + \def\pgfmathresult{-}% + \else + \def\pgfmathfloat@loc@TMPc{+0}% + \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb + \def\pgfmathresult{+}% + \else + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI + \fi + \fi + \fi + \else + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI + \fi + \ifpgfmathprintnumber@thousand@sep@in@fractional + \let\pgfmathresultfractional\pgfutil@empty% + \pgfmathprintnumber@thousand@sep@in@fractional#2MMMM\@@ + \else + \def\pgfmathresultfractional{#2}% + \fi + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}% + \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP}% + \toks3=\expandafter{\pgfmathresultfractional}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 \the\toks3 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP +}% + +% assigns \pgfmathresult such that it contains the formatted result. +% It assumes that none of the following tokens contains a period. +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod{% + \ifx\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP\pgfutil@empty + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% + \else + \ifnum\c@pgf@counta<0\relax % exponent of the number in this context + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% + \else + \ifnum\c@pgf@counta<\pgfkeysvalueof{/pgf/number format/min exponent for 1000 sep}\relax + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% + \else + \advance\c@pgf@counta by1 % counta:= total number of digits, N. + \c@pgf@countb=\c@pgf@counta + \divide\c@pgf@countb by3 % countb := N DIV 3 + \c@pgf@countc=\c@pgf@countb + \multiply\c@pgf@countc by3 + \advance\c@pgf@counta by-\c@pgf@countc% now counta := N MOD 3 + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign + }% + \fi + \fi + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign#1{% + \def\pgfmathfloat@loc@TMPb{#1}% + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@MINUS + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% + \let\pgfmathfloat@loc@TMPb=\pgfutil@empty + \else + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@PLUS + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% + \let\pgfmathfloat@loc@TMPb=\pgfutil@empty + \else + \ifpgfmathprintnumber@showpositive + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult +}% + \fi + \fi + \fi + \ifnum\c@pgf@counta>0 % \c@pgf@counta = N MOD 3 in this context + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits\pgfmathfloat@loc@TMPb + }% + \else + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird\pgfmathfloat@loc@TMPb + }% + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits#1#2{% + \ifcase\c@pgf@counta % = N MOD 3 in this context + % does not happen per construction + \or + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird#2% + }% + \or + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1#2}% + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird% + }% + \fi + \ifnum\c@pgf@countb>0\relax % \c@pgf@countb = N DIV 3 in this context + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird#1#2#3{% + \ifnum\c@pgf@countb>0\relax + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1#2#3}% + \advance\c@pgf@countb by-1 + \ifnum\c@pgf@countb>0\relax + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \fi + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird% + }% + \else + % in this case, #1#2#3 are expected to be + % \pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI + %-------------------------------------------------- + % \def\pgfmathfloat@loc@TMPb{\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI}% + % \def\pgfmathfloat@loc@TMPc{#1#2#3}% + % \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb + % \else + % \pgfmath@error{INTERNAL ERROR in fixed style - The input sequence did not terminate as expected; which indicates a wrong exponent argument provided to \string\pgfmathprintnumber@fixed@style}{}% + % \fi + %-------------------------------------------------- + \let\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT=\relax + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} + +% \pgfmathprintnumber@thousand@sep@in@fractional 01234525MMMM\@@ +% -> +% 012<sep>345<sep>25 +\def\pgfmathprintnumber@thousand@sep@in@fractional#1#2#3#4{% + \if#4M% + % Ok, no further separator + \def\pgfmathprint@next{\pgfmathprintnumber@thousand@sep@in@fractional@finish#1#2#3#4}% + \else + \begingroup + \toks0=\expandafter{\pgfmathresultfractional}% + \toks1={#1#2#3}% + \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }% + \endgroup + \let\pgfmathresultfractional=\pgfmathfloat@glob@TMP + \def\pgfmathprint@next{\pgfmathprintnumber@thousand@sep@in@fractional#4}% + \fi + \pgfmathprint@next +}% +\def\pgfmathprintnumber@thousand@sep@in@fractional@finish#1M{% + \expandafter\def\expandafter\pgfmathresultfractional\expandafter{\pgfmathresultfractional #1}% + \pgfmathprintnumber@thousand@sep@in@fractional@finish@ +}% +\def\pgfmathprintnumber@thousand@sep@in@fractional@finish@#1\@@{}% + +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall#1{% + \def\pgfmathfloat@loc@TMPb{#1}% + \let\pgfmathfloat@loc@TMPc=\pgfutil@empty + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@MINUS + \else + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@PLUS + \else + \ifpgfmathprintnumber@showpositive + \def\pgfmathfloat@loc@TMPc{+}% + \fi + \fi + \fi + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall@\pgfmathfloat@loc@TMPc#1% +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall@#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI{% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% +}% + +% @deprecated. It has been replaced by \pgfmathprintnumber@fixed@styleDEFAULT +% #1 maybe a macro +\def\pgfmathprintnumber@fixed@stylePERIOD#1#2#3e#4\relax{% + \def\pgfmathresult{#1}% +} + +% @deprecated. It has been replaced by \pgfmathprintnumber@fixed@styleDEFAULT +% #1 maybe a macro +\def\pgfmathprintnumber@fixed@styleCOMMA#1#2#3e#4\relax{% + \ifpgfmathfloatroundhasperiod + \expandafter\pgfmathprintnumber@fixed@styleCOMMA@impl#1\pgfmathfloat@EOI + \else + \def\pgfmathresult{#1}% + \fi +} +\def\pgfmathprintnumber@fixed@styleCOMMA@impl#1.#2\pgfmathfloat@EOI{\def\pgfmathresult{#1{,}#2}} + +% The default style to display fixed point numbers. +% +% It does not apply numerics, but it is responsible for typesetting the +% rounded number. +% It can access the \ifpgfmathfloatroundhasperiod boolean. +% +% Arguments: +% #1#2#3e#4\relax + +% Input: +% #1 the fixed point number to be displayed (maybe a macro). +% #2#3e#4: the (possibly unformatted) floating point representation +% which belongs to #1. This format is returned (only!) by +% \pgfmathfloat@to@FMeE@style. +% It is used to determine sign and exponent. +\let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT + + +% Rounds a normalized floating point number to \pgfmathfloat@round@precision +% digits precision and writes the result to \pgfmathresult. +% +% This method uses \pgfmathroundto for the mantissa. +% +% @see pgfmathfloatroundzerofill +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to +% whether the final mantissa #5 has a period or not. +\def\pgfmathfloatround#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodfalse + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatround@impl + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% Overload. +% +% This method uses a fixed width for the mantissa and fills in zeros +% if necessary. +% +% This method uses \pgfmathroundtozerofill for the mantissa. +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to +% whether the final mantissa #5 has a period or not. +\def\pgfmathfloatroundzerofill#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodtrue + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatround@impl + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\newif\ifpgfmathfloatround@allow@empty@mantissa +\def\pgfmathfloatround@mantissa@ONE{1pt }% + +% #1: sign +% #2: mantissa +% #3: exponent +% #4: CODE to display if the mantissa is drawn. +% This code will be shown just before the exponent. +% Example: #4=\cdot +% #5: CODE to display if the mantissa is NOT draw. (unused currently) +% Might be used to display '10^1' instead of '1*10^1'. +% #6: CODE to display the exponent. +\def\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax#4#5#6{% + \pgfkeysgetvalue{/pgf/number format/@sci exponent mark}\pgfmathfloatrounddisplaystyle@e@mark + \ifcase#1\relax + \pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \or + \def\pgfmathfloat@loc@TMPa{1}% "should draw mantissa=1" + \ifpgfmathfloatround@allow@empty@mantissa + \else + \ifdim#2pt=\pgfmathfloatround@mantissa@ONE + \def\pgfmathfloat@loc@TMPa{0}% do not draw it. + \fi + \fi + % + \if1\pgfmathfloat@loc@TMPa + \pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \else + \def\pgfmathfloat@loc@TMPa{0}% + \pgfmathfloatrounddisplaystyle@shared@impl@{#5}{#6}% + \fi + \or + \def\pgfmathfloat@loc@TMPa{1}% "should draw mantissa=1" + \ifpgfmathfloatround@allow@empty@mantissa + \else + \ifdim#2pt=\pgfmathfloatround@mantissa@ONE + \def\pgfmathfloat@loc@TMPa{0}% do not draw it. + \fi + \fi + % + \if1\pgfmathfloat@loc@TMPa + \pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \else + \def\pgfmathfloat@loc@TMPa{0}% + \pgfmathfloatrounddisplaystyle@shared@impl@{-#5}{#6}% + \fi + \or + \pgfmathfloatrounddisplaystyle@shared@impl@@{\hbox{NaN}}{}% + \or + \ifpgfmathprintnumber@showpositive + \pgfmathfloatrounddisplaystyle@shared@impl@@{+\infty}{}% + \else + \pgfmathfloatrounddisplaystyle@shared@impl@@{\infty}{}% + \fi + \or + \pgfmathfloatrounddisplaystyle@shared@impl@@{-\infty}{}% + \fi +} + +% #1: the part before the exponent code +% #2: the part for the exponent code. +\def\pgfmathfloatrounddisplaystyle@shared@impl@#1#2{% + \pgfmathprintnumber@begingroup + \toks0={#1}% + \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \pgfmathprintnumber@endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP +}% +% Same as \pgfmathfloatrounddisplaystyle@shared@impl@, but it also +% inserts the '@dec sep mark' at the end. +\def\pgfmathfloatrounddisplaystyle@shared@impl@@#1#2{% + \pgfmathprintnumber@begingroup + \toks0={#1}% + \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}% + \pgfkeysgetvalue{/pgf/number format/@dec sep mark}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK + \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }% + \pgfmathprintnumber@endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP +} + +\def\pgfmathfloatrounddisplaystyle@std#1#2e#3\relax{% + \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{\cdot}{}{10^{#3}}% +} +\def\pgfmathfloatrounddisplaystyle@subscript#1#2e#3\relax{% + \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{_{#3}}% +} +\def\pgfmathfloatrounddisplaystyle@superscript#1#2e#3\relax{% + \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{^{#3}}% +} +\def\pgfmathfloatrounddisplaystyle@e#1#2e#3\relax{% + \ifnum#3<0\relax + \pgfmathprintnumber@begingroup + \count0=#3\relax + \multiply\count0 by-1 + \xdef\pgfmathfloat@glob@TMP{e{-}\the\count0}% + \pgfmathprintnumber@endgroup% + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \else + \def\pgfmathresult{e{+}#3}% + \fi + \def\pgfmathfloat@loc@TMPb{\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}}% + \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}% +} +\def\pgfmathfloatrounddisplaystyle@E#1#2e#3\relax{% + \ifnum#3<0\relax + \pgfmathprintnumber@begingroup + \count0=#3\relax + \multiply\count0 by-1 + \xdef\pgfmathfloat@glob@TMP{E{-}\the\count0}% + \pgfmathprintnumber@endgroup% + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \else + \def\pgfmathresult{E{+}#3}% + \fi + \def\pgfmathfloat@loc@TMPb{\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}}% + \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}% +} + +\def\pgfmathfloatrounddisplaystyle@generic#1#2e#3\relax{% + \begingroup + \pgfkeysvalueof {/pgf/number format/sci generic/@/.@cmd}{#3}{#1}{#2}\pgfeov + \pgfkeysgetvalue{/pgf/number format/sci generic/mantissa sep}\pgfmathdisplay@aftermantissa + \pgfkeysgetvalue{/pgf/number format/sci generic/empty mantissa sep}\pgfmathdisplay@nomantissa + \pgfkeysgetvalue{/pgf/number format/sci generic/exponent}\pgfmathdisplay@e + \toks0=\expandafter{\pgfmathdisplay@aftermantissa}% + \toks1=\expandafter{\pgfmathdisplay@nomantissa}% + \toks2=\expandafter{\pgfmathdisplay@e}% + \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\noexpand\relax{\the\toks0}{\the\toks1}{\the\toks2}}% + \endgroup + \pgfmathfloat@glob@TMP +} + +% A macro which takes the argument '<SIGN><MANTISSE>e<EXPONENT>' and +% expands to the final TeX-representation for that floating point +% number. +% +% PRECONDITION: +% the floating point number has already been rounded properly and +% the mantissa has been rounded correctly. +% +% The argument needs to be in the format returned by +% \pgfmathfloat@to@FMeE@style and terminated by '\relax'. +\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std +\newif\ifpgfmathfloat@usezerofill@sci +\newif\ifpgfmathfloat@usezerofill@fixed +\newif\ifpgfmathprintnumber@assumemathmode +\newif\ifpgfmathprintnumber@showpositive +\newif\ifpgfmathprintnumber@frac@warn +\newif\ifpgfmathprintnumber@frac@whole +\newif\ifpgfmathparsenumber@comma@as@period + +\long\def\pgfmathfloatfrac@verbatim#1#2{#1/#2}% + +\let\pgfmathround@@orig=\pgfmathround@ + +% 2 = compatible +% 0 = no +% 1 = yes +\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{2}% + +\newif\ifpgfmathprintnumber@thousand@sep@in@fractional +\pgfkeys{% + /pgf/number format/.is family, + /pgf/number format, + fixed/.code= \pgfmath@set@number@printer{pgfmathprintnumber@FIXED}, + sci/.code= \pgfmath@set@number@printer{pgfmathprintnumber@SCI}, + std/.code= {\pgfmath@set@number@printer{pgfmathprintnumber@STD}\pgfmathprintnumber@STD@setparam{#1}}, + std/.default=,% + relative round mode/.is choice, + relative round mode/fixed/.code={\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{1}}, + relative round mode/mantissa/.code={\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{0}}, + relative round mode/compatible/.code={\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{2}}, + % relative={<exponent base 10>} + relative/.code={% + \pgfmath@set@number@printer{pgfmathprintnumber@RELATIVE}% + \pgfmathround@@orig{#1}% + \expandafter\pgfmathfloattoint@@\pgfmathresult\relax + \let\pgfmathprintnumber@RELATIVE@param=\pgfmathresult + },% + relative/.value required, + relative*/.style={/pgf/number format/relative={#1},/pgf/number format/relative round mode=fixed}, + every relative/.style=std, + relative style/.style={/pgf/number format/every relative/.append style={#1}}, + fixed relative/.code= \pgfmath@set@number@printer{pgfmathprintnumber@FIXED@RELATIVE}, + int detect/.code= \pgfmath@set@number@printer{pgfmathprintnumber@INT@DETECT}, + int trunc/.code= \pgfmath@set@number@printer{pgfmathprintnumber@INT@TRUNC}, + frac/.code= \pgfmath@set@number@printer{pgfmathprintnumber@frac},% + frac TeX/.initial=\frac, + frac whole format/.code={\def\pgfmathresult{#1}}, + frac denom/.initial=, + frac whole/.is if=pgfmathprintnumber@frac@whole, + frac whole=true, + frac shift/.initial=4, + frac warning/.is if=pgfmathprintnumber@frac@warn, + frac warning=true, + assume math mode/.is if=pgfmathprintnumber@assumemathmode, + assume math mode/.default=true, + fixed zerofill/.is if= pgfmathfloat@usezerofill@fixed, + fixed zerofill/.default=true, + sci zerofill/.is if= pgfmathfloat@usezerofill@sci, + sci zerofill/.default=true, + zerofill/.style= {/pgf/number format/fixed zerofill={#1},/pgf/number format/sci zerofill={#1}}, + zerofill/.default= true, + precision/.store in= \pgfmathfloat@round@precision, + sci precision/.code={% + \edef\pgfmathfloat@loc@TMPa{#1}% + \ifx\pgfmathfloat@loc@TMPa\pgfutil@empty + \def\pgfmathprintnumber@sci@precision{\pgfmathfloat@round@precision}% + \else + \let\pgfmathprintnumber@sci@precision=\pgfmathfloat@loc@TMPa + \fi + },% + sci precision/.default=, + sci precision=, + fixed default/.code= {\let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT}, + set decimal separator/.initial=, + dec sep/.style={/pgf/number format/set decimal separator={#1}}, + @dec sep mark/.initial=, + @sci exponent mark/.initial=, + set thousands separator/.initial=, + 1000 sep in fractionals/.is if=pgfmathprintnumber@thousand@sep@in@fractional, + 1000 sep in fractionals/.default=true, + 1000 sep/.style={/pgf/number format/set thousands separator={#1}}, + min exponent for 1000 sep/.initial=0, + use period/.style= {/pgf/number format/set decimal separator={.},/pgf/number format/set thousands separator={{{,}}}}, + use comma/.style= {/pgf/number format/set decimal separator={{{,}}},/pgf/number format/set thousands separator={.}}, + showpos/.is if=pgfmathprintnumber@showpositive, + showpos/.default=true, + print sign/.is if=pgfmathprintnumber@showpositive, + print sign/.default=true, + read comma as period/.is if=pgfmathparsenumber@comma@as@period, + read comma as period/.default=true, + skip 0./.is if=pgfmathprintnumberskipzeroperiod, + skip 0./.default=true, + skip 0.= false, + use period, + sci 10^e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std}, + sci 10e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std}, + sci e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@e}, + sci E/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@E}, + sci subscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@subscript}, + sci superscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@superscript}, + sci generic/.code= {% + \let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@generic + \pgfkeysdefargs{/pgf/number format/sci generic/@}% + {##1##2##3}% + {\pgfqkeys{/pgf/number format/sci generic}{#1}}% + }, + sci generic/mantissa sep/.initial=,% + sci generic/empty mantissa sep/.initial=,% + sci generic/mantisse sep/.style={/pgf/number format/sci generic/mantissa sep={#1}},% + sci generic/empty mantisse sep/.style={/pgf/number format/sci generic/empty mantissa sep={#1}},% + sci generic/exponent/.initial=,% + sci generic/.value required, + verbatim/.code={% + \pgfqkeys{/pgf/number format}{% + sci generic={mantissa sep=,exponent={e##1}}, + 1000 sep=, + skip 0.=false, + print sign=false, + dec sep=., + assume math mode, + frac TeX=\pgfmathfloatfrac@verbatim, + frac whole format/.code={\def\pgfmathresult{##1 }}, + @dec sep mark=, + @sci exponent mark=, + }% + }, + retain unit mantissa/.is if=pgfmathfloatround@allow@empty@mantissa, + retain unit mantissa/.default=true, + retain unit mantissa=true, + % + % allows to replace the implementation, for example + % 'implementation=\num'. This is experimental -- it is unclear + % if all consumers work well since they rely on the keys in + % /pgf/number format. + implementation/.code={\def\pgfmathprintnumber@protected{#1}}, +} + + + +\def\pgfmathprintnumber@STD#1{% + % parse the input: + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@STD@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@STD@setparam#1{% + \edef\pgfmathfloat@loc@TMPb{#1}% + \ifx\pgfmathfloat@loc@TMPb\pgfutil@empty + % DEFAULT for lower and upper bound. + \def\pgfmathprintnumber@STD@getlowerbound{% + \c@pgf@counta=\pgfmathfloat@round@precision@orig\relax + \divide\c@pgf@counta by-2\relax + }% + \def\pgfmathprintnumber@STD@upperbound{4}% + \else + \expandafter\pgfutil@in@\expandafter:\expandafter{\pgfmathfloat@loc@TMPb}% + \ifpgfutil@in@ + % we have -4:5 or something like that. + % parse both values: + \def\pgfmathfloat@loc@TMPa##1:##2\relax{% + \edef\pgfmathprintnumber@STD@getlowerbound{% + \noexpand\c@pgf@counta=##1\space + }% + \edef\pgfmathprintnumber@STD@upperbound{##2}% + }% + \expandafter\pgfmathfloat@loc@TMPa\pgfmathfloat@loc@TMPb\relax + \else + % we have just the lower bound: + \def\pgfmathprintnumber@STD@upperbound{4}% + \edef\pgfmathprintnumber@STD@getlowerbound{% + \noexpand\c@pgf@counta=\pgfmathfloat@loc@TMPb\space + }% + \fi + \fi +}% + +\def\pgfmathprintnumber@STD@issci#1#2e#3\relax{% + \expandafter\ifnum#1<3 + \expandafter\ifnum#3>\pgfmathprintnumber@STD@upperbound\relax + \pgfmathprintnumber@SCI@issci#1#2e#3\relax% + \else + \begingroup + \pgfmathprintnumber@STD@getlowerbound + \ifnum#3<\c@pgf@counta + \pgfmathprintnumber@SCI@issci#1#2e#3\relax% + \else + \pgfmathprintnumber@FIXED@issci#1#2e#3\relax% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup + \fi + \else% nan or inf: + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi +} + +\def\pgfmathprintnumber@RELATIVE#1{% + % parse the input: + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@RELATIVE@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn{% + \pgf@typeout{! Package pgf warning: the use of /pgf/number format/relative is discouraged (buggy). Please use 'relative*' instead or type \string\pgfkeys{/pgf/number format/relative round mode=fixed} into your preamble.}% + \global\let\pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn=\relax +} + +\def\pgfmathprintnumber@RELATIVE@issci#1#2e#3\relax{% + \begingroup + % format X / 10^{relative}: + \c@pgf@counta=#3\relax + \advance\c@pgf@counta by-\pgfmathprintnumber@RELATIVE@param\relax + \pgfmathfloatcreate{#1}{#2}{\the\c@pgf@counta}% + % OK, round it to the desired precision: + \if0\pgfmathprintnumber@RELATIVE@choice@roundtofixed + % relative round mode=mantissa + \def\b@round@fixed{0}% + \else + \if1\pgfmathprintnumber@RELATIVE@choice@roundtofixed + % relative round mode=fixed + \def\b@round@fixed{1}% + \else + \pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn + % relative round mode=compatible + \ifnum\c@pgf@counta>0 + % hm. for positive exponents, we should round the + % mantissa rather than only the fractional part. + \def\b@round@fixed{0}% + \else + % negative exponent -> round fixed representation: + \def\b@round@fixed{1}% + \fi + \fi + \fi + \if1\b@round@fixed + % round fixed representation: + \pgfmathfloattofixed\pgfmathresult + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \pgfmathfloatroundhasperiodtrue% make sure the code below works: + \else + % round the mantissa: + \expandafter\pgfmathfloatround\expandafter{\pgfmathresult}% + \fi + % Now, compute result * 10^{relative} and format the result: + \pgfmathfloattoregisterstok\pgfmathresult\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S=0 + \pgfmathfloat@a@E=\pgfmathfloat@a@S % avoid 0 * 10^8 + \else + \advance\pgfmathfloat@a@E by+\pgfmathprintnumber@RELATIVE@param\relax + \fi + \edef\pgfmathresultX{% + \the\pgfmathfloat@a@S + \the\pgfmathfloat@a@Mtok + \ifpgfmathfloatroundhasperiod\else.0\fi + e\the\pgfmathfloat@a@E}% + % call another formatter for the result (but avoid rounding inside of it): + \pgfqkeys{/pgf/number format}{/pgf/number format/every relative, + fixed zerofill=false,% useless here! + sci zerofill=false}% + \ifx\pgfmathprintnumber@issci\pgfmathprintnumber@RELATIVE@issci + \pgfmath@error{The '/pgf/number format/every relative' style should set a valid display style}{}% + \fi + \let\pgfmathfloat@round@precision@orig=\pgfmathfloat@round@precision + \def\pgfmathfloat@round@precision{9999}% + \expandafter\pgfmathprintnumber@issci\pgfmathresultX\relax% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\def\pgfmathprintnumber@FIXED@RELATIVE#1{% + % parse the input: + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@FIXED@RELATIVE@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@FIXED@RELATIVE@issci#1#2e#3\relax{% + \begingroup + \pgfmathfloatcreate{#1}{#2}{#3}% + % we want the first <precision> digits - not the first + % <precision>+1 digits: + \c@pgf@counta=\pgfmathfloat@round@precision\relax + \advance\c@pgf@counta by-1 + \edef\pgfmathfloat@round@precision{\the\c@pgf@counta}% + \pgfmathfloatround{\pgfmathresult}% + \pgfmathfloattoregisterstok\pgfmathresult\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S=0 + \pgfmathfloat@a@E=\pgfmathfloat@a@S % avoid 0 * 10^8 + \fi + \edef\pgfmathresultX{% + \the\pgfmathfloat@a@S + \the\pgfmathfloat@a@Mtok + \ifpgfmathfloatroundhasperiod\else.0\fi + e\the\pgfmathfloat@a@E}% + \let\pgfmathfloat@round@precision@orig=\pgfmathfloat@round@precision + \pgfmathfloat@usezerofill@fixedfalse + \def\pgfmathfloat@round@precision{9999}% typeset all remaining digits! + \expandafter\pgfmathprintnumber@FIXED@issci\pgfmathresultX\relax% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\def\pgfmathprintnumber@frac#1{% + % parse the input: + \pgfmathfloatparsenumber{#1}% + \pgfmathfloatgetfrac{\pgfmathresult}% + \expandafter\pgfmathprintnumber@frac@formatresult\pgfmathresult +} +\def\pgfmathprintnumber@frac@issci#1#2e#3\relax{% + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloatgetfrac{\pgfmathresult}% + \expandafter\pgfmathprintnumber@frac@formatresult\pgfmathresult +} +\def\pgfmathprintnumber@frac@formatresult#1#2#3{% + \begingroup + \pgfkeysgetvalue{/pgf/number format/frac TeX}\pgfmathresult + \toks0=\expandafter{\pgfmathresult}% + \def\pgfmathfloat@loc@TMPa{#1}% + \ifx\pgfmathfloat@loc@TMPa\pgfutil@empty + \ifpgfmathprintnumber@showpositive + \def\pgfmathfloat@loc@TMPa{+}% + \fi + \else + \ifx\pgfmathfloat@loc@TMPa-% + \else + \ifx\pgfmathfloat@loc@TMPa+% + \else + \ifpgfmathprintnumber@showpositive + \edef\pgfmathfloat@loc@TMPa{+\pgfmathfloat@loc@TMPa}% + \fi + \def\pgfmathfloat@loc@TMPb{\pgfkeysvalueof{/pgf/number format/frac whole format/.@cmd}}% + \expandafter\pgfmathfloat@loc@TMPb\pgfmathfloat@loc@TMPa\pgfeov + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \fi + \fi + \fi + \toks1=\expandafter{\pgfmathfloat@loc@TMPa}% + \edef\pgfmathresult{% + \the\toks1 \ifnum#2=0 \else\the\toks0 {#2}{#3}\fi% + }% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% Defines \pgfmathresult to contain three sets of braces containing +% the sign (optionally containing any components >1), the numerator and the denominator for #1. +% +% \pgfmathfloatgetfrac{0.5} -> \pgfmathresult contains {}{1}{2} +% \pgfmathfloatgetfrac{-0.5} -> \pgfmathresult contains {-}{1}{2} +% \pgfmathfloatgetfrac{1.5} -> \pgfmathresult contains {1}{1}{2} +% +% special cases: +% \pgfmathfloatgetfrac{0} -> \pgfmathresult contains {0}{0}{1} +% \pgfmathfloatgetfrac{1} -> \pgfmathresult contains {1}{0}{1} +% +% The numerator and denominator is always a number (not empty) +\def\pgfmathfloatgetfrac#1{% + \pgfutil@ifundefined{pgfmathfloatmultiply@}{% + \pgfmath@error{Sorry, the number format 'frac' requires '\string\usetikzlibrary{fpu}' (and, optionally, \string\usepackage{fp}) in order to work correctly}{}% + \edef\pgfmathresult{{#1}{0}{1}}% + }{% + \pgfmathfloatgetfrac@{#1}% + }% +}% +\def\pgfmathfloatgetfrac@#1{% + \begingroup + \edef\pgfmathfloat@arg{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathfloat@arg\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \def\pgfmathfloat@loc@TMPa{0}% + \ifcase\pgfmathfloat@a@S + % #1 = 0: + \def\pgfmathresult{{0}{0}{1}}% + \or% #1 > 0 + \pgfmathfloat@a@S=1 + \def\pgfmathfloat@loc@TMPa{1}% + \or% #1 < 0 + \pgfmathfloat@a@S=-1 + \def\pgfmathfloat@loc@TMPa{1}% + \or + \edef\pgfmathresult{{}{NaN}{1}}% + \or + \edef\pgfmathresult{{}{\infty}{1}}% + \or + \edef\pgfmathresult{{-}{\infty}{1}}% + \fi + \if1\pgfmathfloat@loc@TMPa + \ifnum\pgfmathfloat@a@E<0 + \def\pgfmathfloat@wholenumber{}% + \else + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmathfloattofixed\pgfmathresult% + \def\pgfmathfloat@loc@TMPa##1.##2\relax{% + \def\pgfmathfloat@wholenumber{##1}% + \pgfmathfloatparsenumber{0.##2}% + }% + \expandafter\pgfmathfloat@loc@TMPa\pgfmathresult\relax + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \fi + % + \def\pgfmathfloat@loc@TMPa##1.##2\relax{% + \def\pgfmathfloat@mantissa@first{##1}% + \def\pgfmathfloat@mantissa@ltone{0.##2}% + }% + \expandafter\pgfmathfloat@loc@TMPa\the\pgfmathfloat@a@Mtok\relax + % + \def\pgfmathfloat@loc@@to@int##1.##2\relax##3{% + ##3=##1 + \ifdim0.##2pt>0.5pt + \advance##3 by1 + \fi + }% + % + % alias registers names: + \let\pgfmathresultnumerator=\pgfmathfloat@b@S + \let\pgfmathresultdenom=\pgfmathfloat@b@E + % + \pgfkeysgetvalue{/pgf/number format/frac denom}\pgfmath@target@denominator + \ifx\pgfmath@target@denominator\pgfutil@empty + % + \pgfmathfloat@a@E=-\pgfmathfloat@a@E + \ifdim\pgfmathfloat@mantissa@ltone pt=0pt + \def\pgfmathfloat@factor{1}% + \edef\pgfmathfloat@scaled@numerator{\the\pgfmathfloat@a@Mtok}% + \else + % FIXME : this here is numerically instable. + % + % The errors of 1/r are magnified by 10^k which + % doesn't work. + \pgfutil@ifundefined{FPdiv}{% + \pgfmathfloatparsenumber{\pgfmathfloat@mantissa@ltone}% + \pgfmathfloatreciprocal@{\pgfmathresult}% + }{% + % \usepackage{fp}. + % yields higher absolute precision. + \FPmessagesfalse% + \FPdebugfalse% + \FPdiv\pgfmathresult{1}{\pgfmathfloat@mantissa@ltone}% + \pgfmathfloatparsenumber{\pgfmathresult}% + }% + \let\pgfmathfloat@inv=\pgfmathresult + \pgfmathfloatcreate{1}{1.0}{\pgfkeysvalueof{/pgf/number format/frac shift}}% + \let\pgfmathfloat@scalebaseten=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@inv}{\pgfmathfloat@scalebaseten}% + \let\pgfmathfloat@factor=\pgfmathresult + % + \expandafter\pgfmathfloatparsenumber\expandafter{\the\pgfmathfloat@a@Mtok}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@factor}{\pgfmathfloat@loc@TMPa}% + \pgfmathfloattofixed\pgfmathresult + \let\pgfmathfloat@scaled@numerator=\pgfmathresult + % + \pgfmathfloattofixed\pgfmathfloat@factor + \expandafter\pgfmathfloat@loc@@to@int\pgfmathresult\relax{\pgfmathfloat@b@S}% + \edef\pgfmathfloat@factor{\the\pgfmathfloat@b@S}% + \fi + % + % + \pgfmathresultdenom=\pgfmathfloat@factor\relax + \pgfmathfloat@multiply@ten@to@the@E\pgfmathresultdenom + % + \expandafter\pgfmathfloat@loc@@to@int\pgfmathfloat@scaled@numerator\relax{\pgfmathresultnumerator}% + %\message{scale = \pgfmathfloat@factor; Z = \the\pgfmathresultnumerator\space ( von \pgfmathfloat@scaled@numerator), N = \the\pgfmathresultdenom.}% + % + \pgfmathgreatestcommondivisor{\pgfmathresultnumerator}{\pgfmathresultdenom}% + \divide\pgfmathresultnumerator by\pgfmathresult\relax + \divide\pgfmathresultdenom by\pgfmathresult\relax + \ifpgfmathprintnumber@frac@warn + \ifnum\pgfmathresultdenom>1000 + \pgfutil@ifundefined{FPdiv}{% + \pgfmathfloattosci@\pgfmathfloat@arg + \pgf@typeout{! Package pgf /pgf/number format/frac warning=true: /pgf/number format/frac of `\pgfmathresult' = \the\pgfmathresultnumerator\space / \the\pgfmathresultdenom\space might be large due to instabilities. Try \string\usepackage{fp} to improve accuracy.}% + }{}% + \fi + \fi + \else + % use target denominator: + \pgfmathresultdenom=\pgfmath@target@denominator\relax + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmathfloattofixed\pgfmathresult + \pgf@xa=\pgfmathresult pt + \multiply\pgf@xa by\pgfmathresultdenom + \edef\pgfmathfloat@scaled@numerator{\pgfmath@tonumber\pgf@xa}% + \expandafter\pgfmathfloat@loc@@to@int\pgfmathfloat@scaled@numerator\relax{\pgfmathresultnumerator}% + \fi + \ifpgfmathprintnumber@frac@whole + \else + \ifx\pgfmathfloat@wholenumber\pgfutil@empty + \else + \count0=\pgfmathfloat@wholenumber\relax + \multiply\count0 by\pgfmathresultdenom + \advance\pgfmathresultnumerator by\count0 + \def\pgfmathfloat@wholenumber{}% + \fi + \fi + \ifnum\pgfmathfloat@a@S<0 + \edef\pgfmathresult{{-\pgfmathfloat@wholenumber}{\the\pgfmathresultnumerator}{\the\pgfmathresultdenom}}% + \else + \edef\pgfmathresult{{\pgfmathfloat@wholenumber}{\the\pgfmathresultnumerator}{\the\pgfmathresultdenom}}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloat@gobble@until@relax#1\relax{} + +% computes the greatest common divisor of two integer numbers (in +% integer arithmetics). +\def\pgfmathgreatestcommondivisor#1#2{% + \begingroup + \count0=#1\relax + \count1=#2\relax + \ifnum\count0=0 + \edef\pgfmathresult{\the\count1}% + \else + \pgfmathgreatestcommondivisor@loop + \edef\pgfmathresult{\the\count0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\def\pgfmathgreatestcommondivisor@loop{% + \ifnum\count1=0 + \else + \ifnum\count0>\count1 + \advance\count0 by-\count1 + \else + \advance\count1 by-\count0 + \fi + \expandafter\pgfmathgreatestcommondivisor@loop + \fi +}% + +% multiplies a TeX register by 10^E where E is stored in the register +% \pgfmathfloat@a@E (and it should be positive!)% +% +% #1 a TeX register +\def\pgfmathfloat@multiply@ten@to@the@E#1{% + \ifnum\pgfmathfloat@a@E>0 + \multiply#1 by10 + \advance\pgfmathfloat@a@E by-1 + \def\pgfmathfloat@multiply@ten@to@the@E@next{\pgfmathfloat@multiply@ten@to@the@E{#1}}% + \else + \let\pgfmathfloat@multiply@ten@to@the@E@next=\relax% + \fi + \pgfmathfloat@multiply@ten@to@the@E@next +}% + +\def\pgfmathprintnumber@INT@TRUNC#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@INT@TRUNC@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@INT@TRUNC@impl#1.#2\relax#3#4e#5\relax{% + \pgfmathfloatroundhasperiodfalse + \pgfmathprintnumber@fixed@style{#1}#3#4e#5\relax% +} +\def\pgfmathprintnumber@INT@TRUNC@issci#1#2e#3\relax{% + \ifnum#1<3\relax + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% + \expandafter\pgfmathprintnumber@INT@TRUNC@impl\pgfmathresult\relax#1#2e#3\relax + \else + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi +} + +% Invokes '#2' if '#1' is actually an integer or '#3' if not. +% +% As a side-effect, \pgfretval will be set to the integer value if it +% actually *is* an integer. Otherwise, \pgfretval will contain the +% parsed floating point number. +% +% #1 a number constant (not necessarily a parsed float). +\def\pgfmathifisint#1#2#3{% + \gdef\pgfmathfloatisint@@{0}% + \begingroup + \pgfmathfloatparsenumber{#1}% + \let\pgfretval\pgfmathresult + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathfloatisint@\pgfmathresult\relax + \pgfmath@smuggleone\pgfretval + \endgroup + \if1\pgfmathfloatisint@@ #2\else #3\fi +}% +\def\pgfmathfloatisint@#1#2e#3\relax{% + \ifnum#1<3\relax + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% + \def\pgfmathfloat@round@precision{6}% + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \ifpgfmathfloatroundhasperiod + \else + \let\pgfretval\pgfmathresult% + \gdef\pgfmathfloatisint@@{1}% + \fi + \fi +} + +\def\pgfmathprintnumber@INT@DETECT#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@INT@DETECT@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@INT@DETECT@issci#1#2e#3\relax{% + \begingroup + \ifnum#1<3\relax + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% + \let\pgfmathfloat@round@precision@=\pgfmathfloat@round@precision + \def\pgfmathfloat@round@precision{6}% + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \let\pgfmathfloat@round@precision=\pgfmathfloat@round@precision@ + \ifpgfmathfloatroundhasperiod + \pgfmathprintnumber@SCI@issci#1#2e#3\relax + \else + \expandafter\pgfmathprintnumber@fixed@style\expandafter{\pgfmathresult}#1#2e#3\relax + \fi + \else + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\def\pgfmathprintnumber@FIXED#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@FIXED@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@FIXED@issci#1#2e#3\relax{% + \begingroup + \ifnum#1<3 + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% + \ifpgfmathfloat@usezerofill@fixed + \expandafter\pgfmathroundtozerofill\expandafter{\pgfmathresult}% + \else + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \fi + \ifpgfmathfloatroundmayneedrenormalize + \pgfmathfloat@a@E=#3\relax + \advance\pgfmathfloat@a@E by1 + \edef\pgfmathfloat@loc@TMPb{\noexpand\pgfmathprintnumber@fixed@style{\pgfmathresult}#1#2e\the\pgfmathfloat@a@E}% + \pgfmathfloat@loc@TMPb\relax% + \else + \expandafter\pgfmathprintnumber@fixed@style\expandafter{\pgfmathresult}#1#2e#3\relax% + \fi + \else% nan or inf: + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + + +\def\pgfmathprintnumber@SCI#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@SCI@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@SCI@issci#1#2e#3\relax{% + \begingroup + \pgfmathfloatcreate{#1}{#2}{#3}% + \edef\pgfmathfloat@round@precision{\pgfmathprintnumber@sci@precision}% + \ifpgfmathfloat@usezerofill@sci + \pgfmathfloatroundzerofill{\pgfmathresult}% + \else + \pgfmathfloatround{\pgfmathresult}% + \fi + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathfloatrounddisplaystyle\pgfmathresult\relax + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% Prints argument #1 using the current pretty printer environment (all +% variables in /pgf/number format). +% +% You may specify optional arguments with \pgfmathprintnumber[...]. +\pgfutil@protected\def\pgfmathprintnumber{% + \pgfutil@ifnextchar[% + {\pgfmathprintnumber@OPT}% + {\pgfmathprintnumber@noopt}% +} + +\def\pgfmathprintnumber@noopt#1{% + \pgfmathprintnumber@{#1}% + \ifpgfmathprintnumber@assumemathmode + \pgfmathresult + \else + \pgfutilensuremath{\pgfmathresult}% + \fi +}% +\def\pgfmathprintnumber@OPT[#1]#2{% + \begingroup + \pgfqkeys{/pgf/number format}{#1}% + \pgfmathprintnumber@{#2}% + \ifpgfmathprintnumber@assumemathmode + \pgfmathresult + \else + \pgfutilensuremath{\pgfmathresult}% + \fi + \endgroup +}% + +% As \pgfmathprintnumber, but it produces its output into the second +% argument. +\def\pgfmathprintnumberto{% + \pgfutil@ifnextchar[% + {\pgfmathprintnumberto@OPT}% + {\pgfmathprintnumberto@noopt}% +} + +\def\pgfmathprintnumberto@noopt#1#2{% + \begingroup + \pgfmathprintnumber@{#1}% + \ifpgfmathprintnumber@assumemathmode + \global\let\pgfmathfloat@glob@TMP=\pgfmathresult + \else + \toks0=\expandafter{\pgfmathresult}% + \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfutilensuremath{\the\toks0 }}% + \fi + \endgroup + \let#2=\pgfmathfloat@glob@TMP +}% +\def\pgfmathprintnumberto@OPT[#1]#2#3{% + \begingroup + \pgfqkeys{/pgf/number format}{#1}% + \pgfmathprintnumber@{#2}% + \ifpgfmathprintnumber@assumemathmode + \global\let\pgfmathfloat@glob@TMP=\pgfmathresult + \else + \toks0=\expandafter{\pgfmathresult}% + \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfutilensuremath{\the\toks0 }}% + \fi + \endgroup + \let#3=\pgfmathfloat@glob@TMP +}% + + +% Changes the current number pretty printer to #1. +% +% #1 is the macro base name for the pretty print routine, without the +% leading '\'. +\def\pgfmath@set@number@printer#1{% + \expandafter\let\expandafter\pgfmathprintnumber@\csname #1\endcsname + \expandafter\let\expandafter\pgfmathprintnumber@issci\csname #1@issci\endcsname +} + +\pgfkeys{/pgf/number format/std} + +%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% IMPL +% +%%%%%%%%%%%%%%%%%%%%%%%%%% + +% equals only itself when compared with \ifx: +\def\pgfmathfloat@EOI{\pgfmathfloat@EOI}% + +% Re-use counters internally. +% +% They are always grouped and only used inside of the rounding +% routines. +\let\c@pgfmathroundto@prec=\pgfmathfloat@b@S% ATTENTION: DOUBLE-USED REGISTERS! +\let\c@pgfmathroundto@offsetbehindperiod=\pgfmathfloat@b@E +\newcount\c@pgfmathroundto@lastzeros + +\newif\ifpgfmathround@impl@PREPERIOD@is@negative@zero + +% PRECONDITION: +% \ifpgfmathfloatroundhasperiod=\iftrue holds outside of the current TeX group. +% +% POSTCONDITION: +% \ifpgfmathfloatroundhasperiod will be set correctly AFTER the +% current TeX group. +% \ifpgfmathfloatroundmayneedrenormalize will be set globally +\def\pgfmathroundto@impl#1{% + \edef\pgfmathround@input{#1}% + \global\pgfmathfloatroundmayneedrenormalizefalse + \pgfmathfloat@tmptoks={}% + \let\pgfmathround@next=\pgfutil@empty + \let\pgfmathround@cur=\pgfutil@empty + \let\pgfmathresult=\pgfutil@empty + \expandafter\c@pgfmathroundto@prec\pgfmathfloat@round@precision\relax + \c@pgfmathroundto@lastzeros=0 + \c@pgfmathroundto@offsetbehindperiod=-1 % means: no period found so far + \pgfmathround@impl@PREPERIOD@is@negative@zerotrue + \expandafter\pgfmathroundto@impl@ITERATE@NODOT@firstcall\pgfmathround@input\pgfmathfloat@EOI +} + +% \pgfmathroundto implementation in WORDS: +% +% coarse idea: +% 1. collect all digits/sign BEFORE the first period in REVERSE order +% 2. then, collect UP TO \prec digits after the period in REVERSE order +% Steps 1. and 2. lead to the digit [sign] sequence +% "x_{-p} x_{-p+1} ... x_{-2} x_{-1} '.' x_0 ... x_r" +% where 'r' is the total number of digits. The integer 'p' denotes the +% ACTUALLY collected number of digits behind the period. +% +% Let 'k' be the desired precision. +% +% Please note that pgfmathroundto rounds the mantissa, that means |abs(x)|. +% +% There are exactly TWO cases: +% 1. The case with p<=k and x_{-p-1} = end of input. +% 2. The case with p=k and x_{-p-1} is a further, next character. +% +% Then, for case 1.): +% discard any unused zeros at the tail of our number (possibly +% including the period) +% +% and in case 2.) +% if NEXT DIGIT < 5: +% do exactly the same as in case 1.) above and discard any +% following digits. +% else +% let q := -p +% while(x_q = 9 and q<=r ) +% if q>=0 +% set x_q = '0' +% else +% discard digit x_q='9' +% fi +% ++q +% if q=0 +% discard the period +% fi +% end while +% if q = r+1 +% insert a '1' +% else +% set x_q = x_q + 1 +% fi +% fi +% +% All these loops have been implemented in spaghetti-code below. +% Sorry, I fear its hard to understand. In principle, everything is +% realised using more or less finite state machines (with some number +% counting logic). +% +% Some comments: +% - The token register \pgfmathfloat@tmptoks is used to accumulate the REVERSED input number. +% - \pgfmathfloat@EOI always denotes 'END OF INPUT'. +% - in the second stage, we need to reverse \pgfmathfloat@tmptoks. +% This is -- again -- done with \pgfmathfloat@tmptoks. + +\def\pgfmathroundto@impl@discard@period#1.#2\pgfmathfloat@EOI{% + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \def\pgfmathresult{#1}% +} + +\def\pgfmathroundto@impl@gobble@rest@and@start#1\pgfmathfloat@EOI{% + \pgfmathroundto@impl@start +} +\def\pgfmathroundto@impl@gobble@and@start\pgfmathfloat@EOI{% + \pgfmathroundto@impl@start +} +\def\pgfmathroundto@impl@gobble\pgfmathfloat@EOI{}% +\def\pgfmathroundto@impl@gobble@rest#1\pgfmathfloat@EOI{}% + +% This method will be invoked as soon as the first step, the reverse +% collection of up to PREC digits after the period, has finished. +\def\pgfmathroundto@impl@start{% + \ifx\pgfmathround@next\pgfutil@empty + \ifnum\c@pgfmathroundto@offsetbehindperiod<0 + % no period found. + \ifpgfmathfloat@fixed@digits@after@period + \ifnum\c@pgfmathroundto@prec=0\relax + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \edef\pgfmathresult{\pgfmathround@input}% + \else + \pgfmathfloat@tmptoks=\expandafter{\pgfmathround@input.}% + \c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + \pgfmathroundto@impl@append@zeros + \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}% + \fi + \else + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \edef\pgfmathresult{\pgfmathround@input}% + \fi + \else + %\ifnum\c@pgfmathroundto@offsetbehindperiod>\c@pgfmathroundto@prec + % \pgfmath@error{Internal logic error in pgfmathroundto at [I] - should not have happened!?}{}% + %\fi + \pgfmathroundto@impl@finish@with@truncation + \fi + \else + %\ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + %\else + % \pgfmath@error{Internal logic error in pgfmathroundto at [II] - should not have happened!? I have offsetbehindperiod=\the\c@pgfmathroundto@offsetbehindperiod and prec = \the\c@pgfmathroundto@prec}{}% + %\fi + \expandafter\ifnum\pgfmathround@next<5\relax + \pgfmathroundto@impl@finish@with@truncation + \else + \multiply\c@pgfmathroundto@offsetbehindperiod by-1 + \expandafter\pgfmathroundto@impl@ADD@ONE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \fi + \fi +} + +% takes the current input and decides whether trailing zeros shall be +% discarded or more zeros need to be filled in. +\def\pgfmathroundto@impl@finish@with@truncation{% + \ifpgfmathfloat@fixed@digits@after@period + \expandafter\pgfmathroundto@impl@REVERSE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \ifnum\c@pgfmathroundto@lastzeros=\c@pgfmathroundto@offsetbehindperiod + \ifpgfmathround@impl@PREPERIOD@is@negative@zero + % write '0.0000' instead of '-0.0000': + \expandafter\pgfmathroundto@impl@discard@minus\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \fi + \fi + \ifnum\c@pgfmathroundto@prec=0\relax + \expandafter\pgfmathroundto@impl@discard@period\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \else + \advance\c@pgfmathroundto@prec by-\c@pgfmathroundto@offsetbehindperiod + \c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + \pgfmathroundto@impl@append@zeros + \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}% + \fi + \else + \pgfmathroundto@impl@discard@suffix@zeros + \fi +} + +\def\pgfmathroundto@impl@discard@minus-#1\pgfmathfloat@EOI{\pgfmathfloat@tmptoks={#1}}% + +% appends \c@pgfmathroundto@offsetbehindperiod zeros at the end of \pgfmathfloat@tmptoks. +\def\pgfmathroundto@impl@append@zeros{% + \ifnum\c@pgfmathroundto@offsetbehindperiod>0 + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \advance\c@pgfmathroundto@offsetbehindperiod by-1 + \pgfmathroundto@impl@append@zeros + \fi +} + +\def\pgfmathroundto@impl@ADD@ONE{% + \pgfmathfloat@tmptoks={}% no longer needed because its old value will be read from input + \pgfmathroundto@impl@ADD@ONE@ITERATE +} +\def\pgfmathroundto@impl@ADD@ONE@ITERATE{% + \pgfutil@ifnextchar\pgfmathfloat@EOI{% + \global\pgfmathfloatroundmayneedrenormalizetrue + \edef\pgfmathresult{1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble + }{% + \pgfutil@ifnextchar.{% + \ifnum\c@pgfmathroundto@prec=0 + % silently discard period in special case precision=0 + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot}% + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@NEXT@COLLECT}% + \fi + \pgfmathround@nextcmd + }{% + \pgfutil@ifnextchar+{% + \global\pgfmathfloatroundmayneedrenormalizetrue + \edef\pgfmathresult{1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble@rest + }{% + \pgfutil@ifnextchar-{% + \global\pgfmathfloatroundmayneedrenormalizetrue + \edef\pgfmathresult{-1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble@rest + }{% + \pgfmathroundto@impl@ADD@ONE@NEXT + }% + }% + }% + }% +} + +\def\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot.{% + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \pgfmathroundto@impl@ADD@ONE@ITERATE +} + +\def\pgfmathroundto@impl@ADD@ONE@NEXT@COLLECT#1{% + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@ADD@ONE@ITERATE +} +\def\pgfmathroundto@impl@ADD@ONE@NEXT#1{% + \ifnum#1=9 + \ifnum\c@pgfmathroundto@offsetbehindperiod<0 + \ifpgfmathfloat@fixed@digits@after@period + \pgfmathfloat@tmptoks=\expandafter{\expandafter0\the\pgfmathfloat@tmptoks}% + \else + % silently DROP digit + \fi + \else + \pgfmathfloat@tmptoks=\expandafter{\expandafter0\the\pgfmathfloat@tmptoks}% + \fi + \advance\c@pgfmathroundto@offsetbehindperiod by1 + \ifnum\c@pgfmathroundto@offsetbehindperiod=0 + \ifpgfmathfloat@fixed@digits@after@period + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE}% + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot}% + \fi + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE}% + \fi + \else + % re-use this counter: + \c@pgfmathroundto@lastzeros=#1 + \advance\c@pgfmathroundto@lastzeros by1 + \edef\pgfmathresult{\the\c@pgfmathroundto@lastzeros\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks=\expandafter{\pgfmathresult}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@REVERSE@ITERATE}% + \fi + \pgfmathround@nextcmd +} + + +\def\pgfmathroundto@impl@discard@suffix@zeros{% + \ifnum\c@pgfmathroundto@lastzeros=\c@pgfmathroundto@offsetbehindperiod + \ifpgfmathround@impl@PREPERIOD@is@negative@zero + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \def\pgfmathresult{0}% write '0' instead of '-0' + \else + \expandafter\pgfmathroundto@impl@discard@period\pgfmathround@input\pgfmathfloat@EOI + \fi + \else + \ifnum\c@pgfmathroundto@lastzeros=0 + \expandafter\pgfmathroundto@impl@REVERSE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \else + \expandafter\pgfmathroundto@impl@discard@suffix@zeros@ITERATE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \fi + \fi +} + +% PRECONDITION: +% \c@pgfmathroundto@lastzeros > 0 +\def\pgfmathroundto@impl@discard@suffix@zeros@ITERATE#1{% + \advance\c@pgfmathroundto@lastzeros by-1 + \ifnum\c@pgfmathroundto@lastzeros=0 + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@REVERSE}% + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@discard@suffix@zeros@ITERATE}% + \fi + \pgfmathround@nextcmd +} + +% Usage: +% \pgfmathroundto@impl@REVERSE#1\pgfmathfloat@EOI +% -> writes #1 reversed into \pgfmathfloat@tmptoks +\def\pgfmathroundto@impl@REVERSE{% + \pgfmathfloat@tmptoks={}% + \pgfmathroundto@impl@REVERSE@ITERATE +} + +\def\pgfmathroundto@impl@REVERSE@ITERATE{% + \pgfutil@ifnextchar\pgfmathfloat@EOI{% + \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble + }{% + \pgfmathroundto@impl@REVERSE@NEXT + }% +} + +\def\pgfmathroundto@impl@REVERSE@NEXT#1{% + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@REVERSE@ITERATE +} + +\def\pgfmathroundto@impl@BEGIN@DOT.{% + \pgfmathfloat@tmptoks=\expandafter{\expandafter.\the\pgfmathfloat@tmptoks}% + \c@pgfmathroundto@offsetbehindperiod=0 + \pgfmathroundto@impl@ITERATE@DOT +} +\def\pgfmathroundto@impl@ITERATE@DOT{% + \pgfutil@ifnextchar\pgfmathfloat@EOI{% + % finished. + \pgfmathroundto@impl@gobble@and@start + }{% + \pgfmathroundto@impl@NEXT@DOT + }% +} +\def\pgfmathroundto@impl@NEXT@DOT#1{% + \ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + \def\pgfmathround@next{#1}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@gobble@rest@and@start}% + \else + \advance\c@pgfmathroundto@offsetbehindperiod by1 + \ifnum#1=0 + \advance\c@pgfmathroundto@lastzeros by1 + \else + \c@pgfmathroundto@lastzeros=0 + \fi + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@DOT}% + \fi + \pgfmathround@nextcmd +}% + +% in contrast to pgfmathroundto@impl@ITERATE@NODOT, this method here +% checks also for signs +\def\pgfmathroundto@impl@ITERATE@NODOT@firstcall#1{% + \def\pgfmathround@cur{#1}% + \ifx\pgfmathround@cur\pgfmathfloat@EOI + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@start}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@PERIOD + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@BEGIN@DOT.}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@MINUS + \else + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \fi + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@NODOT}% + \fi + \fi + \pgfmathround@nextcmd +} + +\def\pgfmathroundto@impl@ITERATE@NODOT#1{% + \def\pgfmathround@cur{#1}% + \ifx\pgfmathround@cur\pgfmathfloat@EOI + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@start}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@PERIOD + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@BEGIN@DOT.}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@ZERO + \else + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \fi + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@NODOT}% + \fi + \fi + \pgfmathround@nextcmd +} + +%-------------------------------------------- +% END of pgfmathroundto implementation. +%-------------------------------------------- + + +% flags, mantissa and exponent has already been stored into +% \pgfmathfloat@a@* [using ...@Mtok] +% +% PRECONDITION: +% \ifpgfmathfloatroundhasperiod = \iftrue outside of the current +% group +% +% POSTCONDITION: +% \ifpgfmathfloatroundhasperiod will be set after the current TeX +% group. +\def\pgfmathfloatround@impl{% + \expandafter\pgfmathroundto@impl\expandafter{\the\pgfmathfloat@a@Mtok}% + \ifpgfmathfloatroundmayneedrenormalize + \ifpgfmathfloatroundhasperiod + \expandafter\pgfmathfloatround@impl@renormalize\pgfmathresult\pgfmathfloat@EOI% + \else + \expandafter\pgfmathfloatround@impl@renormalize\pgfmathresult.\pgfmathfloat@EOI% + \fi + \advance\pgfmathfloat@a@E by1 + \fi + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgfmathresult}{\the\pgfmathfloat@a@E}% +} + +\def\pgfmathfloatround@impl@renormalize#1#2.#3\pgfmathfloat@EOI{% + \pgfmathroundto@impl{#1.#2#3}% +} + + + + + +% ATTENTION: this thing REQUIRES a period in the mantissa! +% collects everything into \pgfmathresult +\def\pgfmathfloattofixed@impl#1.#2\relax{% + \ifnum\pgfmathfloat@a@E<0 + \ifcase-\pgfmathfloat@a@E + \or%e-1 + \pgfmathfloat@a@Mtok={0.}% + \or%e-2 + \pgfmathfloat@a@Mtok={0.0}% + \or%e-3 + \pgfmathfloat@a@Mtok={0.00}% + \or%e-4 + \pgfmathfloat@a@Mtok={0.000}% + \or%e-5 + \pgfmathfloat@a@Mtok={0.0000}% + \or%e-6 + \pgfmathfloat@a@Mtok={0.00000}% + \or%e-7 + \pgfmathfloat@a@Mtok={0.000000}% + \or%e-8 + \pgfmathfloat@a@Mtok={0.0000000}% + \or%e-9 + \pgfmathfloat@a@Mtok={0.00000000}% + \or%e-10 + \pgfmathfloat@a@Mtok={0.000000000}% + \else%<= -11 + \pgfmathfloat@a@Mtok={0.0000000000}% + \advance\pgfmathfloat@a@E by10 + \pgfutil@loop + \ifnum\pgfmathfloat@a@E<-1 + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}% + \advance\pgfmathfloat@a@E by1 + \pgfutil@repeat + \fi + \def\pgfmathfloat@loc@TMPb{#2}% + \def\pgfmathfloat@loc@TMPc{0}% + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloat@loc@TMPc + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1}% + \else + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1#2}% + \fi + \else + %-------------------------------------------------- + % \ifnum\pgfmathfloat@a@E=0% + % \edef\pgfmathresult{#1.#2}% + % \else + % \pgfmathfloat@a@Mtok={#1}% + % \pgfmathfloattofixed@impl@collectmantissa#2\count\pgfmathfloat@a@E + % \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% + % \fi + %-------------------------------------------------- + \pgfmathfloat@a@Mtok{#1}% + \pgfmathfloattofixed@impl@pos#2000000000\pgfmathfloat@EOI + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% + \fi +} + +% FIXME: this implementation here is very fast, but it introduces trailing zeros. Is that acceptable? +\def\pgfmathfloattofixed@impl@pos#1#2#3#4#5#6#7#8#9\pgfmathfloat@EOI{% + \ifcase\pgfmathfloat@a@E + % e+0 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok .#1#2#3#4#5#6#7#8#9}% + \or%e+1 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1.#2#3#4#5#6#7#8#9}% + \or%e+2 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2.#3#4#5#6#7#8#9}% + \or%e+3 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3.#4#5#6#7#8#9}% + \or%e+4 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4.#5#6#7#8#9}% + \or%e+5 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5.#6#7#8#9}% + \or%e+6 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6.#7#8#9}% + \or%e+7 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7.#8#9}% + \or%e+8 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7#8.#9}% + \else%>=9 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7#8}% + \advance\pgfmathfloat@a@E by-8 + \pgfmathfloattofixed@impl@collectmantissa#9\count\pgfmathfloat@a@E + \fi +}% + +\def\pgfmathfloattofixed@impl@collectmantissa#1#2\count#3{% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok #1}% + \advance\pgfmathfloat@a@E by-1% + \def\pgfmathfloat@loc@TMPb{#2}% + \ifx\pgfmathfloat@loc@TMPb\pgfutil@empty + \pgfutil@loop + \ifnum\pgfmathfloat@a@E>0% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}% + \advance\pgfmathfloat@a@E by-1% + \pgfutil@repeat + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .0}% + \else + \ifnum\pgfmathfloat@a@E=0 + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .#2}% + \else + \pgfmathfloattofixed@impl@collectmantissa#2\count#3% + \fi + \fi +} + + +% ============================================ +% +% +% \pgfmathfloatparsenumber implementation +% +% +% ============================================ + +% accepted parser tokens: +\def\pgfmathfloatparsenumber@tok@ZERO{0} +\def\pgfmathfloatparsenumber@tok@PLUS{+} +\def\pgfmathfloatparsenumber@tok@MINUS{-} +\def\pgfmathfloatparsenumber@tok@PERIOD{.} + +\newif\ifpgfmathfloatparsenumberpendingperiod + +\def\pgfflt@EOI{p@EOI}% +\def\pgfflt@EOI@unexpanded{\pgfflt@EOI}% + +% Starts a finite-start-machine parser to read a number. +% +% The machine's state is represented by the macro which is currently +% processed; state transitions are realised using \csname...#1\endcsname +% constructions. +% +% It assigns \pgfmathfloat@a@S, \pgfmathfloat@a@Mtok, \pgfmathfloat@a@E. +\def\pgfflt@impl#1{% + \pgfmathfloatparsenumberpendingperiodfalse + \pgfmathfloat@tmptoks={}% this register is used to collect PENDING ZEROS + \pgfmathfloat@a@E=0 + % start parsing: check for sign: + \expandafter\ifx\csname pgfflt@#1\endcsname\relax + \pgfmathfloat@a@S=1 + \expandafter\pgfflt@init\expandafter#1% + \else + \expandafter\expandafter\csname pgfflt@#1\endcsname + \fi +} +% State transitions: +\expandafter\def\csname pgfflt@+\endcsname{% + \pgfmathfloat@a@S=1 % + \pgfflt@init}% +\expandafter\def\csname pgfflt@-\endcsname{% + \pgfmathfloat@a@S=2 % + \pgfflt@init}% +\expandafter\def\csname pgfflt@\pgfflt@EOI\endcsname{% + \pgfmathfloatparsenumber@handleerror{empty number}{}{}}% + +\pgfkeys{ + /pgf/fpu/handlers/empty number/.style 2 args={% + /pgf/fpu/handlers/invalid number={#1}{#2}% + }, + /pgf/fpu/empty number is zero/.style={% + /pgf/fpu/handlers/empty number/.code 2 args={% + \pgfmathfloatcreate{0}{0.0}{0}% + }% + },% + /pgf/fpu/handlers/invalid separator/.code 2 args={% + \pgfmath@error{Could not parse input '#1' as a floating point number, sorry. The unreadable part was near the decimal separator '#2'. Do you need the option 'read comma as period'?}{}% + }, + /pgf/fpu/handlers/invalid number/.code 2 args={% + \pgfmath@error{Could not parse input '#1' as a floating point number, sorry. The unreadable part was near '#2'.}{}% + }, + /pgf/fpu/handlers/wrong lowlevel format/.code 2 args={% + \pgfmath@error{Sorry, an internal routine of the floating point unit got an ill-formatted floating point number `#1'. The unreadable part was near '#2'.}{}% + \let\pgfmathresult=\pgfutil@empty + }, +} + +% #1 the error handler +% #2 the number which was invalid. +% #3 the part which produced the error +% +% POSTCONDITION: the three registers +% \pgfmathfloat@a@S +% \pgfmathfloat@a@Mtok +% \pgfmathfloat@a@E +% will contain the number which results from the error handler. +\def\pgfmathfloatparsenumber@handleerror#1#2#3{% + \let\pgfmathresult=\pgfutil@empty + \pgfmathfloatparsenumberpendingperiodfalse + \pgfkeys{/pgf/fpu/handlers/#1={#2}{#3}}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloat@a@S=3 + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0 + \else + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \fi +} +\def\pgfflt@error#1\pgfflt@EOI{% + \begingroup + \pgfmathfloat@a@Mtok={#1}% + \xdef\pgfmathfloat@glob@TMP{% + \noexpand\pgfmathfloatparsenumber@handleerror + {invalid number}{\pgfmathresult}{\the\pgfmathfloat@a@Mtok}}% + \endgroup + \pgfmathfloat@glob@TMP +}% + + + +% FROM: checksign. +% +\def\pgfflt@init#1{% + \expandafter\ifx\csname pgffltA@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltA@#1\endcsname + \fi} +% state transitions: +\expandafter\def\csname pgffltA@0\endcsname{\pgfflt@leadingzero}% FIXME: inline optimization! +\expandafter\def\csname pgffltA@1\endcsname{\pgfflt@nonzerodigit1}% +\expandafter\def\csname pgffltA@2\endcsname{\pgfflt@nonzerodigit2}% +\expandafter\def\csname pgffltA@3\endcsname{\pgfflt@nonzerodigit3}% +\expandafter\def\csname pgffltA@4\endcsname{\pgfflt@nonzerodigit4}% +\expandafter\def\csname pgffltA@5\endcsname{\pgfflt@nonzerodigit5}% +\expandafter\def\csname pgffltA@6\endcsname{\pgfflt@nonzerodigit6}% +\expandafter\def\csname pgffltA@7\endcsname{\pgfflt@nonzerodigit7}% +\expandafter\def\csname pgffltA@8\endcsname{\pgfflt@nonzerodigit8}% +\expandafter\def\csname pgffltA@9\endcsname{\pgfflt@nonzerodigit9}% +\def\pgfflt@nonzerodigit#1{% + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloatparsenumberpendingperiodtrue + \pgfflt@positiveexp}% +\expandafter\def\csname pgffltA@n\endcsname{\pgfflt@readnan}% FIXME: inlining? +\expandafter\def\csname pgffltA@N\endcsname{\pgfflt@readnan}% FIXME: inlining? +\expandafter\def\csname pgffltA@i\endcsname{\pgfflt@readinf}% FIXME: inlining? +\expandafter\def\csname pgffltA@I\endcsname{\pgfflt@readinf}% FIXME: inlining? +\expandafter\def\csname pgffltA@.\endcsname{% read '.9' like '0.9' + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltA@,\endcsname{% read ',9' like '0,9' + \pgfmathfloat@frenchinput{% + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod + }% +}% + +\def\pgfmathfloat@frenchinput#1{% + \ifpgfmathparsenumber@comma@as@period + \def\pgf@marshal{#1}% + \expandafter\pgf@marshal + \else + \expandafter\pgfflt@error@separator\expandafter,% + \fi +}% +\def\pgfflt@error@separator#1\pgfflt@EOI{% + \begingroup + \pgfmathfloat@a@Mtok={#1}% + \xdef\pgfmathfloat@glob@TMP{% + \noexpand\pgfmathfloatparsenumber@handleerror + {invalid separator}{\pgfmathresult}{\the\pgfmathfloat@a@Mtok}}% + \endgroup + \pgfmathfloat@glob@TMP +}% + +\def\pgfflt@finish#1\pgfflt@EOI{} + +\def\pgfflt@readnan #1#2{% + \def\pgfflt@readnan@ok{1}% + \if#1a\else\if#1A\else\def\pgfflt@readnan@ok{0}\fi\fi + \if#2n\else\if#2N\else\def\pgfflt@readnan@ok{0}\fi\fi + \if\pgfflt@readnan@ok1% + \pgfmathfloat@a@S=3\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \expandafter\pgfflt@finish + \else + \def\pgfflt@readnan@{\pgfflt@error #1#2}% + \expandafter\pgfflt@readnan@ + \fi +} +\def\pgfflt@readinf #1#2{% + \def\pgfflt@readinf@ok{1}% + \if#1n\else\if#1N\else\def\pgfflt@readinf@ok{0}\fi\fi + \if#2f\else\if#2F\else\def\pgfflt@readinf@ok{0}\fi\fi + \if\pgfflt@readinf@ok1% + \ifnum\pgfmathfloat@a@S=1 % + \pgfmathfloat@a@S=4 % + \pgfmathfloat@a@Mtok={0.0}% + \else + \pgfmathfloat@a@S=5 % + \pgfmathfloat@a@Mtok={0.0}% + \fi + \pgfmathfloat@a@E=0 % + \expandafter\pgfflt@finish + \else + \def\pgfflt@readinf@{\pgfflt@error #1#2}% + \expandafter\pgfflt@readinf@ + \fi +} +\def\pgfflt@leadingzero#1{% + \expandafter\ifx\csname pgffltB@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltB@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltB@0\endcsname{\pgfflt@leadingzero}% +\expandafter\def\csname pgffltB@1\endcsname{\pgfmathfloat@a@Mtok={1}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@2\endcsname{\pgfmathfloat@a@Mtok={2}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@3\endcsname{\pgfmathfloat@a@Mtok={3}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@4\endcsname{\pgfmathfloat@a@Mtok={4}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@5\endcsname{\pgfmathfloat@a@Mtok={5}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@6\endcsname{\pgfmathfloat@a@Mtok={6}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@7\endcsname{\pgfmathfloat@a@Mtok={7}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@8\endcsname{\pgfmathfloat@a@Mtok={8}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@9\endcsname{\pgfmathfloat@a@Mtok={9}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@\pgfmathfloat@POSTFLAGSCHAR\endcsname{\pgfmathfloat@a@Mtok={0}\pgfflt@readlowlevelfloat}% +\expandafter\def\csname pgffltB@.\endcsname{% + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltB@,\endcsname{% + \pgfmathfloat@frenchinput{% + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod + }% +}% +\expandafter\def\csname pgffltB@e\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfflt@readexponent}% +\let\pgffltB@E=\pgffltB@e +\expandafter\def\csname pgffltB@\pgfflt@EOI\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0}% + +\def\pgfflt@leadingzero@foundperiod#1{% + \expandafter\ifx\csname pgffltC@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltC@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltC@0\endcsname{% + \advance\pgfmathfloat@a@E by-1 + \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltC@1\endcsname{\pgfmathfloat@a@Mtok={1}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@2\endcsname{\pgfmathfloat@a@Mtok={2}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@3\endcsname{\pgfmathfloat@a@Mtok={3}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@4\endcsname{\pgfmathfloat@a@Mtok={4}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@5\endcsname{\pgfmathfloat@a@Mtok={5}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@6\endcsname{\pgfmathfloat@a@Mtok={6}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@7\endcsname{\pgfmathfloat@a@Mtok={7}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@8\endcsname{\pgfmathfloat@a@Mtok={8}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@9\endcsname{\pgfmathfloat@a@Mtok={9}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@e\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfflt@readexponent}% +\let\pgffltC@E=\pgffltC@e +\expandafter\def\csname pgffltC@\pgfflt@EOI\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0}% + + +\def\pgfflt@positiveexp#1{% + \expandafter\ifx\csname pgffltD@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltD@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltD@0\endcsname{% + \advance\pgfmathfloat@a@E by1 + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfflt@pendingzeros@positiveexp}% +\expandafter\def\csname pgffltD@1\endcsname{\pgffltD@nonzerodigit1}% +\expandafter\def\csname pgffltD@2\endcsname{\pgffltD@nonzerodigit2}% +\expandafter\def\csname pgffltD@3\endcsname{\pgffltD@nonzerodigit3}% +\expandafter\def\csname pgffltD@4\endcsname{\pgffltD@nonzerodigit4}% +\expandafter\def\csname pgffltD@5\endcsname{\pgffltD@nonzerodigit5}% +\expandafter\def\csname pgffltD@6\endcsname{\pgffltD@nonzerodigit6}% +\expandafter\def\csname pgffltD@7\endcsname{\pgffltD@nonzerodigit7}% +\expandafter\def\csname pgffltD@8\endcsname{\pgffltD@nonzerodigit8}% +\expandafter\def\csname pgffltD@9\endcsname{\pgffltD@nonzerodigit9}% +\expandafter\def\csname pgffltD@\pgfmathfloat@POSTFLAGSCHAR\endcsname{\pgfflt@readlowlevelfloat}% +\expandafter\def\csname pgffltD@.\endcsname{\pgfflt@finish@number@after@period}% FIXME : inlining? +\expandafter\def\csname pgffltD@,\endcsname{\pgfmathfloat@frenchinput{\pgfflt@finish@number@after@period}}% +\expandafter\def\csname pgffltD@e\endcsname{\pgfflt@readexponent}% FIXME : inlining? +\let\pgffltD@E=\pgffltD@e +\expandafter\def\csname pgffltD@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltD@nonzerodigit#1{% + \advance\pgfmathfloat@a@E by1 + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@positiveexp}% + +% Read a low-level floating point. +% Since we are in the second state, \pgfmathfloat@a@Mtok contains the +% FLAGS. The post-flags-char has also been read. +\def\pgfflt@readlowlevelfloat#1e#2]\pgfflt@EOI{% + \pgfmathfloatparsenumberpendingperiodfalse + \pgfmathfloat@a@S=\the\pgfmathfloat@a@Mtok\relax + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloat@a@E=#2 +}% + +\def\pgfflt@readexponent#1\pgfflt@EOI{% + \afterassignment\pgfflt@readexponent@ + \pgfmathfloat@b@E=#1 \pgfflt@EOI% the white space is important, otherwise \pgfflt@EOI will be expanded. +} +\def\pgfflt@readexponent@#1{% + \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E\relax + % + % sanity checking: + \def\pgfmathfloat@loc@TMPb{#1}% + \ifx\pgfmathfloat@loc@TMPb\pgfflt@EOI@unexpanded + \else + \def\pgfmathfloat@loc@TMPb{\pgfflt@error#1}% + \expandafter\pgfmathfloat@loc@TMPb + \fi +} + +\def\pgfflt@pendingzeros@positiveexp#1{% + \expandafter\ifx\csname pgffltE@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltE@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltE@0\endcsname{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \advance\pgfmathfloat@a@E by1 + \pgfflt@pendingzeros@positiveexp}% +\expandafter\def\csname pgffltE@1\endcsname{\pgffltE@nonzerodigit1}% +\expandafter\def\csname pgffltE@2\endcsname{\pgffltE@nonzerodigit2}% +\expandafter\def\csname pgffltE@3\endcsname{\pgffltE@nonzerodigit3}% +\expandafter\def\csname pgffltE@4\endcsname{\pgffltE@nonzerodigit4}% +\expandafter\def\csname pgffltE@5\endcsname{\pgffltE@nonzerodigit5}% +\expandafter\def\csname pgffltE@6\endcsname{\pgffltE@nonzerodigit6}% +\expandafter\def\csname pgffltE@7\endcsname{\pgffltE@nonzerodigit7}% +\expandafter\def\csname pgffltE@8\endcsname{\pgffltE@nonzerodigit8}% +\expandafter\def\csname pgffltE@9\endcsname{\pgffltE@nonzerodigit9}% +\expandafter\def\csname pgffltE@.\endcsname{\pgfflt@finish@number@after@period}% FIXME : inlining? +\expandafter\def\csname pgffltE@,\endcsname{\pgfmathfloat@frenchinput{\pgfflt@finish@number@after@period}}% FIXME : inlining? +\def\pgffltE@e{\pgfflt@readexponent}% FIXME : inlining? +\let\pgffltE@E=\pgffltE@e +\expandafter\def\csname pgffltE@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltE@nonzerodigit#1{% + \advance\pgfmathfloat@a@E by1 + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@positiveexp}% + +\def\pgfflt@finish@number@after@period#1{% + \expandafter\ifx\csname pgffltF@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltF@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltF@0\endcsname{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfflt@pendingzeros}% +\expandafter\def\csname pgffltF@1\endcsname{\pgffltF@nonzerodigit1}% +\expandafter\def\csname pgffltF@2\endcsname{\pgffltF@nonzerodigit2}% +\expandafter\def\csname pgffltF@3\endcsname{\pgffltF@nonzerodigit3}% +\expandafter\def\csname pgffltF@4\endcsname{\pgffltF@nonzerodigit4}% +\expandafter\def\csname pgffltF@5\endcsname{\pgffltF@nonzerodigit5}% +\expandafter\def\csname pgffltF@6\endcsname{\pgffltF@nonzerodigit6}% +\expandafter\def\csname pgffltF@7\endcsname{\pgffltF@nonzerodigit7}% +\expandafter\def\csname pgffltF@8\endcsname{\pgffltF@nonzerodigit8}% +\expandafter\def\csname pgffltF@9\endcsname{\pgffltF@nonzerodigit9}% +\def\pgffltF@e{\pgfflt@readexponent}% +\let\pgffltF@E=\pgffltF@e +\expandafter\def\csname pgffltF@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltF@nonzerodigit#1{% + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@finish@number@after@period}% + + +\def\pgfflt@pendingzeros#1{% + \expandafter\ifx\csname pgffltG@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltG@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltG@0\endcsname{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfflt@pendingzeros}% +\expandafter\def\csname pgffltG@1\endcsname{\pgffltG@nonzerodigit1}% +\expandafter\def\csname pgffltG@2\endcsname{\pgffltG@nonzerodigit2}% +\expandafter\def\csname pgffltG@3\endcsname{\pgffltG@nonzerodigit3}% +\expandafter\def\csname pgffltG@4\endcsname{\pgffltG@nonzerodigit4}% +\expandafter\def\csname pgffltG@5\endcsname{\pgffltG@nonzerodigit5}% +\expandafter\def\csname pgffltG@6\endcsname{\pgffltG@nonzerodigit6}% +\expandafter\def\csname pgffltG@7\endcsname{\pgffltG@nonzerodigit7}% +\expandafter\def\csname pgffltG@8\endcsname{\pgffltG@nonzerodigit8}% +\expandafter\def\csname pgffltG@9\endcsname{\pgffltG@nonzerodigit9}% +\def\pgffltG@e{\pgfflt@readexponent}% FIXME: inlining? +\let\pgffltG@E=\pgffltG@e +\expandafter\def\csname pgffltG@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltG@nonzerodigit#1{% + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@finish@number@after@period}% + +\endinput diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.base.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.base.code.tex new file mode 100644 index 0000000000..fcf5503b36 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.base.code.tex @@ -0,0 +1,330 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% +% This file provides basic macros for converting between bases. +% +% Version 1.4142135 8/11/2008 + +% Base conversion operations for the parser. +% +\pgfmathdeclarefunction{bin}{1}{% + \begingroup% + \afterassignment\pgfmath@gobbletilpgfmath@% + \c@pgfmath@counta=#1\relax\pgfmath@% + \expandafter\pgfmathbasetobase\expandafter\pgfmathresult\expandafter{\the\c@pgfmath@counta}{10}{2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} +\pgfmathdeclarefunction{hex}{1}{% + \begingroup% + \afterassignment\pgfmath@gobbletilpgfmath@% + \c@pgfmath@counta=#1\relax\pgfmath@% + \expandafter\pgfmathbasetobase\expandafter\pgfmathresult\expandafter{\the\c@pgfmath@counta}{10}{16}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +\pgfmathdeclarefunction{Hex}{1}{% + \begingroup% + \afterassignment\pgfmath@gobbletilpgfmath@% + \c@pgfmath@counta=#1\relax\pgfmath@% + \expandafter\pgfmathbasetoBase\expandafter\pgfmathresult\expandafter{\the\c@pgfmath@counta}{10}{16}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +\pgfmathdeclarefunction{oct}{1}{% + \begingroup% + \afterassignment\pgfmath@gobbletilpgfmath@% + \c@pgfmath@counta=#1\relax\pgfmath@% + \expandafter\pgfmathbasetobase\expandafter\pgfmathresult\expandafter{\the\c@pgfmath@counta}{10}{8}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% Additional macros: + +% \pgfmathbasetodec +% +% Convert a representation of an integer from +% the specified base to base 10. +% +% #1 - a macro to store the result. +% #2 - the representation of a number (i.e. not a register) +% #3 - the current base. +% +% e.g. +% +% \pgfmathbasetodec\mynumber{10111}{2} +% +% \mynumber <- 23 +% +\def\pgfmathbasetodec#1#2#3{% + \pgfmath@checknumber{#2}% + \pgfmath@checkbase{#3}% + \def\pgfmath@base{#3}% + \def\pgfmath@base@macro{#1}% + \c@pgfmath@counta=1\relax% + \let\pgfmath@reversed=\pgfmath@empty% + \expandafter\pgfmathbasetodec@#2\pgfmath@base@stop} + +\def\pgfmathbasetodec@#1{% + \ifx#1\pgfmath@base@stop% + \c@pgfmath@countb=0% + \divide\c@pgfmath@counta by\pgfmath@base\relax% + \expandafter\pgfmathbasetodec@@% + \else% + \edef\pgfmath@reversed{\pgfmath@reversed#1}% + \expandafter\multiply\expandafter\c@pgfmath@counta\pgfmath@base\relax% + \expandafter\pgfmathbasetodec@% + \fi} + +\def\pgfmathbasetodec@@{\expandafter\pgfmathbasetodec@@@\pgfmath@reversed\pgfmathbasetodec} + +\def\pgfmathbasetodec@@@#1{% + \ifx\pgfmathbasetodec#1\relax% + \expandafter\edef\pgfmath@base@macro{\the\c@pgfmath@countb}% + \let\pgfmath@next=\pgfmathbasetodec@@@@% + \else% + \chardef\pgfmath@charnum`#1\relax% + \c@pgfmath@countc=\pgfmath@charnum\relax% + \ifnum\c@pgfmath@countc>96\relax% + \advance\c@pgfmath@countc by-87\relax% + \else + \ifnum\c@pgfmath@countc>64\relax% + \advance\c@pgfmath@countc by-55\relax% + \else + \advance\c@pgfmath@countc by-48\relax% + \fi% + \fi% + \ifnum\c@pgfmath@countc<\pgfmath@base\relax% + \multiply\c@pgfmath@countc by\c@pgfmath@counta% + \advance\c@pgfmath@countb by\c@pgfmath@countc% + \divide\c@pgfmath@counta by\pgfmath@base\relax% + \let\pgfmath@next\pgfmathbasetodec@@@% + \else + \pgfmath@error{Digit `#1' invalid for base \pgfmath@base}{}% + \let\pgfmath@next=\relax% + \fi% + \fi% + \pgfmath@next} +\def\pgfmathbasetodec@@@@{% + \expandafter\pgfmath@ensurenumberlength\expandafter{\pgfmath@base@macro}% +} + +% \pgfmathdectobase +% +% Convert a representation of an integer from +% base 10 to the specified base. Letters for bases +% greater than 10 are in lowercase. +% +% #1 - a macro to store the result. +% #2 - a number in base 10 (in a macro, not a register) +% #3 - the required base. +% +% e.g. +% +% \pgfmathdectobase\mynumber{127}{16} +% +% \mynumber <- 7f +% +\def\pgfmathdectobase#1#2#3{% + \pgfmath@checknumber{#2}% + \pgfmath@checkbase{#3}% + \c@pgfmath@counta=#2\relax% + \let#1=\pgfmath@empty% + \pgfmathloop + \ifnum\c@pgfmath@counta>0\relax% + \c@pgfmath@countb=\c@pgfmath@counta% + \divide\c@pgfmath@countb by#3\relax% + \multiply\c@pgfmath@countb by-#3\relax% + \advance\c@pgfmath@countb by\c@pgfmath@counta% + \edef#1{\csname pgfmath@lowercase digit@\the\c@pgfmath@countb\endcsname#1}% + \divide\c@pgfmath@counta by#3\relax% + \repeatpgfmathloop% + \pgfmath@ensurenumberlength{#1}} + +% \pgfmathdectoBase +% +% Convert a representation of an integer from +% base 10 to the specified base. Letters for bases +% greater than 10 are in uppercase. +% +% #1 - a macro to store the result. +% #2 - a number in base 10 (in a macro, not a register) +% #3 - the required base. +% +% e.g. +% +% \pgfmathdectoBase\mynumber{127}{16} +% +% \mynumber <- 7F +% +\def\pgfmathdectoBase#1#2#3{% + \pgfmath@checkbase{#3}% + \pgfmath@checknumber{#2}% + \c@pgfmath@counta=#2\relax% + \let#1=\pgfmath@empty% + \pgfmathloop + \ifnum\c@pgfmath@counta>0\relax% + \c@pgfmath@countb=\c@pgfmath@counta% + \divide\c@pgfmath@countb by#3\relax% + \multiply\c@pgfmath@countb by-#3\relax% + \advance\c@pgfmath@countb by\c@pgfmath@counta% + \edef#1{\csname pgfmath@uppercase digit@\the\c@pgfmath@countb\endcsname#1}% + \divide\c@pgfmath@counta by#3\relax% + \repeatpgfmathloop% + \pgfmath@ensurenumberlength{#1}} + +\def\pgfmath@base@digits@create{% + \def\pgfmath@base@digit@style{lowercase digit}% + \c@pgfmath@counta=0\relax% + \pgfmath@base@digits@create@0123456789abcdefghijklmnopqrstuvwxyz\pgfmath@base@digits@create% + \def\pgfmath@base@digit@style{uppercase digit}% + \c@pgfmath@counta=0\relax% + \pgfmath@base@digits@create@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\pgfmath@base@digits@create} + +\def\pgfmath@base@digits@create@#1{% + \ifx\pgfmath@base@digits@create#1\relax% + \else% + \expandafter\pgfmath@def\expandafter{\pgfmath@base@digit@style}{\the\c@pgfmath@counta}{#1}% + \advance\c@pgfmath@counta by1\relax% + \expandafter\pgfmath@base@digits@create@% + \fi} +\pgfmath@base@digits@create + +% \pgfmathbasetobase +% +% Convert a representation of an integer from +% between the specified bases. Letters for target +% bases greater than 10 are in uppercase. +% +% #1 - a macro to store the result. +% #2 - a number (in a macro, not a register) +% #3 - the source base. +% #4 - the target base. +% +% e.g. +% +% \pgfmathbasetobase\mynumber{4321}{5}{9} +% +% \mynumber <- 721 +% +\def\pgfmathbasetobase#1#2#3#4{% + \pgfmathbasetodec{\pgfmath@base@temp}{#2}{#3}% + \pgfmathdectobase{#1}{\pgfmath@base@temp}{#4}% +} + +% \pgfmathbasetobase +% +% Convert a representation of an integer from +% between the specified bases. Letters for target +% bases greater than 10 are in uppercase. +% +% #1 - a macro to store the result. +% #2 - a number (in a macro, not a register) +% #3 - the source base. +% #4 - the target base. +% +% e.g. +% +% \pgfmathbasetobase\mynumber{1234}{5}{12} +% +% \mynumber <- 142 +% +\def\pgfmathbasetoBase#1#2#3#4{% + \pgfmathbasetodec{\pgfmath@base@temp}{#2}{#3}% + \pgfmathdectoBase{#1}{\pgfmath@base@temp}{#4}% +} + +\def\pgfmath@checkbase#1{% + \ifnum#1<2\relax% + \pgfmath@error{Cannot process numbers in base `#1'.}{}% + \else% + \ifnum#1>36\relax% + \pgfmath@error{Cannot process numbers in base `#1'.}{}% + \fi% + \fi} + +\def\pgfmath@checknumber#1{% + \expandafter\pgfmath@checknumber@#1\pgfmath@} +\def\pgfmath@checknumber@#1#2\pgfmath@{% + \ifx#1-% + \pgfmath@error{Cannot process negative numbers.}{}% + \fi} + +% \pgfmath@ensurenumberlength +% +% Internal macro for making a representation of a number have +% a specific length, byte prefixing zeros to the number. +% +% #1 - a macro containing a representation of an integer. +% #2 - the number of digits to ensure. +% +% e.g. +% +% \foo <- 7FF +% +% \pgfmathsetnumberlength{8}% +% \pgfmath@ensurenumberlength\foo +% +% \foo <- 000007FF +% +\def\pgfmath@ensurenumberlength#1{% + \def\pgfmath@base@tempa{#1}% + \expandafter\c@pgfmath@counta\pgfmath@basenumberlength\relax% + \expandafter\pgfmath@ensurenumberlength@#1\pgfmath@ensurenumberlength} +\def\pgfmath@ensurenumberlength@#1{% + \ifx\pgfmath@ensurenumberlength#1\relax% + \expandafter\pgfmath@ensurenumberlength@@% + \else% + \advance\c@pgfmath@counta by-1\relax% + \expandafter\pgfmath@ensurenumberlength@ + \fi} + +\def\pgfmath@ensurenumberlength@@{% + \edef\pgfmath@base@tempb{\pgfmath@base@tempa}% + \pgfmath@ensurenumberlength@@@} +\def\pgfmath@ensurenumberlength@@@{% + \ifnum\c@pgfmath@counta>0\relax% + \advance\c@pgfmath@counta by-1\relax% + \edef\pgfmath@base@tempb{0\pgfmath@base@tempb}% + \expandafter\pgfmath@ensurenumberlength@@@% + \fi% + \expandafter\edef\pgfmath@base@tempa{\pgfmath@base@tempb}} + +\def\pgfmathsetbasenumberlength#1{\def\pgfmath@basenumberlength{#1}} +\pgfmathsetbasenumberlength{1}% + +% \pgfmathtodigitlist\marg{macro}\marg{number}} +% +% This command converts \meta{number} into a comma-separated +% list of digits and stores the result in \meta{macro}. +% The \marg{number} is \emph{not} parsed before processing. +% +\def\pgfmathtodigitlist#1#2{% + \def\pgfmath@temp{#1}% + \let\pgfmath@digitlist=\pgfutil@empty% + \edef\pgfmath@@tmp{#2}% + \expandafter\pgfmath@todigitlist\pgfmath@@tmp @% +} +\def\pgfmath@base@atchar{@} +\def\pgfmath@todigitlist#1{% + \def\pgfmath@digit{#1}% + \ifx\pgfmath@digit\pgfmath@base@atchar% + \expandafter\let\pgfmath@temp=\pgfmath@digitlist% + \else% + \ifx\pgfmath@digitlist\pgfutil@empty% + \edef\pgfmath@digitlist{#1}% + \else% + \edef\pgfmath@digitlist{\pgfmath@digitlist,#1}% + \fi% + \expandafter\pgfmath@todigitlist% + \fi% +} diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.basic.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.basic.code.tex new file mode 100644 index 0000000000..1607c386e8 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.basic.code.tex @@ -0,0 +1,803 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file defines the mathematical functions and operators. +% +% Version 1.4142135 25/8/2008 + +% add function. +% +\pgfmathdeclarefunction{add}{2}{% + \begingroup% + \pgfmath@x=#1pt\relax% + \pgfmath@y=#2pt\relax% + \advance\pgfmath@x by\pgfmath@y% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + + +% subtract function. +% +\pgfmathdeclarefunction{subtract}{2}{% + \begingroup% + \pgfmath@x=#1pt\relax% + \pgfmath@y=#2pt\relax% + \advance\pgfmath@x by-\pgfmath@y% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% neg function. +% +\pgfmathdeclarefunction{neg}{1}{% + \begingroup% + \pgfmath@x=-#1pt\relax% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} +% change the precedence for neg. +% Otherwise, unary minus and exponentiation won't have the correct precedence +% (test '-2^2') +\def\pgfmath@operation@neg@precedence{500} + +% multiply function. +% +\pgfmathdeclarefunction{multiply}{2}{% + \begingroup% + \pgfmath@x=#1pt\relax% + \pgfmath@y=#2pt\relax% + \pgfmath@x=\pgfmath@tonumber{\pgfmath@y}\pgfmath@x% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% divide function. +% +\newif\ifpgfmath@divide@period + +\pgfmathdeclarefunction{divide}{2}{% + \begingroup% + \pgfmath@x=#1pt\relax% + \pgfmath@y=#2pt\relax% + \let\pgfmath@sign=\pgfmath@empty% + \ifdim0pt=\pgfmath@y% + \pgfmath@error{You've asked me to divide `#1' by `#2', % + but I cannot divide any number by `#2'}{}% + \fi% + \afterassignment\pgfmath@xa% + \c@pgfmath@counta\the\pgfmath@y\relax% + \ifdim0pt=\pgfmath@xa% + \divide\pgfmath@x by\c@pgfmath@counta% + \else% + \ifdim0pt>\pgfmath@x% + \def\pgfmath@sign{-}% + \pgfmath@x=-\pgfmath@x% + \fi% + \ifdim0pt>\pgfmath@y% + \expandafter\def\expandafter\pgfmath@sign\expandafter{\pgfmath@sign-}% + \pgfmath@y=-\pgfmath@y% + \fi% + \ifdim1pt>\pgfmath@y% + \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}% + \pgfmath@x=\pgfmath@sign\pgfmathresult\pgfmath@x% + \else% + \def\pgfmathresult{0}% + \pgfmath@divide@periodtrue% + \c@pgfmath@counta=0\relax% + \pgfmathdivide@@% + \pgfmath@x=\pgfmath@sign\pgfmathresult pt\relax% + \fi% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +\def\pgfmath@small@number{0.00002} + +\def\pgfmathdivide@@{% + \let\pgfmath@next=\relax% + \ifdim\pgfmath@small@number pt<\pgfmath@x% + \ifdim\pgfmath@small@number pt<\pgfmath@y% + \ifdim\pgfmath@y>\pgfmath@x% + \ifpgfmath@divide@period% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult.}% + \pgfmath@divide@periodfalse% + \fi% + \pgfmathdivide@dimenbyten\pgfmath@y% + \ifdim\pgfmath@y>\pgfmath@x% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult0}% + \fi% + \else% + \c@pgfmath@counta=\pgfmath@x% + \c@pgfmath@countb=\pgfmath@y% + \divide\c@pgfmath@counta by\c@pgfmath@countb% + \pgfmath@ya=\c@pgfmath@counta\pgfmath@y% + \advance\pgfmath@x by-\pgfmath@ya% + \def\pgfmath@next{% + \toks0=\expandafter{\pgfmathresult}% + \edef\pgfmathresult{\the\toks0 \the\c@pgfmath@counta}% + }% + \ifpgfmath@divide@period + \else + % we are behind the period. It may happen that the + % result is more than one digit - in that case, + % introduce special handling: + \ifnum\c@pgfmath@counta>9 % + \expandafter\pgfmathdivide@advance@last@digit\pgfmathresult CCCCC\@@ + \advance\c@pgfmath@counta by-10 % + \ifnum\c@pgfmath@counta=0 + \let\pgfmath@next=\relax + \fi + \fi + \fi + \pgfmath@next + \fi% + \let\pgfmath@next=\pgfmathdivide@@% + \fi% + \fi% + \pgfmath@next% +} + +% advances the last digit found in the number. Any missing digits are +% supposed to be filled with 'C'. +\def\pgfmathdivide@advance@last@digit#1.#2#3#4#5#6#7\@@{% + \pgfmath@ya=\pgfmathresult pt % + \if#2C% + \pgfmath@xa=1pt % + \else + \if#3C% + \pgfmath@xa=0.1pt % + \else + \if#4C% + \pgfmath@xa=0.01pt % + \else + \if#5C% + \pgfmath@xa=0.001pt % + \else + \if#6C% + \pgfmath@xa=0.0001pt % + \else + \pgfmath@xa=0.00001pt % + \fi + \fi + \fi + \fi + \fi + \advance\pgfmath@ya by\pgfmath@xa + \edef\pgfmathresult{\pgfmath@tonumber@notrailingzero\pgfmath@ya}% +}% + +{ +\catcode`\p=12 +\catcode`\t=12 +\gdef\Pgf@geT@NO@TRAILING@ZERO#1.#2pt{% + #1.% + \ifnum#2=0 \else #2\fi +} +} +\def\pgfmath@tonumber@notrailingzero#1{\expandafter\Pgf@geT@NO@TRAILING@ZERO\the#1} + + +\def\pgfmathdivide@dimenbyten#1{% + \edef\pgfmath@temp{\pgfmath@tonumber{#1}}% + \expandafter\pgfmathdivide@@dimenbyten\pgfmath@temp\@@#1\@@} +\def\pgfmathdivide@@dimenbyten#1.#2\@@#3\@@{% + \pgfmath@tempcnta=#1\relax% + \divide\pgfmath@tempcnta by10\relax% + \pgfmath@tempcntb=\pgfmath@tempcnta% + \multiply\pgfmath@tempcnta by-10\relax% + \advance\pgfmath@tempcnta by#1\relax% + #3=\the\pgfmath@tempcntb.\the\pgfmath@tempcnta#2pt\relax% +} + + +% reciprocal function. +% +\pgfmathdeclarefunction{reciprocal}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \ifdim\pgfmath@x=0pt\relax% + \pgfmath@error{You asked me to calculate `1/#1', but I cannot divide any number by zero}{}% + \fi% + \edef\pgfmath@reciprocaltemp{\pgfmath@tonumber{\pgfmath@x}}% + \expandafter\pgfmathreciprocal@@\pgfmath@reciprocaltemp0000000\pgfmath@} +\def\pgfmathreciprocal@@#1.#2#3#4#5#6#7\pgfmath@{% + \c@pgfmath@counta#2#3#4#5#6\relax% + % If the number is an integer, use TeX arithmetic. + \ifnum\c@pgfmath@counta=0\relax% + \pgfmath@x1pt\relax% + \divide\pgfmath@x#1\relax% + \else% + \ifnum#1>100\relax% + \c@pgfmath@counta#1#2#3#4\relax% + \c@pgfmath@countb1000000000\relax% + \divide\c@pgfmath@countb\c@pgfmath@counta% + \c@pgfmath@counta\c@pgfmath@countb% + \divide\c@pgfmath@counta10000\relax% + \pgfmath@x\c@pgfmath@counta pt\relax% + \multiply\c@pgfmath@counta-10000\relax% + \advance\c@pgfmath@countb\c@pgfmath@counta% + \pgfmath@y\c@pgfmath@countb pt\relax% + \divide\pgfmath@y1000000\relax% + \advance\pgfmath@x\pgfmath@y% + \else% + \c@pgfmath@counta#1#2#3#4#5#6\relax% + \c@pgfmath@countb1000000000\relax% + \divide\c@pgfmath@countb\c@pgfmath@counta% + \c@pgfmath@counta\c@pgfmath@countb% + \divide\c@pgfmath@counta10000\relax% + \pgfmath@x\c@pgfmath@counta pt\relax% + \multiply\c@pgfmath@counta-10000\relax% + \advance\c@pgfmath@countb\c@pgfmath@counta% + \pgfmath@y\c@pgfmath@countb pt\relax% + \pgfmath@y.1\pgfmath@y% Yes! This way is more accurate. Go figure... + \pgfmath@y.1\pgfmath@y% + \pgfmath@y.1\pgfmath@y% + \pgfmath@y.1\pgfmath@y% + \advance\pgfmath@x\pgfmath@y% + \fi% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% div function. +% +\pgfmathdeclarefunction{div}{2}{% + \begingroup% + \pgfmathdivide@{#1}{#2}% + \ifdim\pgfmathresult pt<0pt\relax% + \pgfmathceil@{\pgfmathresult}% + \else% + \pgfmathfloor@{\pgfmathresult}% + \fi% + \afterassignment\pgfmath@gobbletilpgfmath@% + \c@pgfmath@counta=\pgfmathresult\relax\pgfmath@% + \edef\pgfmathresult{\the\c@pgfmath@counta}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% mod function. +% +\pgfmathdeclarefunction{mod}{2}{% + \begingroup% + \pgfmath@xa#1pt% + \pgfmath@xb#2pt% + \pgfmath@x\pgfmath@xa% + \c@pgfmath@counta\pgfmath@xa% + \c@pgfmath@countb\pgfmath@xb% + \divide\c@pgfmath@counta\c@pgfmath@countb% + \multiply\pgfmath@xb\c@pgfmath@counta% + \advance\pgfmath@x-\pgfmath@xb% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% Mod function (never negative). +% +\pgfmathdeclarefunction{Mod}{2}{% + \begingroup% + \pgfmathmod@{#1}{#2}% + \pgfmath@x=\pgfmathresult pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \advance\pgfmath@x by#2pt\relax% + \fi% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% abs function. +% +\pgfmathdeclarefunction{abs}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% sign(x) +\pgfmathdeclarefunction{sign}{1}{% + \begingroup + \ifdim#1pt>0sp % + \def\pgfmathresult{1}% + \else + \ifdim#1pt=0sp % + \def\pgfmathresult{0}% + \else + \def\pgfmathresult{-1}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% e constant. +% +\pgfmathdeclarefunction{e}{0}{\def\pgfmathresult{2.718281828}} + +% ln function. +% +% This is based on an algorithm due to Rouben Rostamian and +% uses coefficients contributed by Alain Matthes. +% +\pgfmathdeclarefunction{ln}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \ifdim\pgfmath@x>0pt\else% + \pgfmath@error{I cannot calculate the logarithm of `#1'}{}% + \fi% + \c@pgfmath@counta=0\relax% + \ifdim\pgfmath@x>2pt\relax% + \ifdim\pgfmath@x<128pt\relax% + \ifdim\pgfmath@x<8pt\relax% + \ifdim\pgfmath@x<4pt\relax% + \divide\pgfmath@x by2\relax% + \c@pgfmath@counta=1\relax% + \else% + \divide\pgfmath@x by4\relax% + \c@pgfmath@counta=2\relax% + \fi% + \else% + \ifdim\pgfmath@x<32pt\relax% + \ifdim\pgfmath@x<16pt\relax% + \divide\pgfmath@x by8\relax% + \c@pgfmath@counta=3\relax% + \else% + \divide\pgfmath@x by16\relax% + \c@pgfmath@counta=4\relax% + \fi% + \else% + \ifdim\pgfmath@x<64pt\relax% + \divide\pgfmath@x by32\relax% + \c@pgfmath@counta=5\relax% + \else% + \divide\pgfmath@x by64\relax% + \c@pgfmath@counta=6\relax% + \fi% + \fi% + \fi% + \else% + \ifdim\pgfmath@x<2048pt\relax% + \ifdim\pgfmath@x<512pt\relax% + \ifdim\pgfmath@x<256pt\relax% + \divide\pgfmath@x by128\relax% + \c@pgfmath@counta=7\relax% + \else% + \divide\pgfmath@x by256\relax% + \c@pgfmath@counta=8\relax% + \fi% + \else% + \ifdim\pgfmath@x<1024pt\relax% + \divide\pgfmath@x by512\relax% + \c@pgfmath@counta=9\relax% + \else% + \divide\pgfmath@x by1024\relax% + \c@pgfmath@counta=10\relax% + \fi% + \fi% + \else% + \ifdim\pgfmath@x<8192pt\relax% + \ifdim\pgfmath@x<4096pt\relax% + \divide\pgfmath@x by2048\relax% + \c@pgfmath@counta=11\relax% + \else% + \divide\pgfmath@x by4096\relax% + \c@pgfmath@counta =12\relax% + \fi% + \else% + \divide\pgfmath@x by8192\relax% + \c@pgfmath@counta=13\relax% + \fi% + \fi% + \fi% + \else% + \ifdim\pgfmath@x<1pt\relax% + \ifdim\pgfmath@x>0.0078125pt\relax% 2^-7 + \ifdim\pgfmath@x>0.125pt\relax% 2^-3 + \ifdim\pgfmath@x>0.5pt\relax% 2^-1 + \multiply\pgfmath@x by2\relax% + \c@pgfmath@counta=-1\relax% + \else% + \multiply\pgfmath@x by4\relax% + \c@pgfmath@counta=-2\relax% + \fi% + \else% + \ifdim\pgfmath@x>0.03125pt\relax% 2^-5 + \ifdim\pgfmath@x>0.0625pt\relax% + \multiply\pgfmath@x by8\relax% + \c@pgfmath@counta=-3\relax% + \else% + \multiply\pgfmath@x by16\relax% + \c@pgfmath@counta=-4\relax% + \fi% + \else% + \ifdim\pgfmath@x>0.015625pt\relax% 2^-6 + \multiply\pgfmath@x by32\relax% + \c@pgfmath@counta=-5\relax% + \else% + \multiply\pgfmath@x by64\relax% + \c@pgfmath@counta=-6\relax% + \fi% + \fi% + \fi% + \else% + \ifdim\pgfmath@x>0.00048828125pt\relax% 2^-11 + \ifdim\pgfmath@x>0.001953125pt\relax% 2^-9 + \ifdim\pgfmath@x>0.00390625pt\relax% 2^-8 + \multiply\pgfmath@x by128\relax% + \c@pgfmath@counta=-7\relax% + \else% + \multiply\pgfmath@x by256\relax% + \c@pgfmath@counta=-8\relax% + \fi% + \else% + \ifdim\pgfmath@x>0.0009765625pt\relax% 2^-10 + \multiply\pgfmath@x by512\relax% + \c@pgfmath@counta=-9\relax% + \else% + \multiply\pgfmath@x by1024\relax% + \c@pgfmath@counta=-10\relax% + \fi% + \fi% + \else% + \ifdim\pgfmath@x>0.0001220703125pt\relax% 2^13 + \ifdim\pgfmath@x>0.0002441406256pt\relax% 2^12 + \multiply\pgfmath@x by2048\relax% + \c@pgfmath@counta=-11\relax% + \else% + \multiply\pgfmath@x by4096\relax% + \c@pgfmath@counta=-12\relax% + \fi% + \else% + \multiply\pgfmath@x by8192\relax% + \c@pgfmath@counta=-13\relax% + \fi% + \fi% + \fi% + \fi% + \fi% + % + % Use A+(B+(C+(D+(E+F*x)*x)*x)*x)*x + % + % where: + % A = -2.787927935 + % B = 5.047861502 + % C = -3.489886985 + % D = 1.589480044 + % E = -.4025153233 + % F = 0.04300521312 + % + \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@x=0.04300521312\pgfmath@x% + \advance\pgfmath@x by-.4025153233pt\relax% + \pgfmath@x=\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x by1.589480044pt\relax% + \pgfmath@x=\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x by-3.489886985pt\relax% + \pgfmath@x=\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x by5.047861502pt\relax% + \pgfmath@x=\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x by-2.787927935pt\relax% + \advance\pgfmath@x by\c@pgfmath@counta pt\relax% + \pgfmath@x=0.6931471806\pgfmath@x% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% log2 function. +% +\pgfmathdeclarefunction{log2}{1}{% + \begingroup% + \pgfmathln@{#1}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmath@x=1.442695041\pgfmath@x% 1/ln(2). + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% log10 function +% +\pgfmathdeclarefunction{log10}{1}{% + \begingroup% + \pgfmathln@{#1}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmath@x=0.43429441\pgfmath@x% 1/ln(10). + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% This is needed since \pgfmathlog2 and \pgfmathlog10 are not legal macro names +\expandafter\let\expandafter\pgfmathlogtwo\csname pgfmathlog2\endcsname +\expandafter\let\expandafter\pgfmathlogtwo@\csname pgfmathlog2@\endcsname +\expandafter\let\expandafter\pgfmathlogten\csname pgfmathlog10\endcsname +\expandafter\let\expandafter\pgfmathlogten@\csname pgfmathlog10@\endcsname + +% exp function. +% +\pgfmathdeclarefunction{exp}{1}{% + \begingroup + \pgfmath@xc=#1pt\relax + \pgfmath@yc=#1pt\relax + \ifdim\pgfmath@xc<-9pt + \pgfmath@x=1sp\relax + \else + \ifdim\pgfmath@xc<0pt + \pgfmath@xc=-\pgfmath@xc + \fi + \pgfmath@x=1pt\relax + \pgfmath@xa=1pt\relax + \pgfmath@xb=\pgfmath@x + \pgfmathloop% + \divide\pgfmath@xa by\pgfmathcounter + \pgfmath@xa=\pgfmath@tonumber\pgfmath@xc\pgfmath@xa% + \advance\pgfmath@x by\pgfmath@xa + \ifdim\pgfmath@x=\pgfmath@xb + \else + \pgfmath@xb=\pgfmath@x + \repeatpgfmathloop% + \ifdim\pgfmath@yc<0pt + \pgfmathreciprocal@{\pgfmath@tonumber\pgfmath@x}% + \pgfmath@x=\pgfmathresult pt\relax + \fi + \fi + \pgfmath@returnone\pgfmath@x% + \endgroup +} + +% sqrt function. +% +\pgfmathdeclarefunction{sqrt}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@error{I cannot calculate the square-root of the negative number `#1'}{}% + \else% + \ifdim\pgfmath@x<10pt\relax% + \def\pgfmath@zeros{0}% + \def\pgfmath@targetiterations{1}% + \else% + \ifdim\pgfmath@x<100pt\relax% + \def\pgfmath@zeros{}% + \def\pgfmath@targetiterations{1}% + \else% + \ifdim\pgfmath@x<1000pt\relax% + \def\pgfmath@zeros{0}% + \def\pgfmath@targetiterations{2}% + \else% + \ifdim\pgfmath@x<10000pt\relax% + \def\pgfmath@zeros{}% + \def\pgfmath@targetiterations{2}% + \else% + \def\pgfmath@zeros{0}% + \def\pgfmath@targetiterations{3}% + \fi\fi\fi\fi\fi% + \edef\pgfmath@temp{\pgfmath@zeros\pgfmath@tonumber{\pgfmath@x}}% + \expandafter\pgfmath@sqrt@\pgfmath@temp\pgfmath@% +} +\def\pgfmath@sqrt@#1.#2\pgfmath@{\pgfmath@@sqrt@#1#2\pgfmath@empty\pgfmath@empty\pgfmath@} + +\def\pgfmath@@sqrt@#1#2{% + \c@pgfmath@countb=#1#2\relax% + \ifnum\c@pgfmath@countb>35\relax% + \ifnum\c@pgfmath@countb>63\relax% + \ifnum\c@pgfmath@countb>80\relax% + \c@pgfmath@counta=9\relax% + \else% + \c@pgfmath@counta=8\relax% + \fi% + \else% + \ifnum\c@pgfmath@countb>48\relax% + \c@pgfmath@counta=7\relax% + \else% + \c@pgfmath@counta=6\relax% + \fi% + \fi% + \else% + \ifnum\c@pgfmath@countb>15\relax% + \ifnum\c@pgfmath@countb>24\relax% + \c@pgfmath@counta5\relax% + \else% + \c@pgfmath@counta=4\relax% + \fi% + \else% + \ifnum\c@pgfmath@countb>3\relax% + \ifnum\c@pgfmath@countb>8\relax% + \c@pgfmath@counta=3\relax% + \else% + \c@pgfmath@counta=2\relax% + \fi% + \else% + \ifnum\c@pgfmath@countb>0\relax% + \c@pgfmath@counta=1\relax% + \else% + \c@pgfmath@counta=0\relax% + \fi% + \fi% + \fi% + \fi% + \edef\pgfmath@root{\the\c@pgfmath@counta}% + \edef\pgfmath@rootspecial{\the\c@pgfmath@counta}% + \multiply\c@pgfmath@counta by-\c@pgfmath@counta\relax% + \advance\c@pgfmath@counta by#1#2\relax% + \edef\pgfmath@remainder{\the\c@pgfmath@counta}% + \pgfmath@@@sqrt@% +} + +\def\pgfmath@@@sqrt@#1#2{% + \ifx\pgfmath@empty#1% + \edef\pgfmath@remainder{\pgfmath@remainder00}% + \def\pgfmath@tokens{\pgfmath@empty\pgfmath@empty}% + \else% + \ifx\pgfmath@empty#2% + \edef\pgfmath@remainder{\pgfmath@remainder#10}% + \def\pgfmath@tokens{\pgfmath@empty\pgfmath@empty}% + \else% + \edef\pgfmath@remainder{\pgfmath@remainder#1#2}% + \def\pgfmath@tokens{}% + \fi\fi% + \c@pgfmath@counta=\pgfmath@rootspecial\relax% + \multiply\c@pgfmath@counta by20\relax% + \c@pgfmath@countb=\c@pgfmath@counta% + \multiply\c@pgfmath@countb by6\relax% + \advance\c@pgfmath@countb by36\relax% + \c@pgfmath@countc=\c@pgfmath@counta% + \multiply\c@pgfmath@countc by2\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \advance\c@pgfmath@countb by-\c@pgfmath@countc% + \advance\c@pgfmath@countb by-20\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \advance\c@pgfmath@countb by-\c@pgfmath@countc% + \advance\c@pgfmath@countb by-12\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \advance\c@pgfmath@countb by-\c@pgfmath@counta% + \advance\c@pgfmath@countb by-3\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \def\pgfmath@digit{0}% + \else% + \def\pgfmath@digit{1}% + \fi% + \else% + \advance\c@pgfmath@countb by\c@pgfmath@counta% + \advance\c@pgfmath@countb by5\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \def\pgfmath@digit{2}% + \else% + \def\pgfmath@digit{3}% + \fi% + \fi% + \else% + \advance\c@pgfmath@countb by\c@pgfmath@counta% + \advance\c@pgfmath@countb by9\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \def\pgfmath@digit{4}% + \else% + \def\pgfmath@digit{5}% + \fi% + \fi% + \else% + \advance\c@pgfmath@countb by\c@pgfmath@countc% + \advance\c@pgfmath@countb by28\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \advance\c@pgfmath@countb by-\c@pgfmath@counta% + \advance\c@pgfmath@countb by-15\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \def\pgfmath@digit{6}% + \else% + \def\pgfmath@digit{7}% + \fi% + \else% + \advance\c@pgfmath@countb by\c@pgfmath@counta% + \advance\c@pgfmath@countb by17\relax% + \ifnum\c@pgfmath@countb>\pgfmath@remainder\relax% + \def\pgfmath@digit{8}% + \else% + \def\pgfmath@digit{9}% + \fi% + \fi% + \fi% + \edef\pgfmath@rootspecial{\pgfmath@rootspecial\pgfmath@digit}% + \advance\c@pgfmath@counta by\pgfmath@digit\relax% + \multiply\c@pgfmath@counta by-\pgfmath@digit\relax% + \advance\c@pgfmath@counta by\pgfmath@remainder\relax% + \edef\pgfmath@remainder{\the\c@pgfmath@counta}% + \c@pgfmath@counta=\pgfmath@targetiterations\relax% + \advance\c@pgfmath@counta by-1\relax% + \edef\pgfmath@targetiterations{\the\c@pgfmath@counta}% + \ifnum\c@pgfmath@counta=0\relax% + \edef\pgfmath@root{\pgfmath@root.\pgfmath@digit}% + \else% + \edef\pgfmath@root{\pgfmath@root\pgfmath@digit}% + \fi% + \ifnum\c@pgfmath@counta=-4\relax% -n+1 digits of precision. + \let\pgfmath@next\pgfmath@sqrt@end% + \else% + \let\pgfmath@next\pgfmath@@@sqrt@% + \fi% + \expandafter\pgfmath@next\pgfmath@tokens% +} + +\def\pgfmath@sqrt@end#1\pgfmath@{% + \edef\pgfmathresult{\pgfmath@root}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup} + +% \pgfmathpow +% +% Calculates #1 ^ #2 +% +\pgfmathdeclarefunction{pow}{2}{% + \begingroup% + \pgfmath@xa=#1pt% + \pgfmath@xb=#2pt% + \ifdim\pgfmath@xa=0pt\relax% + \ifdim\pgfmath@xb=0pt\relax% + \pgfmath@x=1pt\relax% + \else% + \pgfmath@x=0pt\relax% + \fi% + \else% + \afterassignment\pgfmath@x% + \expandafter\c@pgfmath@counta\the\pgfmath@xb\relax% + \ifnum\c@pgfmath@counta<0\relax% + \c@pgfmath@counta=-\c@pgfmath@counta% + \pgfmathreciprocal@{#1}% + \pgfmath@xa=\pgfmathresult pt\relax% + \fi + \ifdim\pgfmath@x=0pt\relax% + \pgfmath@x=1pt\relax% + \pgfmathloop% + \ifnum\c@pgfmath@counta>0\relax% + \ifodd\c@pgfmath@counta% + \pgfmath@x=\pgfmath@tonumber{\pgfmath@x}\pgfmath@xa% + \fi + \ifnum\c@pgfmath@counta>1\relax% + \pgfmath@xa=\pgfmath@tonumber{\pgfmath@xa}\pgfmath@xa% + \fi% + \divide\c@pgfmath@counta by2\relax% + \repeatpgfmathloop% + \else% + \pgfmathln@{#1}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmath@x=\pgfmath@tonumber{\pgfmath@xb}\pgfmath@x% + \pgfmathexp@{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@x=\pgfmathresult pt\relax% + \fi% + \fi + \pgfmath@returnone\pgf@x% + \endgroup% +} + +% factorial function. +% +\pgfmathdeclarefunction{factorial}{1}{% + \begingroup% + \afterassignment\pgfmath@gobbletilpgfmath@% + \c@pgfmath@counta=#1\relax\pgfmath@% + \pgfmath@x=1pt\relax% + \pgfmathloop% + \ifnum\c@pgfmath@counta<2\relax% + \else% + \multiply\pgfmath@x by\c@pgfmath@counta% + \advance\c@pgfmath@counta by-1\relax% + \repeatpgfmathloop% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% Local Variables: +% coding: undecided-unix +% End: diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.code.tex new file mode 100644 index 0000000000..6e5d079c6b --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.code.tex @@ -0,0 +1,267 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% Declare a function for the parser. +% +% #1 - the name of the function. +% #2 - arity (or ... for variable arguments). +% #3 - the code for the function. +% +% Use \pgfmathdeclarefunction* to force a redefinition if the function exists already. +\def\pgfmathdeclarefunction{\pgfmath@ifnextchar*\pgfmathdeclarefunction@force\pgfmathdeclarefunction@check} +\def\pgfmathdeclarefunction@check#1{% + \expandafter\ifx\csname pgfmath@function@#1\endcsname\relax\else% + \pgfmath@error{The function `#1' already exists}{}% + \fi% + \pgfmath@declarefunction{#1}% +} +\def\pgfmathdeclarefunction@force*{\pgfmath@declarefunction}% + +\def\pgfmathredeclarefunction#1#2{% + \expandafter\ifx\csname pgfmath@function@#1\endcsname\relax% + \pgfmath@error{The function `#1' does not exist}{}% + \else% + % was: \pgfmath@namedef{pgfmath#1@}{#2}% TT + \edef\pgf@marshal{\noexpand\pgfmathdeclarefunction*{#1}{\csname pgfmath@operation@#1@arity\endcsname}}% + \pgf@marshal{#2}% + \fi% +} + +\def\pgfmath@declarefunction#1#2{% + \pgfmath@namedef{pgfmath@function@#1}{#1}% + \pgfmath@namedef{pgfmath@operation@#1@type}{function}% + \pgfmath@namedef{pgfmath@operation@#1@arity}{#2}% + \pgfmath@namedef{pgfmath@operation@#1@infix}{#1}% + \pgfmath@namedef{pgfmath@operation@#1@precedence}{1000}% + \expandafter\ifx\csname pgfmath@operation@#1@arity\endcsname\pgfmath@dots% + \pgfmath@namedef{pgfmath@operation@#1@arity}{1}% + \else% + \ifnum\csname pgfmath@operation@#1@arity\endcsname>9\relax% + \pgfmath@namedef{pgfmath@operation@#1@arity}{1}% + \fi% + \fi% + \edef\pgfmath@marshal{% + \noexpand\pgfmath@@declarefunction% + {\expandafter\noexpand\csname pgfmath#1\endcsname}% + {\expandafter\noexpand\csname pgfmath#1@\endcsname}% + {\csname pgfmath@operation@#1@arity\endcsname}% + }% + \pgfkeysvalueof{/pgf/declare function/execute at begin function}% + \pgfmath@marshal% +} + +% #1 - \pgfmath<name>. +% #2 - \pgfmath<name>@. +% #3 - arity. +% #4 - code for function <name>. +% +\def\pgfmath@@declarefunction#1#2#3#4{% Function of arity 0 - 9. + \pgfkeysvalueof{/pgf/declare function/execute at end function}% + \ifcase#3\relax% + \def#1{#2}% + \def\pgfmath@@head{\def#2}% + \or + \def#1##1{\pgfmathparse{##1}\expandafter#2\expandafter{\pgfmathresult}}% + \def\pgfmath@@head{\def#2####1}% + \else% + \pgfmath@toks={}% + \pgfmathloop% + \ifnum\pgfmathcounter>#3\relax% + \else% + \expandafter\pgfmath@addto@toks\expandafter{\pgfmath@char@hash}% + \expandafter\pgfmath@addto@toks\expandafter{\pgfmathcounter}% + \repeatpgfmathloop% + \edef\pgfmath@head{\noexpand\def\noexpand#1\the\pgfmath@toks}% + \edef\pgfmath@@head{\noexpand\def\noexpand#2\the\pgfmath@toks}% + \pgfmath@toks={}% + \def\pgfmath@arguments{}% + \pgfmathloop% + \ifnum\pgfmathcounter>#3\relax% + \else% + \pgfmath@addto@toks{\pgfmathparse}% + \expandafter\expandafter\expandafter\pgfmath@addto@toks% + \expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter% + {\expandafter\pgfmath@char@hash\pgfmathcounter}}% + \pgfmath@addto@toks{\let}% + \expandafter\pgfmath@addto@toks\expandafter{% + \csname pgfmath@argument@\pgfmathcounter\endcsname=\pgfmathresult}% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% + \pgfmath@arguments\expandafter\expandafter\expandafter{\expandafter% + \pgfmath@arguments\expandafter{\csname pgfmath@argument@\pgfmathcounter\endcsname}}% + \repeatpgfmathloop% + \expandafter\pgfmath@addto@toks\expandafter{\expandafter#2\pgfmath@arguments}% + \edef\pgfmath@body{{\the\pgfmath@toks}}% + \expandafter\pgfmath@head\pgfmath@body% + \fi% + \pgfmath@@head{#4}% +} + +\def\pgfmath@addto@toks#1{% + \edef\pgfmath@toks@expanded{\the\pgfmath@toks}% + \expandafter\pgfmath@toks\expandafter{\pgfmath@toks@expanded#1}} + +% Key for declaring local functions. +% +\pgfkeys{% + /pgf/declare function/.code={% + \pgfmath@local@functions#1@=@;% + }, + /pgf/declare function/execute at begin function/.initial={}, + /pgf/declare function/execute at end function/.initial={}, + /pgf/declare function/ignore spaces/.is choice, + /pgf/declare function/ignore spaces/.default=true, + /pgf/declare function/ignore spaces/true/.style={% + /pgf/declare function/execute at begin function={% + \begingroup + \catcode`\^^I=9\relax + \catcode`\ =9\relax + \catcode`\~=10\relax + \endlinechar=`\ \relax + }, + /pgf/declare function/execute at end function={% + \endgroup + }, + }, + /pgf/declare function/ignore spaces/false/.style={% + /pgf/declare function/execute at begin function={}, + /pgf/declare function/execute at end function={}, + }, +} + +\def\pgfmath@local@gobbleone#1{} +\def\pgfmath@local@at{@}% + +\def\pgfmath@local@functions{% + \pgfutil@ifnextchar x{\pgfmath@local@@functions}{\pgfmath@local@@functions}% +} + +\def\pgfmath@local@@functions#1=#2;{% + \def\pgfmath@local@temp{#1}% + \ifx\pgfmath@local@temp\pgfmath@local@at% + \let\pgfmath@local@next=\relax% + \else% + \pgfmath@local@function#1=#2;% + \let\pgfmath@local@next=\pgfmath@local@functions% + \fi% + \pgfmath@local@next% +} + +\def\pgfmath@local@function{% + \let\pgfmath@local@name=\pgfutil@empty% + \let\pgfmath@local@args=\pgfutil@empty% + \let\pgfmath@local@body=\pgfutil@empty% + \pgfmath@local@@function} + +\def\pgfmath@local@@function#1{% + \if#1=% + \let\pgfmath@local@next=\pgfmath@local@function@body% + \else% + \if#1(% + \let\pgfmath@local@next=\pgfmath@local@function@args% + \else% + \expandafter\def\expandafter\pgfmath@local@name\expandafter{\pgfmath@local@name#1}% + \let\pgfmath@local@next=\pgfmath@local@@function% + \fi% + \fi% + \pgfmath@local@next% +} + +\def\pgfmath@local@function@args#1){% + \def\pgfmath@local@args{#1}% + \pgfmath@local@@function} + +\def\pgfmath@local@function@body#1;{% + \def\pgfmath@local@body{#1}% + \begingroup% + \c@pgf@counta=0\relax% + \ifx\pgfmath@local@args\pgfmath@empty% + \expandafter\pgfmath@toks\expandafter=\expandafter{\pgfmath@local@body}% + \else% + \pgfmath@toks={}% + \expandafter\pgfmath@local@function@@body\pgfmath@local@args,,% + \fi% + \xdef\pgfmath@local@temp{% + \noexpand\pgfmathnotifynewdeclarefunction{\pgfmath@local@name}{\the\c@pgf@counta}% + {\the\pgfmath@toks}% + }% + \endgroup% + \pgfmath@local@temp% +} + +% #1: the name +% #2: the number of arguments <n> +% #3: a math expression containing '#1', '#2', ... ,'#'<n> +% This callback is overwritten by pgflibraryluamath. +\def\pgfmathnotifynewdeclarefunction#1#2#3{% + \pgfmathdeclarefunction{#1}{#2}{\pgfmathparse{#3}}% +}% + +\def\pgfmath@local@function@@body#1,{% + \def\pgfmath@local@test{#1}% + \ifx\pgfmath@local@test\pgfutil@empty% + \let\pgfmath@local@next=\relax% + \else% + \edef\pgfmath@local@var@string{@\expandafter\pgfmath@local@gobbleone\string#1}% + \advance\c@pgf@counta by1\relax% + \expandafter\expandafter\expandafter\pgfmath@toks\expandafter\expandafter\expandafter=% + \expandafter\expandafter\expandafter{\expandafter\pgfmath@char@hash\the\c@pgf@counta}% + \edef#1{\the\pgfmath@toks}% + \pgfmath@toks={}% + \expandafter\pgfmath@local@function@@@body\pgfmath@local@body @% + \edef\pgfmath@local@body{\the\pgfmath@toks}% + \let\pgfmath@local@next=\pgfmath@local@function@@body% + \fi% + \pgfmath@local@next% +} + +\def\pgfmath@local@function@@@body{% + \pgfutil@ifnextchar\bgroup{\pgfmath@local@function@@@body@bgroup}% + {\pgfmath@local@function@@@body@nobgroup}}% + +\def\pgfmath@local@function@@@body@bgroup#1{% + \begingroup% + \pgfmath@toks={}% + \pgfmath@local@function@@@body#1 @% + \xdef\pgfmath@local@temp{{\the\pgfmath@toks}}% + \endgroup% + \expandafter\pgfmath@addto@toks\expandafter{\pgfmath@local@temp}% + \pgfmath@local@function@@@body% +} + +\def\pgfmath@local@function@@@body@nobgroup#1{% + \ifx#1@% + \let\pgfmath@local@next=\relax% + \else% + \let\pgfmath@local@next=\pgfmath@local@function@@@body% + \edef\pgfmath@local@var@@string{@\expandafter\pgfmath@local@gobbleone\string#1}% + \ifx\pgfmath@local@var@@string\pgfmath@local@var@string% + \expandafter\pgfmath@addto@toks\expandafter{#1}% + \else% + \edef\pgfmath@local@temp{\the\pgfmath@toks}% + \pgfmath@toks={#1}% + \edef\pgfmath@local@@temp{\the\pgfmath@toks}% + \expandafter\pgfmath@toks\expandafter=\expandafter{\pgfmath@local@temp}% + \expandafter\pgfmath@addto@toks\expandafter{\pgfmath@local@@temp}% + \fi% + \fi% + \pgfmath@local@next% +} + +% Allows to define 'x' as some \TeX command '#2'. +\def\pgfmathdeclarepseudoconstant#1#2{% + \pgfmathdeclarefunction*{#1}{0}{#2}% +}% +% Redefines a pseudo constant '#1'. +\def\pgfmathredeclarepseudoconstant#1#2{% + \pgfmathredeclarefunction{#1}{#2}% +}% + +% Local Variables: +% tab-width: 2 +% End: diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.comparison.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.comparison.code.tex new file mode 100644 index 0000000000..a0632670d8 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.comparison.code.tex @@ -0,0 +1,179 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file defines the mathematical functions and operators. +% +% Version 1.4142135 11/8/2008 + +\pgfmathdeclarefunction{greater}{2}{% + \begingroup% + \ifdim#1pt>#2pt\relax% + \def\pgfmathresult{1}% + \else% + \def\pgfmathresult{0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} +\let\pgfmathgreaterthan=\pgfmathgreater + +\pgfmathdeclarefunction{less}{2}{% + \begingroup% + \ifdim#1pt<#2pt\relax% + \def\pgfmathresult{1}% + \else% + \def\pgfmathresult{0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} +\let\pgfmathlessthan=\pgfmathless + +\pgfmathdeclarefunction{equal}{2}{% + \begingroup% + \ifdim#1pt=#2pt\relax% + \def\pgfmathresult{1}% + \else% + \def\pgfmathresult{0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} +\let\pgfmathequalto=\pgfmathequal + + +% approxequalto function from Christian Feuersaenger. +% +\newif\ifpgfmathcomparison +\pgfmathdeclarefunction{approxequalto}{2}{% + \begingroup% + \pgfmath@x=#1pt\relax% + \pgfmath@y=#2pt\relax% + \advance\pgfmath@x by-\pgfmath@y% + \ifdim\pgfmath@x<0pt\relax% + \multiply\pgfmath@x by-1\relax% + \fi + \ifdim\pgfmath@x<0.0001pt\relax% + \def\pgfmathresult{1.0}% + \global\pgfmathcomparisontrue% + \else% + \def\pgfmathresult{0.0}% + \global\pgfmathcomparisonfalse% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + + + +% ifthenelse function. +% +\pgfmathdeclarefunction{ifthenelse}{3}{% + \begingroup% + \ifdim#1pt=0.0pt\relax% + \expandafter\def\expandafter\pgfmathresult\expandafter{#3}% + \else% + \expandafter\def\expandafter\pgfmathresult\expandafter{#2}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% notequal function. +% +\pgfmathdeclarefunction{notequal}{2}{% + \begingroup% + \ifdim#1pt=#2pt\relax% + \def\pgfmathresult{0}% + \else% + \def\pgfmathresult{1}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% notless function. +% +\pgfmathdeclarefunction{notless}{2}{% + \begingroup% + \ifdim#1pt<#2pt\relax% + \def\pgfmathresult{0}% + \else% + \def\pgfmathresult{1}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% notgreater function. +% +\pgfmathdeclarefunction{notgreater}{2}{% + \begingroup% + \ifdim#1pt>#2pt\relax% + \def\pgfmathresult{0}% + \else% + \def\pgfmathresult{1}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% and function. +% +\pgfmathdeclarefunction{and}{2}{% + \begingroup% + \def\pgfmathresult{1}% + \ifdim#1pt=0pt\relax% + \def\pgfmathresult{0}% + \else% + \ifdim#2pt=0pt\relax% + \def\pgfmathresult{0}% + \fi% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% or function. +% +\pgfmathdeclarefunction{or}{2}{% + \begingroup% + \def\pgfmathresult{0}% + \ifdim#1pt=0pt\relax% + \ifdim#2pt=0pt\relax% + \else% + \def\pgfmathresult{1}% + \fi% + \else% + \def\pgfmathresult{1}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% not function. +% +\pgfmathdeclarefunction{not}{1}{% + \begingroup% + \ifdim#1pt=0pt\relax% + \def\pgfmathresult{1}% + \else% + \def\pgfmathresult{0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% true function. +% +\pgfmathdeclarefunction{true}{0}{\def\pgfmathresult{1}} + +% false function. +% +\pgfmathdeclarefunction{false}{0}{\def\pgfmathresult{0}} diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.integerarithmetics.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.integerarithmetics.code.tex new file mode 100644 index 0000000000..ab8f4e6d3c --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.integerarithmetics.code.tex @@ -0,0 +1,124 @@ +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% Macros contributed by Alain Matthes and adapted by CJ +\pgfmathdeclarefunction{gcd}{2}{% + \begingroup + \pgfmathcontinuelooptrue + \pgfmath@xa=#1pt + \pgfmath@xb=#2pt + \ifdim\pgfmath@xa=0pt\relax + \pgfmathcontinueloopfalse + \pgfmath@xa=\pgfmath@xb + \fi + \ifdim\pgfmath@xb=0pt\relax + \pgfmathcontinueloopfalse + \pgfmath@xb=\pgfmath@xa + \fi + \ifdim\pgfmath@xa<0pt\relax + \pgfmath@xa=-\pgfmath@xa + \fi + \ifdim\pgfmath@xb<0pt\relax + \pgfmath@xb=-\pgfmath@xb + \fi + \loop + \ifpgfmathcontinueloop + \ifdim\pgfmath@xa=\pgfmath@xb + \pgfmathcontinueloopfalse + \else + \ifdim\pgfmath@xa>\pgfmath@xb + \advance\pgfmath@xa by-\pgfmath@xb + \else + \advance\pgfmath@xb by-\pgfmath@xa + \fi + \fi + \repeat + \pgfmathparse{int(\pgfmath@xa)}% + \pgfmath@smuggleone\pgfmathresult + \endgroup} + +\newif\ifpgfmath@isprime@unknown +\newif\ifpgfmath@isprime + +\pgfmathdeclarefunction{isprime}{1}{% + \begingroup + \pgfmath@isprime@unknowntrue + \pgfmathsetcount\c@pgfmath@counta{abs(int(#1))}% + \ifcase\c@pgfmath@counta\relax + % |#1| = 0 + \pgfmath@isprimefalse + \pgfmath@isprime@unknownfalse + \or + % |#1| = 1 + \pgfmath@isprimefalse + \pgfmath@isprime@unknownfalse + \or + % |#1| = 2 + \pgfmath@isprimetrue + \pgfmath@isprime@unknownfalse + \or + % |#1| = 3 + \pgfmath@isprimetrue + \pgfmath@isprime@unknownfalse + \else + % |#1| > 3 + \ifodd\c@pgfmath@counta\relax + \else + \pgfmath@isprimefalse + \pgfmath@isprime@unknownfalse + \fi + \fi + \ifpgfmath@isprime@unknown + \c@pgfmath@countd=3 + \pgfmath@isprimetrue + \pgfmathloop + \c@pgfmath@countb=\c@pgfmath@counta + \divide\c@pgfmath@countb by\c@pgfmath@countd + \ifnum\c@pgfmath@countb>\c@pgfmath@countd + \pgfmath@isprime@unknowntrue + \else + \pgfmath@isprime@unknownfalse + \fi + \multiply\c@pgfmath@countb by\c@pgfmath@countd + \ifnum\c@pgfmath@countb=\c@pgfmath@counta + \global\pgfmath@isprimefalse + \pgfmath@isprime@unknownfalse + \fi + \ifpgfmath@isprime@unknown\advance\c@pgfmath@countd by 2 + \repeatpgfmathloop + \fi + \ifpgfmath@isprime + \def\pgfmathresult{1}% + \else + \def\pgfmathresult{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup} + +\pgfmathdeclarefunction{isodd}{1}{% + \begingroup + \pgfmathsetcount\c@pgfmath@counta{abs(int(#1))}% + \ifodd\c@pgfmath@counta + \def\pgfmathresult{1}% + \else + \def\pgfmathresult{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup} + +\pgfmathdeclarefunction{iseven}{1}{% + \begingroup + \pgfmathsetcount\c@pgfmath@counta{abs(int(#1))}% + \ifodd\c@pgfmath@counta + \def\pgfmathresult{0}% + \else + \def\pgfmathresult{1}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup} + +\endinput diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.misc.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.misc.code.tex new file mode 100644 index 0000000000..859d8266a9 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.misc.code.tex @@ -0,0 +1,353 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file defines the mathematical functions and operators. +% +% Version 1.414213 29/9/2007 + +% veclen function adapted from ideas due to Rouben Rostamian. +% +% Calculate the Euclidean length of a 2D vector. +% +% +\pgfmathdeclarefunction{veclen}{2}{% + \begingroup% + \pgfmath@x#1pt\relax% + \pgfmath@y#2pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \ifdim\pgfmath@y<0pt\relax% + \pgfmath@y-\pgfmath@y% + \fi% + \ifdim\pgfmath@x=0pt\relax% + \pgfmath@x\pgfmath@y% + \else% + \ifdim\pgfmath@y=0pt\relax% + \else% + \ifdim\pgfmath@x>\pgfmath@y% + \pgfmath@xa\pgfmath@x% + \pgfmath@x\pgfmath@y% + \pgfmath@y\pgfmath@xa% + \fi% + % We use a scaling factor to reduce errors. + \ifdim\pgfmath@y>10000pt\relax% + \c@pgfmath@counta1500\relax% + \else% + \ifdim\pgfmath@y>1000pt\relax% + \c@pgfmath@counta150\relax% + \else% + \ifdim\pgfmath@y>100pt\relax% + \c@pgfmath@counta50\relax% + \else% + \c@pgfmath@counta1\relax% + \fi% + \fi% + \fi% + \divide\pgfmath@x\c@pgfmath@counta\relax% + \divide\pgfmath@y\c@pgfmath@counta\relax% + \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}% + \pgfmath@x\pgfmathresult\pgfmath@x% + \pgfmath@xa\pgfmath@tonumber{\pgfmath@x}\pgfmath@x% + \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@xa}}% + % + % Use A+x^2*(B+x^2*(C+x^2*(D+E*x^2))) + % where + % A = +1.000012594 + % B = +0.4993615349 + % C = -0.1195159052 + % D = +0.04453994279 + % E = -0.01019210944 + % + \pgfmath@x-0.01019210944\pgfmath@xa% + \advance\pgfmath@x0.04453994279pt\relax% + \pgfmath@x\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x-0.1195159052pt\relax% + \pgfmath@x\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x0.4993615349pt\relax% + \pgfmath@x\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x1.000012594pt\relax% + \ifdim\pgfmath@y<0pt\relax% + \pgfmath@y-\pgfmath@y% + \fi% + \pgfmath@x\pgfmath@tonumber{\pgfmath@y}\pgfmath@x% + % Invert the scaling factor. + \multiply\pgfmath@x\c@pgfmath@counta\relax% + \fi% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% Hyperbolic functions contributed by Martin Heller. +% +\pgfmathdeclarefunction{cosh}{1}{% + \begingroup + \edef\pgfmath@arg{#1}% + \pgfmathexp@{\pgfmath@arg}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmathexp@{-\pgfmath@arg}% + \advance\pgfmath@x by\pgfmathresult pt\relax% + \divide\pgfmath@x by2\relax% + \pgfmath@returnone\pgfmath@x% + \endgroup} + +\pgfmathdeclarefunction{sinh}{1}{% + \begingroup + \edef\pgfmath@arg{#1}% + \pgfmathexp@{\pgfmath@arg}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmathexp@{-\pgfmath@arg}% + \advance\pgfmath@x by-\pgfmathresult pt\relax% + \divide\pgfmath@x by2\relax% + \pgfmath@returnone\pgfmath@x% + \endgroup +}% + +\pgfmathdeclarefunction{tanh}{1}{% + \begingroup + \edef\pgfmath@arg{#1}% + \pgfmathsinh@{\pgfmath@arg}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmathcosh@{\pgfmath@arg}% + \pgfmath@y=\pgfmathresult pt\relax% + \pgfmathdivide@{\pgfmath@tonumber{\pgfmath@x}}{\pgfmath@tonumber{\pgfmath@y}}% + \pgfmath@x=\pgfmathresult pt\relax% + \pgfmath@returnone\pgfmath@x% + \endgroup +}% + +% \pgfmathscientific +% +% Return the value of #1e#2 +% +% e.g. \pgfmathscientific{1.23456789123}{4} +% +% defines \pgfmathresult as 12345.67891 +% +% NB These arguments *are not parsed*, as the long mantissa would be lost. +% +\def\pgfmathscientific#1#2{% + \begingroup% + \edef\pgfmath@sci@exponent{#2}% + \pgfmath@x#1pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \edef\pgfmath@sci@sign{-}% + \expandafter\edef\expandafter\pgfmath@temp\expandafter{\expandafter\pgfmath@gobbleone#1}% + \else% + \edef\pgfmath@sci@sign{+}% + \edef\pgfmath@temp{#1}% + \fi% + \expandafter\pgfmath@in@\expandafter.\expandafter{#1}% + \ifpgfmath@in@% + \else% + \edef\pgfmath@temp{\pgfmath@temp.0}% + \fi% + \expandafter\pgfmath@scientific@@\pgfmath@temp00000000000\pgfmath@} + +\def\pgfmath@scientific@@#1.#2#3#4#5#6{% + \edef\pgfmath@sci@int{#1}% + \edef\pgfmath@sci@mantissaA{#2#3#4#5#6}% + \pgfmath@scientific@@@} + +\def\pgfmath@scientific@@@#1#2#3#4#5#6\pgfmath@{% + \edef\pgfmath@sci@mantissaB{#1#2#3#4#5}% + \c@pgfmath@counta\pgfmath@sci@exponent\relax% + \ifnum\c@pgfmath@counta<-4\relax% + \pgfmath@x0pt\relax% + \else% + \c@pgfmath@countb\c@pgfmath@counta% + \ifnum\c@pgfmath@counta<0\relax% + \c@pgfmath@counta-\c@pgfmath@counta% + \fi% + \pgfmathpow@{10}{\the\c@pgfmath@counta}% + \afterassignment\pgfmath@gobbletilpgfmath@ + \c@pgfmath@countc\pgfmathresult\relax\pgfmath@ + \edef\pgfmath@sci@factor{\the\c@pgfmath@countc}% + \ifnum\c@pgfmath@countb<0\relax% + % xE-y: easy... + \pgfmath@x\pgfmath@sci@int.\pgfmath@sci@mantissaA pt\relax% + \divide\pgfmath@x\pgfmath@sci@factor\relax% + \else% + % xE+y: + % Must do this way so as not lose digits in a long mantissa. Sigh... + \c@pgfmath@counta\pgfmath@sci@int% + \c@pgfmath@countb\pgfmath@sci@mantissaA% + \multiply\c@pgfmath@counta\pgfmath@sci@factor\relax% + \multiply\c@pgfmath@countb\pgfmath@sci@factor\relax% + \c@pgfmath@countc\c@pgfmath@countb% + \divide\c@pgfmath@countb100000\relax% + \advance\c@pgfmath@counta\c@pgfmath@countb% + \multiply\c@pgfmath@countb100000\relax% + \advance\c@pgfmath@countc-\c@pgfmath@countb% + \c@pgfmath@countb\pgfmath@sci@mantissaB\relax% + \multiply\c@pgfmath@countb\pgfmath@sci@factor\relax% + \divide\c@pgfmath@countb100000\relax% + \advance\c@pgfmath@countc\c@pgfmath@countb% + \advance\c@pgfmath@countc100000\relax% + \edef\pgfmath@sci@result{\pgfmath@sci@sign\the\c@pgfmath@counta.\expandafter\pgfmath@gobbleone\the\c@pgfmath@countc pt}% + \pgfmath@x\pgfmath@sci@result\relax% + \fi\fi% + \pgfmath@returnone\pgfmath@x% + \endgroup} + + + +% width function. +% +\pgfmathdeclarefunction{width}{1}{% + \begingroup% + \setbox\pgfmath@box=\hbox{{\pgfmath@selectfont{#1}}}% + \pgfmath@x=\wd\pgfmath@box% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + + +% height function. +% +\pgfmathdeclarefunction{height}{1}{% + \begingroup% + \setbox\pgfmath@box=\hbox{{\pgfmath@selectfont{#1}}}% + \pgfmath@x=\ht\pgfmath@box% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% depth function. +% +\pgfmathdeclarefunction{depth}{1}{% + \begingroup% + \setbox\pgfmath@box=\hbox{{\pgfmath@selectfont{#1}}}% + \pgfmath@x=\dp\pgfmath@box% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + + +% array function. +% +\pgfmathdeclarefunction{array}{2}{% + \begingroup% + \afterassignment\pgfmath@gobbletilpgfmath@\pgfmath@count=#2\relax\pgfmath@% + \expandafter\pgfmatharray@@#1\pgfmath@stop% +} + +\def\pgfmath@token@stop{\pgfmath@stop}% +\def\pgfmatharray@@#1{% + \def\pgfmath@temp{#1}% + \advance\pgfmath@count by-1\relax% + \ifx\pgfmath@temp\pgfmath@token@stop% + \pgfmath@error{Array index out of bounds.}{}% + \def\pgfmathresult{0}% + \pgfmath@smuggleone\pgfmathresult\endgroup% + \let\pgfmath@next=\relax% + \else% + \ifnum\pgfmath@count=-1\relax% + \def\pgfmathresult{#1}% + \let\pgfmath@next=\pgfmatharray@@@% + \else% + \let\pgfmath@next=\pgfmatharray@@% + \fi% + \fi% + \pgfmath@next} + +\def\pgfmatharray@@@#1\pgfmath@stop{% + \pgfmath@smuggleone\pgfmathresult\endgroup% +} + +% dim function: return dimension of an array +% dim({1,2,3}) return 3 +% dim({{1,2,3},{4,5,6}}) return 2 +\pgfmathdeclarefunction{dim}{1}{% + \begingroup + \pgfmath@count=0\relax + \expandafter\pgfmath@dim@i\pgfutil@firstofone#1{\pgfmath@token@stop}% + \edef\pgfmathresult{\the\pgfmath@count}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup} + +\def\pgfmath@dim@i#1#{% + \pgfutil@ifempty{#1}{}{\advance\pgfmath@count by 1}% + \pgfmath@dim@ii{#1}} + +\def\pgfmath@dim@ii#1#2{% + \ifx\pgfmath@token@stop#2% + \else + \advance\pgfmath@count by 1\relax + \expandafter\pgfmath@dim@i + \fi} + + +% max function. +% +\pgfmathdeclarefunction{max}{...}{% + \begingroup% + \pgfmath@x=-16383pt\relax% + \pgfmathmax@@#1{}} + +\def\pgfmathmax@@#1{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \let\pgfmath@next=\pgfmathmax@@@% + \else% + \ifdim#1pt>\pgfmath@x% + \pgfmath@x=#1pt\relax% + \fi% + \let\pgfmath@next=\pgfmathmax@@% + \fi% + \pgfmath@next} + +\def\pgfmathmax@@@{\pgfmath@returnone\pgfmath@x\endgroup}% + +% For computability with old code. +\def\pgfmathmax#1#2{% + \pgfmathparse{#1,#2}% + \expandafter\pgfmathmax@\expandafter{\pgfmathresult}% +} + +% min function. +% +\pgfmathdeclarefunction{min}{...}{% + \begingroup% + \pgfmath@x=16383pt\relax% + \pgfmathmin@@#1{}} + +\def\pgfmathmin@@#1{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \let\pgfmath@next=\pgfmathmin@@@% + \else% + \ifdim#1pt<\pgfmath@x% + \pgfmath@x=#1pt\relax% + \fi% + \let\pgfmath@next=\pgfmathmin@@% + \fi% + \pgfmath@next} + +\def\pgfmathmin@@@{\pgfmath@returnone\pgfmath@x\endgroup}% + +% For computability with old code. +\def\pgfmathmin#1#2{% + \pgfmathparse{#1,#2}% + \expandafter\pgfmathmin@\expandafter{\pgfmathresult}% +} + + + +% scalar function. +% +\pgfmathdeclarefunction{scalar}{1}{% + \def\pgfmathresult{#1}% + \global\pgfmathunitsdeclaredfalse% +} diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.random.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.random.code.tex new file mode 100644 index 0000000000..969762c6c9 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.random.code.tex @@ -0,0 +1,246 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file defines the pseudorandom numbers. +% +% Version 1.414213 29/9/2007 + +% Pseudo-random number generation. +% +% See: +% \book@{pressetal1992, +% author = {William H. Press and Brian P. Flannery and Saul A. +% Teukolsky and William T. Vetterling}, +% title = {Numerical Recipies in C}, +% edition = {Second}, +% publisher = {Cambridge University Press} +% } +% +% See also, the documentation for the lcg package by Erich Janka: +% (http://www.ctan.org/tex-archive/macros/latex/contrib/lcg/lcg.pdf) +% +\def\pgfmath@rnd@m{2147483647}% LaTeX Maximum. + +\begingroup +\c@pgfmath@counta=\time% +\multiply\c@pgfmath@counta by\year% +\ifnum\c@pgfmath@counta=0 + \c@pgfmath@counta=1 +\fi +\xdef\pgfmath@rnd@z{\the\c@pgfmath@counta}% The seed. +\endgroup + +% \pgfmathsetseed +% +% Explicitly set the seed for the generator +% +% #1 -> the new seed. +% +\def\pgfmathsetseed#1{% + % Attention pgflibraryluamath.code.tex relies on the fact that + % this method also modifies \pgfmathresult: + \pgfmathparse{#1}\expandafter\pgfmath@setseed\pgfmathresult.0\pgfmath@stop +}% +\def\pgfmath@setseed#1.#2\pgfmath@stop{\def\pgfmath@rnd@z{#1}}% + +% Alternative parameters - see Press et al (1992) p278-279, +% for discussion. +% +% a=16807 q=127773 r=2836 +% a=48271 q=4488 r=3399 +% +\def\pgfmath@rnd@a{69621} +\def\pgfmath@rnd@r{23902} +\def\pgfmath@rnd@q{30845} + +% \pgfmathgeneratepseudorandomnumber +% +% A linear congruency generator for generating +% pseudo-random numbers. Generates numbers in +% the range 1 - 2^31-1. +% +\def\pgfmathgeneratepseudorandomnumber{% + \begingroup% + \c@pgfmath@counta=\pgfmath@rnd@z% + \c@pgfmath@countb=\pgfmath@rnd@z% + \c@pgfmath@countc=\pgfmath@rnd@q% + \divide\c@pgfmath@counta by\c@pgfmath@countc% + \multiply\c@pgfmath@counta by-\c@pgfmath@countc% + \advance\c@pgfmath@counta by\c@pgfmath@countb + \c@pgfmath@countc=\pgfmath@rnd@a% + \multiply\c@pgfmath@counta by\c@pgfmath@countc% + \c@pgfmath@countc=\pgfmath@rnd@q% + \divide\c@pgfmath@countb by\c@pgfmath@countc% + \c@pgfmath@countc=\pgfmath@rnd@r% + \multiply\c@pgfmath@countb by\c@pgfmath@countc% + \advance\c@pgfmath@counta by-\c@pgfmath@countb% + \ifnum\c@pgfmath@counta<0\relax% + \c@pgfmath@countb=\pgfmath@rnd@m% + \advance\c@pgfmath@counta by\c@pgfmath@countb% + \fi% + \xdef\pgfmath@rnd@z{\the\c@pgfmath@counta}% + \endgroup% + \edef\pgfmathresult{\pgfmath@rnd@z}% +} + +% \pgfmathrnd +% +% Generates a pseudo-random number between 0 and 1. +% +\pgfmathdeclarefunction{rnd}{0}{% + \begingroup% + \pgfmathgeneratepseudorandomnumber% + \c@pgfmath@counta\pgfmathresult% + \c@pgfmath@countb\c@pgfmath@counta% + \divide\c@pgfmath@countb100001\relax% To get one. + \multiply\c@pgfmath@countb-100001\relax% + \advance\c@pgfmath@countb\c@pgfmath@counta% + \advance\c@pgfmath@countb1000000\relax% + \expandafter\pgfmathrnd@@\the\c@pgfmath@countb\pgfmath@% + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +\def\pgfmathrnd@@#1#2#3\pgfmath@{% + \edef\pgfmath@temp{#2.#3}% + \pgfmath@x=\pgfmath@temp pt\relax% +}% + +% \pgfmathrand +% +% Generates a pseudo-random number between -1 and 1. +% +\pgfmathdeclarefunction{rand}{0}{% + \begingroup% + \pgfmathgeneratepseudorandomnumber% + \c@pgfmath@counta\pgfmathresult% + \c@pgfmath@countb\c@pgfmath@counta% + \divide\c@pgfmath@countb200001\relax% + \multiply\c@pgfmath@countb-200001\relax% + \advance\c@pgfmath@countb\c@pgfmath@counta% + \advance\c@pgfmath@countb-100000\relax% + \ifnum\c@pgfmath@countb<0\relax% + \advance\c@pgfmath@countb-1000000\relax% + \else% + \advance\c@pgfmath@countb1000000\relax% + \fi% + \expandafter\pgfmathrand@@\the\c@pgfmath@countb\pgfmath@% + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +\def\pgfmathrand@@#1#2#3#4\pgfmath@{% + \ifx#1-% + \edef\pgfmath@temp{-#3.#4}% + \else% + \edef\pgfmath@temp{#2.#3#4}% + \fi% + \pgfmath@x=\pgfmath@temp pt\relax% +}% + +\pgfmathdeclarefunction{random}{...}{% + \begingroup% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \pgfmathrnd@% + \else% + \expandafter\pgfmathrandom@@#1\pgfmath@stop% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup} + +\def\pgfmathrandom@@{\futurelet\pgfmath@token\pgfmathrandom@@@} +\def\pgfmathrandom@@@{% + \ifx\pgfmath@token\bgroup% + \expandafter\pgfmath@random@@@@% + \else% + \expandafter\pgfmath@random@@@@@% + \fi% +} +\def\pgfmath@random@@@@@#1\pgfmath@stop{% + \pgfmathrandominteger\pgfmathresult{1}{#1}% +} +\def\pgfmath@random@@@@#1#2\pgfmath@stop{% + \pgfmathrandominteger\pgfmathresult{#1}{#2}% +} + +% \pgfmathrandominteger +% +% Return a 'randomly' selected integer in the range #2 - #3 (inclusive). +% +% #1 - a macro to store the integer (not a count register). +% #2 - the lower limit of the range. +% #3 - the upper limit of the range. +% +\def\pgfmathrandominteger#1#2#3{% + \begingroup% + \pgfmathsetcount\c@pgfmath@counta{#2}% + \pgfmathsetcount\c@pgfmath@countb{#3}% + \c@pgfmath@countc\c@pgfmath@countb% + % OK. Maybe #2 > #3. + \ifnum\c@pgfmath@counta>\c@pgfmath@countb\relax% + \c@pgfmath@countc\c@pgfmath@counta% + \c@pgfmath@counta\c@pgfmath@countb% + \c@pgfmath@countb\c@pgfmath@countc% + \fi% + \c@pgfmath@countd\c@pgfmath@counta + \advance\c@pgfmath@countc1\relax% + \advance\c@pgfmath@countc-\c@pgfmath@counta% + \pgfmathgeneratepseudorandomnumber% + \c@pgfmath@counta\pgfmathresult\relax% + \c@pgfmath@countb\c@pgfmath@counta% + \divide\c@pgfmath@countb\c@pgfmath@countc% + \multiply\c@pgfmath@countb-\c@pgfmath@countc% + \advance\c@pgfmath@counta\c@pgfmath@countb% + \advance\c@pgfmath@counta\c@pgfmath@countd + \edef\pgfmathresult{\the\c@pgfmath@counta}% + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup% + \edef#1{\pgfmathresult}% +} + +% \pgfmathdeclarerandomlist +% +% Create a list to be used with \pgfmathrandomelement. +% +% #1 - the name of the list +% #2 - a list of elements (e.g., {item-1}{item-2}...{item-n}). +% +\def\pgfmathdeclarerandomlist#1#2{% + \def\pgfmath@randomlistname{#1}% + \begingroup% + \c@pgfmath@counta=1\relax% + % {} is a possible random element so (locally) + % redefine \pgfmath@empty. + \def\pgfmath@empty{pgfmath@empty}% + \expandafter\pgfmath@scanrandomlist#2{pgfmath@empty}} +\def\pgfmath@scanrandomlist#1{% + \def\pgfmath@scanneditem{#1}% + \ifx\pgfmath@scanneditem\pgfmath@empty% + \advance\c@pgfmath@counta-1\relax% + \expandafter\xdef\csname pgfmath@randomlist@\pgfmath@randomlistname\endcsname{\the\c@pgfmath@counta}% + \endgroup% + \else% + \expandafter\gdef\csname pgfmath@randomlist@\pgfmath@randomlistname @\the\c@pgfmath@counta\endcsname{#1}% + \advance\c@pgfmath@counta1\relax% + \expandafter\pgfmath@scanrandomlist% + \fi} + +% \pgfmathrandomitem +% +% Return a 'randomly' selected element from a list. +% +% #1 - a macro to store the item. +% #2 - the name of the list. +% +\def\pgfmathrandomitem#1#2{% + \pgfmath@ifundefined{pgfmath@randomlist@#2}{\pgfmath@error{Unknown random list `#2'}{}}{% + \edef\pgfmath@randomlistlength{\csname pgfmath@randomlist@#2\endcsname}% + \pgfmathrandominteger{\pgfmath@randomtemp}{1}{\pgfmath@randomlistlength}% + \expandafter\def\expandafter#1\expandafter{\csname pgfmath@randomlist@#2@\pgfmath@randomtemp\endcsname}}} diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.round.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.round.code.tex new file mode 100644 index 0000000000..120e971c8c --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.round.code.tex @@ -0,0 +1,123 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file defines the mathematical functions and operators. +% +% Version 1.414213 29/9/2007 + +% round function. Uses asymmetric half-up rounding. +% +\pgfmathdeclarefunction{round}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \afterassignment\pgfmath@xa% + \expandafter\c@pgfmath@counta\the\pgfmath@x\relax% + \pgfmath@xb\pgfmath@x% + \ifdim\pgfmath@xb<0pt\relax% + \ifdim\pgfmath@xa<0.5pt\relax% + \else% + \advance\c@pgfmath@counta-1\relax% + \fi% + \else% + \ifdim\pgfmath@xa<0.5pt\relax% + \else% + \advance\c@pgfmath@counta1\relax% + \fi% + \fi% + \pgfmath@returnone\the\c@pgfmath@counta pt% + \endgroup% +}% + +% floor function. +% +\pgfmathdeclarefunction{floor}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \afterassignment\pgfmathfloor@collect@remainder% + \expandafter\c@pgfmath@counta\the\pgfmath@x\pgfmath@% + \expandafter\pgfmath@x#1pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \ifdim\pgfmathfloor@remainder>0pt + \advance\c@pgfmath@counta by -1\relax% + \else + % ok, we stripped only '0'. + \fi + \fi% + \pgfmath@x\c@pgfmath@counta pt\relax% + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +\def\pgfmathfloor@collect@remainder#1\pgfmath@{% + \def\pgfmathfloor@remainder{#1}% + \ifx\pgfmathfloor@remainder\pgfutil@empty + \def\pgfmathfloor@remainder{0}% + \fi +}% + +% ceil function. +% +\pgfmathdeclarefunction{ceil}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \afterassignment\pgfmath@gobbletilpgfmath@% + \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@% + \pgfmath@y\pgfmath@x% + \advance\pgfmath@y-\c@pgfmath@counta pt\relax% + \pgfmath@x\c@pgfmath@counta pt\relax% + \ifdim\pgfmath@y>0pt\relax% + \advance\pgfmath@x1pt\relax% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +% int function +% +\pgfmathdeclarefunction{int}{1}{% + \begingroup% + \expandafter\pgfmathint@@#1.\pgfmath@stop + \pgfmath@smuggleone\pgfmathresult% + \endgroup} + +\def\pgfmathint@@#1.#2\pgfmath@stop{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \def\pgfmathresult{0}% + \else% + \pgfmath@in@{#1}{+-+0-0}% + \ifpgfmath@in@ + \def\pgfmathresult{0}% + \else% + \def\pgfmathresult{#1}% + \fi% + \fi} + +% frac function. +% +\pgfmathdeclarefunction{frac}{1}{% + \begingroup% + \expandafter\pgfmathfrac@@#1.\pgfmath@stop% + \pgfmath@smuggleone\pgfmathresult% + \endgroup} + +\def\pgfmathfrac@@#1.{% + \pgfmath@ifnextchar\pgfmath@stop{\def\pgfmathresult{0.0}\pgfmath@gobbleone}{\pgfmathfrac@@@}% +} +\def\pgfmathfrac@@@#1.\pgfmath@stop{\def\pgfmathresult{0.#1}} + +% real function. +% +\pgfmathdeclarefunction{real}{1}{% + \begingroup% + \pgfmath@x=#1pt\relax% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} diff --git a/graphics/pgf/base/tex/generic/math/pgfmathfunctions.trigonometric.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.trigonometric.code.tex new file mode 100644 index 0000000000..b76c5b440c --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathfunctions.trigonometric.code.tex @@ -0,0 +1,1571 @@ +% Copyright 2019 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% This file defines the trigonometric functions/functions. +% +% Much of this file is based on ideas and code (particularly +% the old \pgfcoremath.code.tex) due to Till Tantau. +% +% Version 1.414213 29/9/2007 + +% \pgfmathpi +% +\pgfmathdeclarefunction{pi}{0}{\def\pgfmathresult{3.141592654}} + +\pgfkeys{ + /pgf/trig format/.is choice, + % attention: the luamath library will hook into these code keys. + /pgf/trig format/deg/.code={\def\pgfmath@trig@format@choice{0}}, + /pgf/trig format/rad/.code={\def\pgfmath@trig@format@choice{1}}, + /pgf/trig format/deg, +} + +% Executes #1 if 'trig format=deg' and #2 otherwise. +\def\pgfmathiftrigonometricusesdeg#1#2{% + \if0\pgfmath@trig@format@choice + #1% + \else + #2% + \fi +}% + +% \pgfmathradians +% (for compatibility with 1.18 beta, will be deprecated) +% +% Convert #1 from radians to degrees (accurate to 1 deg). +% +\pgfmathdeclarefunction{radians}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \pgfmath@x57.29577\pgfmath@x\relax% 57.29577 = 360/(2*pi) + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +% \pgfmathdeg +% +% Convert #1 from radians to degrees. +% +\pgfmathdeclarefunction{deg}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \pgfmath@scale@rad@to@deg\pgfmath@x + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +\def\pgfmath@scale@rad@to@deg#1{% + #1=57.29577#1\relax% 57.29577 = 360/(2*pi) +}% + +% \pgfmathrad +% +% Convert #1 from degrees to radians. +% +\pgfmathdeclarefunction{rad}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \pgfmath@scale@deg@to@rad\pgfmath@x + \pgfmath@returnone\pgfmath@x% + \endgroup% +}% + +\def\pgfmath@scale@deg@to@rad#1{% + #1=3.14159#1% + \divide#1180\relax% +}% + +% \pgfmathsin +% +% Calculate the sine of #1 (in degrees). +% +\pgfmathdeclarefunction{sin}{1}{% + % Let #1 = a.b + % Then sin(#1) \approx (1-b)*sin(a) + b*sin(a+1) + % + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \if1\pgfmath@trig@format@choice + % trig format=rad + \pgfmath@scale@rad@to@deg\pgfmath@x + \fi + \advance\pgfmath@x-90pt\relax% + \afterassignment\pgfmath@gobbletilpgfmath@ + \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@ + \divide\c@pgfmath@counta360\relax% + \multiply\c@pgfmath@counta-360\relax% + \advance\pgfmath@x\c@pgfmath@counta pt\relax% + \ifdim\pgfmath@x<0pt\relax\pgfmath@x-\pgfmath@x\fi% + \ifdim\pgfmath@x<180pt\relax% + \else + \pgfmath@x-\pgfmath@x% + \advance\pgfmath@x360pt\relax% + \fi% + % Now 0 <= x < 179. So split x into integer and decimal... + % + \afterassignment\pgfmath@xa% + \expandafter\c@pgfmath@counta\the\pgfmath@x\relax% + % + % ...if #1 is an integer, don't do anything fancy. + \ifdim\pgfmath@xa=0pt% + \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname pt\relax% + \else% + \pgfmath@x-\pgfmath@xa% + \advance\pgfmath@x1pt\relax% + \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@x% + \advance\c@pgfmath@counta1\relax% + \ifnum\c@pgfmath@counta=181\relax\c@pgfmath@counta179\relax\fi% + \expandafter\advance\expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@xa% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup +} + +% \pgfmathcos +% +% Calculate the cosine of #1 (in degrees). +% +\pgfmathdeclarefunction{cos}{1}{% + % Let x = a.b + % Then cos(x) \approx (1-b)*cos(a) + b*cos(a+1) + % + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \if1\pgfmath@trig@format@choice + % trig format=rad + \pgfmath@scale@rad@to@deg\pgfmath@x + \fi + \afterassignment\pgfmath@gobbletilpgfmath@% + \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@% + \divide\c@pgfmath@counta360\relax% + \multiply\c@pgfmath@counta-360\relax% + \advance\pgfmath@x\c@pgfmath@counta pt\relax% + \ifdim\pgfmath@x<0pt\relax\pgfmath@x-\pgfmath@x\fi% + \ifdim\pgfmath@x<180pt\relax% + \else% + \pgfmath@x-\pgfmath@x% + \advance\pgfmath@x360pt\relax% + \fi% + % Now 0 <= x < 179. So split x into integer and decimal... + % + \afterassignment\pgfmath@xa% + \expandafter\c@pgfmath@counta\the\pgfmath@x\relax% + % + % ...if #1 is an integer, don't do anything fancy. + \ifdim\pgfmath@xa=0pt% + \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname pt% + \else% + \pgfmath@x-\pgfmath@xa% + \advance\pgfmath@x1pt\relax% + \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@x% + \advance\c@pgfmath@counta1\relax% + \ifnum\c@pgfmath@counta=181\relax\c@pgfmath@counta179\relax\fi% + \expandafter\advance\expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@xa% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% \pgfmathsincos +% +% Calculate the sin and cosine of #1 (in degrees). +% +\def\pgfmathsincos#1{% + \pgfmathparse{#1}% + \expandafter\pgfmathsincos@\expandafter{\pgfmathresult}} +\def\pgfmathsincos@#1{% + \edef\pgfmath@temparg{#1}% + \pgfmathsin@{\pgfmath@temparg}\edef\pgfmathresulty{\pgfmathresult}% + \pgfmathcos@{\pgfmath@temparg}\edef\pgfmathresultx{\pgfmathresult}% +} + +% \pgfmathtan +% +% Calculate the tangent of #1 (in degrees). +% +\pgfmathdeclarefunction{tan}{1}{% + \begingroup% + \edef\pgfmath@temparg{#1}% + \pgfmathcos@{\pgfmath@temparg}% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \edef\pgfmath@tantemp{\pgfmathresult}% + \pgfmathsin@{\pgfmath@temparg}% + \pgfmath@x\pgfmathresult pt\relax% + \pgfmath@x\pgfmath@tantemp\pgfmath@x% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% \pgfmathcosec +% +% Calculate the cosec of #1 (in degrees). +% +\pgfmathdeclarefunction{cosec}{1}{% + \expandafter\pgfmathsin@\expandafter{#1}% + \pgfmathreciprocal@{\pgfmathresult}% +} + +% \pgfmathsec +% +% Calculate the sec of #1 (in degrees). +% +\pgfmathdeclarefunction{sec}{1}{% + \expandafter\pgfmathcos@\expandafter{#1}% + \pgfmathreciprocal@{\pgfmathresult}% +} + +% \pgfmathcot +% +% Calculate the cotangent of #1 (in degrees). +% +\pgfmathdeclarefunction{cot}{1}{% + \begingroup% + \edef\pgfmath@temparg{#1}% + \pgfmathsin@{\pgfmath@temparg}% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \edef\pgfmath@tantemp{\pgfmathresult}% + \pgfmathcos@{\pgfmath@temparg}% + \pgfmath@x\pgfmathresult pt\relax% + \pgfmath@x\pgfmath@tantemp\pgfmath@x% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +\def\pgfmath@multiply@thousand#1.#2#3#4#5\relax{% + \edef\pgfmathresult{#1#2#3#4.#5}% +}% + +% \pgfmathasin +% +% The asin of #1 +% +\pgfmathdeclarefunction{asin}{1}{% + \begingroup% + \pgfmath@x=#1pt % + \pgfmath@xa\pgfmath@x% + \edef\pgf@temp{\pgfmath@tonumber\pgfmath@x}% + % compute lossless '*1000' operation: + \expandafter\pgfmath@multiply@thousand\pgf@temp 000\relax + \pgfmath@x=\pgfmathresult pt % + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \pgfmath@table@lookup{\pgfmath@x}{pgfmath@acos@}{1001}% + \pgfmath@x=-\pgfmath@x + \advance\pgfmath@x90pt\relax% + \ifdim\pgfmath@xa<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \if1\pgfmath@trig@format@choice + % trig format=rad + \pgfmath@scale@deg@to@rad\pgfmath@x + \fi + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% Defines \pgfmath@x to be the result of the table lookup for value +% '#1' in table '#2' +% +% #1: a value for which lookup should be performed +% #2: the table's prefix name +% #3: the table's size +\def\pgfmath@table@lookup#1#2#3{% + \pgfmath@x=#1\relax + \expandafter\pgfmath@table@lookup@\the\pgfmath@x\relax{#2}{#3}% +} +\def\pgfmath@table@lookup@#1.#2\relax#3#4{% + \edef\pgf@temp{\Pgf@geT#2}% strip 'pt' suffix. + % + % prepare constant interpolant (i.e. the value at node '#1'): + \pgfmath@x=\csname #3#1\endcsname pt % + % + \c@pgfmath@countc=#1 % + \advance\c@pgfmath@countc by1 % + \ifnum\c@pgfmath@countc<#4 % + % Ah - we have enough elements in the table. + % + % perform linear interpolation: + \pgfmath@ya=\csname #3\the\c@pgfmath@countc\endcsname pt % + \advance\pgfmath@ya by-\pgfmath@x % + \advance\pgfmath@x by0.\pgf@temp\pgfmath@ya + \fi +}% + +% \pgfmathacos +% +% The acos of #1 +% +\pgfmathdeclarefunction{acos}{1}{% + \begingroup% + \pgfmath@x#1pt\relax% + \pgfmath@xa\pgfmath@x% + \edef\pgf@temp{\pgfmath@tonumber\pgfmath@x}% + % compute lossless '*1000' operation: + \expandafter\pgfmath@multiply@thousand\pgf@temp 000\relax + \pgfmath@x=\pgfmathresult pt % + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \pgfmath@table@lookup{\pgfmath@x}{pgfmath@acos@}{1001}% + \ifdim\pgfmath@xa<0pt\relax% + \pgfmath@x-\pgfmath@x% + \advance\pgfmath@x by180pt\relax% + \fi% + \if1\pgfmath@trig@format@choice + % trig format=rad + \pgfmath@scale@deg@to@rad\pgfmath@x + \fi + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +\pgfmathdeclarefunction{atan}{1}{% + \begingroup% + \expandafter\pgfmath@x#1pt\relax% + \pgfmath@xa\pgfmath@x% + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \pgfmath@xb\pgfmath@x% + \ifdim\pgfmath@x>1pt\relax% + \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@x}}% + \pgfmathreciprocal@{\pgfmath@temp}% + \pgfmath@x\pgfmathresult pt\relax% + \fi% + % compute lossless '*1000' operation: + \edef\pgf@temp{\pgfmath@tonumber\pgfmath@x}% + \expandafter\pgfmath@multiply@thousand\pgf@temp 000\relax + \pgfmath@x=\pgfmathresult pt % + \pgfmath@table@lookup{\pgfmath@x}{pgfmath@atan@}{1001}%xxx + \ifdim\pgfmath@xb>1pt\relax% + \pgfmath@x=-\pgfmath@x% + \advance\pgfmath@x90pt% + \fi% + \ifdim\pgfmath@xa<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \if1\pgfmath@trig@format@choice + % trig format=rad + \pgfmath@scale@deg@to@rad\pgfmath@x + \fi + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +\pgfmathdeclarefunction{atan2}{2}{% + % Note: first parameter is y (!), second is x (!) + \begingroup% + \let\pgfmath@trig@format@choice@@=\pgfmath@trig@format@choice + \def\pgfmath@trig@format@choice{0}% + \pgfmath@y=#1pt\relax% + \ifdim\pgfmath@y<0pt\relax% + \pgfmath@y=-\pgfmath@y% + \fi% + \ifdim\pgfmath@y<0.001pt\relax% + \ifdim#2pt<0pt\relax% + \pgfmath@x=+180pt\relax% + \else% + \ifdim#2pt>0pt\relax% + \pgfmath@x=0pt\relax% + \else% + \ifdim#1pt<0pt% + \pgfmath@x=-90pt\relax% + \else% + \pgfmath@x=90pt\relax% + \fi% + \fi% + \fi% + \else% + \pgfmathabs@{#1}\let\pgfmath@tempa\pgfmathresult% + \pgfmathabs@{#2}\let\pgfmath@tempb\pgfmathresult% + \ifdim\pgfmath@tempa pt>\pgfmath@tempb pt% + \pgfmathdivide@{#2}{\pgfmath@tempa}% + \expandafter\pgfmathatan@\expandafter{\pgfmathresult}% + \pgfmath@x=90pt% + \advance\pgfmath@x by-\pgfmathresult pt\relax% + \else% + \pgfmathdivide@{\pgfmath@tempa}{#2}% + \expandafter\pgfmathatan@\expandafter{\pgfmathresult}% + \pgfmath@x=\pgfmathresult pt\relax% + \ifdim#2pt<0pt% + \advance\pgfmath@x by180pt\relax% + \fi% + \fi% + \ifdim#1pt<0pt\relax% + \pgfmath@x=-\pgfmath@x% + \fi% + \fi% + \if1\pgfmath@trig@format@choice@@ + % trig format=rad + \pgfmath@scale@deg@to@rad\pgfmath@x + \fi + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +% This is needed since \pgfmathatan2 is not a legal macro name +\expandafter\let\expandafter\pgfmathatantwo\csname pgfmathatan2\endcsname +\expandafter\let\expandafter\pgfmathatantwo@\csname pgfmathatan2@\endcsname + +\def\pgfmath@def#1#2#3{\expandafter\def\csname pgfmath@#1@#2\endcsname{#3}} +\pgfmath@def{cos}{0}{1.00000} \pgfmath@def{cos}{1}{0.99985} +\pgfmath@def{cos}{2}{0.99939} \pgfmath@def{cos}{3}{0.99863} +\pgfmath@def{cos}{4}{0.99756} \pgfmath@def{cos}{5}{0.99619} +\pgfmath@def{cos}{6}{0.99452} \pgfmath@def{cos}{7}{0.99255} +\pgfmath@def{cos}{8}{0.99027} \pgfmath@def{cos}{9}{0.98769} +\pgfmath@def{cos}{10}{0.98481} \pgfmath@def{cos}{11}{0.98163} +\pgfmath@def{cos}{12}{0.97815} \pgfmath@def{cos}{13}{0.97437} +\pgfmath@def{cos}{14}{0.97030} \pgfmath@def{cos}{15}{0.96593} +\pgfmath@def{cos}{16}{0.96126} \pgfmath@def{cos}{17}{0.95630} +\pgfmath@def{cos}{18}{0.95106} \pgfmath@def{cos}{19}{0.94552} +\pgfmath@def{cos}{20}{0.93969} \pgfmath@def{cos}{21}{0.93358} +\pgfmath@def{cos}{22}{0.92718} \pgfmath@def{cos}{23}{0.92050} +\pgfmath@def{cos}{24}{0.91355} \pgfmath@def{cos}{25}{0.90631} +\pgfmath@def{cos}{26}{0.89879} \pgfmath@def{cos}{27}{0.89101} +\pgfmath@def{cos}{28}{0.88295} \pgfmath@def{cos}{29}{0.87462} +\pgfmath@def{cos}{30}{0.86603} \pgfmath@def{cos}{31}{0.85717} +\pgfmath@def{cos}{32}{0.84805} \pgfmath@def{cos}{33}{0.83867} +\pgfmath@def{cos}{34}{0.82904} \pgfmath@def{cos}{35}{0.81915} +\pgfmath@def{cos}{36}{0.80902} \pgfmath@def{cos}{37}{0.79864} +\pgfmath@def{cos}{38}{0.78801} \pgfmath@def{cos}{39}{0.77715} +\pgfmath@def{cos}{40}{0.76604} \pgfmath@def{cos}{41}{0.75471} +\pgfmath@def{cos}{42}{0.74314} \pgfmath@def{cos}{43}{0.73135} +\pgfmath@def{cos}{44}{0.71934} \pgfmath@def{cos}{45}{0.70711} +\pgfmath@def{cos}{46}{0.69466} \pgfmath@def{cos}{47}{0.68200} +\pgfmath@def{cos}{48}{0.66913} \pgfmath@def{cos}{49}{0.65606} +\pgfmath@def{cos}{50}{0.64279} \pgfmath@def{cos}{51}{0.62932} +\pgfmath@def{cos}{52}{0.61566} \pgfmath@def{cos}{53}{0.60182} +\pgfmath@def{cos}{54}{0.58779} \pgfmath@def{cos}{55}{0.57358} +\pgfmath@def{cos}{56}{0.55919} \pgfmath@def{cos}{57}{0.54464} +\pgfmath@def{cos}{58}{0.52992} \pgfmath@def{cos}{59}{0.51504} +\pgfmath@def{cos}{60}{0.50000} \pgfmath@def{cos}{61}{0.48481} +\pgfmath@def{cos}{62}{0.46947} \pgfmath@def{cos}{63}{0.45399} +\pgfmath@def{cos}{64}{0.43837} \pgfmath@def{cos}{65}{0.42262} +\pgfmath@def{cos}{66}{0.40674} \pgfmath@def{cos}{67}{0.39073} +\pgfmath@def{cos}{68}{0.37461} \pgfmath@def{cos}{69}{0.35837} +\pgfmath@def{cos}{70}{0.34202} \pgfmath@def{cos}{71}{0.32557} +\pgfmath@def{cos}{72}{0.30902} \pgfmath@def{cos}{73}{0.29237} +\pgfmath@def{cos}{74}{0.27564} \pgfmath@def{cos}{75}{0.25882} +\pgfmath@def{cos}{76}{0.24192} \pgfmath@def{cos}{77}{0.22495} +\pgfmath@def{cos}{78}{0.20791} \pgfmath@def{cos}{79}{0.19081} +\pgfmath@def{cos}{80}{0.17365} \pgfmath@def{cos}{81}{0.15643} +\pgfmath@def{cos}{82}{0.13917} \pgfmath@def{cos}{83}{0.12187} +\pgfmath@def{cos}{84}{0.10453} \pgfmath@def{cos}{85}{0.08716} +\pgfmath@def{cos}{86}{0.06976} \pgfmath@def{cos}{87}{0.05234} +\pgfmath@def{cos}{88}{0.03490} \pgfmath@def{cos}{89}{0.01745} +\pgfmath@def{cos}{90}{0.00000} \pgfmath@def{cos}{91}{-0.01745} +\pgfmath@def{cos}{92}{-0.03490} \pgfmath@def{cos}{93}{-0.05234} +\pgfmath@def{cos}{94}{-0.06976} \pgfmath@def{cos}{95}{-0.08716} +\pgfmath@def{cos}{96}{-0.10453} \pgfmath@def{cos}{97}{-0.12187} +\pgfmath@def{cos}{98}{-0.13917} \pgfmath@def{cos}{99}{-0.15643} +\pgfmath@def{cos}{100}{-0.17365} \pgfmath@def{cos}{101}{-0.19081} +\pgfmath@def{cos}{102}{-0.20791} \pgfmath@def{cos}{103}{-0.22495} +\pgfmath@def{cos}{104}{-0.24192} \pgfmath@def{cos}{105}{-0.25882} +\pgfmath@def{cos}{106}{-0.27564} \pgfmath@def{cos}{107}{-0.29237} +\pgfmath@def{cos}{108}{-0.30902} \pgfmath@def{cos}{109}{-0.32557} +\pgfmath@def{cos}{110}{-0.34202} \pgfmath@def{cos}{111}{-0.35837} +\pgfmath@def{cos}{112}{-0.37461} \pgfmath@def{cos}{113}{-0.39073} +\pgfmath@def{cos}{114}{-0.40674} \pgfmath@def{cos}{115}{-0.42262} +\pgfmath@def{cos}{116}{-0.43837} \pgfmath@def{cos}{117}{-0.45399} +\pgfmath@def{cos}{118}{-0.46947} \pgfmath@def{cos}{119}{-0.48481} +\pgfmath@def{cos}{120}{-0.50000} \pgfmath@def{cos}{121}{-0.51504} +\pgfmath@def{cos}{122}{-0.52992} \pgfmath@def{cos}{123}{-0.54464} +\pgfmath@def{cos}{124}{-0.55919} \pgfmath@def{cos}{125}{-0.57358} +\pgfmath@def{cos}{126}{-0.58779} \pgfmath@def{cos}{127}{-0.60182} +\pgfmath@def{cos}{128}{-0.61566} \pgfmath@def{cos}{129}{-0.62932} +\pgfmath@def{cos}{130}{-0.64279} \pgfmath@def{cos}{131}{-0.65606} +\pgfmath@def{cos}{132}{-0.66913} \pgfmath@def{cos}{133}{-0.68200} +\pgfmath@def{cos}{134}{-0.69466} \pgfmath@def{cos}{135}{-0.70711} +\pgfmath@def{cos}{136}{-0.71934} \pgfmath@def{cos}{137}{-0.73135} +\pgfmath@def{cos}{138}{-0.74314} \pgfmath@def{cos}{139}{-0.75471} +\pgfmath@def{cos}{140}{-0.76604} \pgfmath@def{cos}{141}{-0.77715} +\pgfmath@def{cos}{142}{-0.78801} \pgfmath@def{cos}{143}{-0.79864} +\pgfmath@def{cos}{144}{-0.80902} \pgfmath@def{cos}{145}{-0.81915} +\pgfmath@def{cos}{146}{-0.82904} \pgfmath@def{cos}{147}{-0.83867} +\pgfmath@def{cos}{148}{-0.84805} \pgfmath@def{cos}{149}{-0.85717} +\pgfmath@def{cos}{150}{-0.86603} \pgfmath@def{cos}{151}{-0.87462} +\pgfmath@def{cos}{152}{-0.88295} \pgfmath@def{cos}{153}{-0.89101} +\pgfmath@def{cos}{154}{-0.89879} \pgfmath@def{cos}{155}{-0.90631} +\pgfmath@def{cos}{156}{-0.91355} \pgfmath@def{cos}{157}{-0.92050} +\pgfmath@def{cos}{158}{-0.92718} \pgfmath@def{cos}{159}{-0.93358} +\pgfmath@def{cos}{160}{-0.93969} \pgfmath@def{cos}{161}{-0.94552} +\pgfmath@def{cos}{162}{-0.95106} \pgfmath@def{cos}{163}{-0.95630} +\pgfmath@def{cos}{164}{-0.96126} \pgfmath@def{cos}{165}{-0.96593} +\pgfmath@def{cos}{166}{-0.97030} \pgfmath@def{cos}{167}{-0.97437} +\pgfmath@def{cos}{168}{-0.97815} \pgfmath@def{cos}{169}{-0.98163} +\pgfmath@def{cos}{170}{-0.98481} \pgfmath@def{cos}{171}{-0.98769} +\pgfmath@def{cos}{172}{-0.99027} \pgfmath@def{cos}{173}{-0.99255} +\pgfmath@def{cos}{174}{-0.99452} \pgfmath@def{cos}{175}{-0.99619} +\pgfmath@def{cos}{176}{-0.99756} \pgfmath@def{cos}{177}{-0.99863} +\pgfmath@def{cos}{178}{-0.99939} \pgfmath@def{cos}{179}{-0.99985} +\pgfmath@def{cos}{180}{-1.00000} \pgfmath@def{cos}{181}{-0.99985} + +\pgfmath@def{cosfrac}{0}{1.00000} \pgfmath@def{cosfrac}{1}{0.99995} +\pgfmath@def{cosfrac}{2}{0.99980} \pgfmath@def{cosfrac}{3}{0.99955} +\pgfmath@def{cosfrac}{4}{0.99920} \pgfmath@def{cosfrac}{5}{0.99875} +\pgfmath@def{cosfrac}{6}{0.99820} \pgfmath@def{cosfrac}{7}{0.99755} +\pgfmath@def{cosfrac}{8}{0.99681} \pgfmath@def{cosfrac}{9}{0.99597} +\pgfmath@def{cosfrac}{10}{0.99503} \pgfmath@def{cosfrac}{11}{0.99400} +\pgfmath@def{cosfrac}{12}{0.99287} \pgfmath@def{cosfrac}{13}{0.99165} +\pgfmath@def{cosfrac}{14}{0.99034} \pgfmath@def{cosfrac}{15}{0.98893} +\pgfmath@def{cosfrac}{16}{0.98744} \pgfmath@def{cosfrac}{17}{0.98585} +\pgfmath@def{cosfrac}{18}{0.98418} \pgfmath@def{cosfrac}{19}{0.98242} +\pgfmath@def{cosfrac}{20}{0.98058} \pgfmath@def{cosfrac}{21}{0.97865} +\pgfmath@def{cosfrac}{22}{0.97664} \pgfmath@def{cosfrac}{23}{0.97455} +\pgfmath@def{cosfrac}{24}{0.97238} \pgfmath@def{cosfrac}{25}{0.97014} +\pgfmath@def{cosfrac}{26}{0.96782} \pgfmath@def{cosfrac}{27}{0.96542} +\pgfmath@def{cosfrac}{28}{0.96296} \pgfmath@def{cosfrac}{29}{0.96042} +\pgfmath@def{cosfrac}{30}{0.95782} \pgfmath@def{cosfrac}{31}{0.95515} +\pgfmath@def{cosfrac}{32}{0.95242} \pgfmath@def{cosfrac}{33}{0.94962} +\pgfmath@def{cosfrac}{34}{0.94677} \pgfmath@def{cosfrac}{35}{0.94385} +\pgfmath@def{cosfrac}{36}{0.94088} \pgfmath@def{cosfrac}{37}{0.93786} +\pgfmath@def{cosfrac}{38}{0.93478} \pgfmath@def{cosfrac}{39}{0.93165} +\pgfmath@def{cosfrac}{40}{0.92847} \pgfmath@def{cosfrac}{41}{0.92525} +\pgfmath@def{cosfrac}{42}{0.92198} \pgfmath@def{cosfrac}{43}{0.91866} +\pgfmath@def{cosfrac}{44}{0.91531} \pgfmath@def{cosfrac}{45}{0.91192} +\pgfmath@def{cosfrac}{46}{0.90849} \pgfmath@def{cosfrac}{47}{0.90502} +\pgfmath@def{cosfrac}{48}{0.90152} \pgfmath@def{cosfrac}{49}{0.89799} +\pgfmath@def{cosfrac}{50}{0.89442} \pgfmath@def{cosfrac}{51}{0.89083} +\pgfmath@def{cosfrac}{52}{0.88721} \pgfmath@def{cosfrac}{53}{0.88357} +\pgfmath@def{cosfrac}{54}{0.87990} \pgfmath@def{cosfrac}{55}{0.87621} +\pgfmath@def{cosfrac}{56}{0.87250} \pgfmath@def{cosfrac}{57}{0.86877} +\pgfmath@def{cosfrac}{58}{0.86503} \pgfmath@def{cosfrac}{59}{0.86126} +\pgfmath@def{cosfrac}{60}{0.85749} \pgfmath@def{cosfrac}{61}{0.85370} +\pgfmath@def{cosfrac}{62}{0.84990} \pgfmath@def{cosfrac}{63}{0.84609} +\pgfmath@def{cosfrac}{64}{0.84227} \pgfmath@def{cosfrac}{65}{0.83844} +\pgfmath@def{cosfrac}{66}{0.83460} \pgfmath@def{cosfrac}{67}{0.83077} +\pgfmath@def{cosfrac}{68}{0.82692} \pgfmath@def{cosfrac}{69}{0.82308} +\pgfmath@def{cosfrac}{70}{0.81923} \pgfmath@def{cosfrac}{71}{0.81538} +\pgfmath@def{cosfrac}{72}{0.81153} \pgfmath@def{cosfrac}{73}{0.80768} +\pgfmath@def{cosfrac}{74}{0.80384} \pgfmath@def{cosfrac}{75}{0.80000} +\pgfmath@def{cosfrac}{76}{0.79616} \pgfmath@def{cosfrac}{77}{0.79232} +\pgfmath@def{cosfrac}{78}{0.78850} \pgfmath@def{cosfrac}{79}{0.78468} +\pgfmath@def{cosfrac}{80}{0.78086} \pgfmath@def{cosfrac}{81}{0.77706} +\pgfmath@def{cosfrac}{82}{0.77326} \pgfmath@def{cosfrac}{83}{0.76948} +\pgfmath@def{cosfrac}{84}{0.76570} \pgfmath@def{cosfrac}{85}{0.76193} +\pgfmath@def{cosfrac}{86}{0.75818} \pgfmath@def{cosfrac}{87}{0.75444} +\pgfmath@def{cosfrac}{88}{0.75071} \pgfmath@def{cosfrac}{89}{0.74699} +\pgfmath@def{cosfrac}{90}{0.74329} \pgfmath@def{cosfrac}{91}{0.73960} +\pgfmath@def{cosfrac}{92}{0.73593} \pgfmath@def{cosfrac}{93}{0.73227} +\pgfmath@def{cosfrac}{94}{0.72862} \pgfmath@def{cosfrac}{95}{0.72499} +\pgfmath@def{cosfrac}{96}{0.72138} \pgfmath@def{cosfrac}{97}{0.71779} +\pgfmath@def{cosfrac}{98}{0.71421} \pgfmath@def{cosfrac}{99}{0.71065} +\pgfmath@def{cosfrac}{100}{0.70710} + +% Oh No! Some really loooooong tables. +\pgfmath@def{atan}{0}{0.00000} \pgfmath@def{atan}{1}{0.05729} +\pgfmath@def{atan}{2}{0.11459} \pgfmath@def{atan}{3}{0.17188} +\pgfmath@def{atan}{4}{0.22918} \pgfmath@def{atan}{5}{0.28647} +\pgfmath@def{atan}{6}{0.34377} \pgfmath@def{atan}{7}{0.40106} +\pgfmath@def{atan}{8}{0.45835} \pgfmath@def{atan}{9}{0.51564} +\pgfmath@def{atan}{10}{0.57293} \pgfmath@def{atan}{11}{0.63022} +\pgfmath@def{atan}{12}{0.68751} \pgfmath@def{atan}{13}{0.74480} +\pgfmath@def{atan}{14}{0.80208} \pgfmath@def{atan}{15}{0.85937} +\pgfmath@def{atan}{16}{0.91665} \pgfmath@def{atan}{17}{0.97393} +\pgfmath@def{atan}{18}{1.03121} \pgfmath@def{atan}{19}{1.08848} +\pgfmath@def{atan}{20}{1.14576} \pgfmath@def{atan}{21}{1.20303} +\pgfmath@def{atan}{22}{1.26030} \pgfmath@def{atan}{23}{1.31757} +\pgfmath@def{atan}{24}{1.37483} \pgfmath@def{atan}{25}{1.43209} +\pgfmath@def{atan}{26}{1.48935} \pgfmath@def{atan}{27}{1.54661} +\pgfmath@def{atan}{28}{1.60386} \pgfmath@def{atan}{29}{1.66111} +\pgfmath@def{atan}{30}{1.71835} \pgfmath@def{atan}{31}{1.77560} +\pgfmath@def{atan}{32}{1.83284} \pgfmath@def{atan}{33}{1.89007} +\pgfmath@def{atan}{34}{1.94730} \pgfmath@def{atan}{35}{2.00453} +\pgfmath@def{atan}{36}{2.06175} \pgfmath@def{atan}{37}{2.11897} +\pgfmath@def{atan}{38}{2.17619} \pgfmath@def{atan}{39}{2.23340} +\pgfmath@def{atan}{40}{2.29061} \pgfmath@def{atan}{41}{2.34781} +\pgfmath@def{atan}{42}{2.40500} \pgfmath@def{atan}{43}{2.46220} +\pgfmath@def{atan}{44}{2.51938} \pgfmath@def{atan}{45}{2.57657} +\pgfmath@def{atan}{46}{2.63374} \pgfmath@def{atan}{47}{2.69092} +\pgfmath@def{atan}{48}{2.74808} \pgfmath@def{atan}{49}{2.80524} +\pgfmath@def{atan}{50}{2.86240} \pgfmath@def{atan}{51}{2.91955} +\pgfmath@def{atan}{52}{2.97669} \pgfmath@def{atan}{53}{3.03383} +\pgfmath@def{atan}{54}{3.09097} \pgfmath@def{atan}{55}{3.14809} +\pgfmath@def{atan}{56}{3.20521} \pgfmath@def{atan}{57}{3.26232} +\pgfmath@def{atan}{58}{3.31943} \pgfmath@def{atan}{59}{3.37653} +\pgfmath@def{atan}{60}{3.43363} \pgfmath@def{atan}{61}{3.49071} +\pgfmath@def{atan}{62}{3.54779} \pgfmath@def{atan}{63}{3.60487} +\pgfmath@def{atan}{64}{3.66193} \pgfmath@def{atan}{65}{3.71899} +\pgfmath@def{atan}{66}{3.77604} \pgfmath@def{atan}{67}{3.83308} +\pgfmath@def{atan}{68}{3.89012} \pgfmath@def{atan}{69}{3.94715} +\pgfmath@def{atan}{70}{4.00417} \pgfmath@def{atan}{71}{4.06118} +\pgfmath@def{atan}{72}{4.11819} \pgfmath@def{atan}{73}{4.17518} +\pgfmath@def{atan}{74}{4.23217} \pgfmath@def{atan}{75}{4.28915} +\pgfmath@def{atan}{76}{4.34612} \pgfmath@def{atan}{77}{4.40308} +\pgfmath@def{atan}{78}{4.46004} \pgfmath@def{atan}{79}{4.51698} +\pgfmath@def{atan}{80}{4.57392} \pgfmath@def{atan}{81}{4.63084} +\pgfmath@def{atan}{82}{4.68776} \pgfmath@def{atan}{83}{4.74467} +\pgfmath@def{atan}{84}{4.80157} \pgfmath@def{atan}{85}{4.85846} +\pgfmath@def{atan}{86}{4.91534} \pgfmath@def{atan}{87}{4.97221} +\pgfmath@def{atan}{88}{5.02907} \pgfmath@def{atan}{89}{5.08592} +\pgfmath@def{atan}{90}{5.14276} \pgfmath@def{atan}{91}{5.19959} +\pgfmath@def{atan}{92}{5.25641} \pgfmath@def{atan}{93}{5.31322} +\pgfmath@def{atan}{94}{5.37002} \pgfmath@def{atan}{95}{5.42681} +\pgfmath@def{atan}{96}{5.48359} \pgfmath@def{atan}{97}{5.54035} +\pgfmath@def{atan}{98}{5.59711} \pgfmath@def{atan}{99}{5.65385} +\pgfmath@def{atan}{100}{5.71059} \pgfmath@def{atan}{101}{5.76731} +\pgfmath@def{atan}{102}{5.82402} \pgfmath@def{atan}{103}{5.88072} +\pgfmath@def{atan}{104}{5.93741} \pgfmath@def{atan}{105}{5.99409} +\pgfmath@def{atan}{106}{6.05075} \pgfmath@def{atan}{107}{6.10741} +\pgfmath@def{atan}{108}{6.16405} \pgfmath@def{atan}{109}{6.22068} +\pgfmath@def{atan}{110}{6.27729} \pgfmath@def{atan}{111}{6.33390} +\pgfmath@def{atan}{112}{6.39049} \pgfmath@def{atan}{113}{6.44707} +\pgfmath@def{atan}{114}{6.50364} \pgfmath@def{atan}{115}{6.56019} +\pgfmath@def{atan}{116}{6.61673} \pgfmath@def{atan}{117}{6.67326} +\pgfmath@def{atan}{118}{6.72978} \pgfmath@def{atan}{119}{6.78628} +\pgfmath@def{atan}{120}{6.84277} \pgfmath@def{atan}{121}{6.89924} +\pgfmath@def{atan}{122}{6.95571} \pgfmath@def{atan}{123}{7.01216} +\pgfmath@def{atan}{124}{7.06859} \pgfmath@def{atan}{125}{7.12501} +\pgfmath@def{atan}{126}{7.18142} \pgfmath@def{atan}{127}{7.23781} +\pgfmath@def{atan}{128}{7.29419} \pgfmath@def{atan}{129}{7.35056} +\pgfmath@def{atan}{130}{7.40691} \pgfmath@def{atan}{131}{7.46324} +\pgfmath@def{atan}{132}{7.51957} \pgfmath@def{atan}{133}{7.57587} +\pgfmath@def{atan}{134}{7.63217} \pgfmath@def{atan}{135}{7.68844} +\pgfmath@def{atan}{136}{7.74471} \pgfmath@def{atan}{137}{7.80095} +\pgfmath@def{atan}{138}{7.85719} \pgfmath@def{atan}{139}{7.91340} +\pgfmath@def{atan}{140}{7.96961} \pgfmath@def{atan}{141}{8.02579} +\pgfmath@def{atan}{142}{8.08196} \pgfmath@def{atan}{143}{8.13812} +\pgfmath@def{atan}{144}{8.19426} \pgfmath@def{atan}{145}{8.25038} +\pgfmath@def{atan}{146}{8.30649} \pgfmath@def{atan}{147}{8.36258} +\pgfmath@def{atan}{148}{8.41866} \pgfmath@def{atan}{149}{8.47472} +\pgfmath@def{atan}{150}{8.53076} \pgfmath@def{atan}{151}{8.58679} +\pgfmath@def{atan}{152}{8.64280} \pgfmath@def{atan}{153}{8.69879} +\pgfmath@def{atan}{154}{8.75477} \pgfmath@def{atan}{155}{8.81073} +\pgfmath@def{atan}{156}{8.86667} \pgfmath@def{atan}{157}{8.92260} +\pgfmath@def{atan}{158}{8.97851} \pgfmath@def{atan}{159}{9.03440} +\pgfmath@def{atan}{160}{9.09027} \pgfmath@def{atan}{161}{9.14613} +\pgfmath@def{atan}{162}{9.20197} \pgfmath@def{atan}{163}{9.25779} +\pgfmath@def{atan}{164}{9.31359} \pgfmath@def{atan}{165}{9.36938} +\pgfmath@def{atan}{166}{9.42515} \pgfmath@def{atan}{167}{9.48090} +\pgfmath@def{atan}{168}{9.53663} \pgfmath@def{atan}{169}{9.59235} +\pgfmath@def{atan}{170}{9.64804} \pgfmath@def{atan}{171}{9.70372} +\pgfmath@def{atan}{172}{9.75938} \pgfmath@def{atan}{173}{9.81502} +\pgfmath@def{atan}{174}{9.87064} \pgfmath@def{atan}{175}{9.92624} +\pgfmath@def{atan}{176}{9.98182} \pgfmath@def{atan}{177}{10.03739} +\pgfmath@def{atan}{178}{10.09294} \pgfmath@def{atan}{179}{10.14846} +\pgfmath@def{atan}{180}{10.20397} \pgfmath@def{atan}{181}{10.25946} +\pgfmath@def{atan}{182}{10.31493} \pgfmath@def{atan}{183}{10.37037} +\pgfmath@def{atan}{184}{10.42580} \pgfmath@def{atan}{185}{10.48121} +\pgfmath@def{atan}{186}{10.53660} \pgfmath@def{atan}{187}{10.59197} +\pgfmath@def{atan}{188}{10.64732} \pgfmath@def{atan}{189}{10.70265} +\pgfmath@def{atan}{190}{10.75796} \pgfmath@def{atan}{191}{10.81325} +\pgfmath@def{atan}{192}{10.86852} \pgfmath@def{atan}{193}{10.92377} +\pgfmath@def{atan}{194}{10.97900} \pgfmath@def{atan}{195}{11.03420} +\pgfmath@def{atan}{196}{11.08939} \pgfmath@def{atan}{197}{11.14456} +\pgfmath@def{atan}{198}{11.19970} \pgfmath@def{atan}{199}{11.25483} +\pgfmath@def{atan}{200}{11.30993} \pgfmath@def{atan}{201}{11.36501} +\pgfmath@def{atan}{202}{11.42007} \pgfmath@def{atan}{203}{11.47511} +\pgfmath@def{atan}{204}{11.53013} \pgfmath@def{atan}{205}{11.58512} +\pgfmath@def{atan}{206}{11.64010} \pgfmath@def{atan}{207}{11.69505} +\pgfmath@def{atan}{208}{11.74998} \pgfmath@def{atan}{209}{11.80489} +\pgfmath@def{atan}{210}{11.85977} \pgfmath@def{atan}{211}{11.91464} +\pgfmath@def{atan}{212}{11.96948} \pgfmath@def{atan}{213}{12.02430} +\pgfmath@def{atan}{214}{12.07910} \pgfmath@def{atan}{215}{12.13388} +\pgfmath@def{atan}{216}{12.18863} \pgfmath@def{atan}{217}{12.24336} +\pgfmath@def{atan}{218}{12.29807} \pgfmath@def{atan}{219}{12.35275} +\pgfmath@def{atan}{220}{12.40741} \pgfmath@def{atan}{221}{12.46205} +\pgfmath@def{atan}{222}{12.51667} \pgfmath@def{atan}{223}{12.57126} +\pgfmath@def{atan}{224}{12.62583} \pgfmath@def{atan}{225}{12.68038} +\pgfmath@def{atan}{226}{12.73490} \pgfmath@def{atan}{227}{12.78940} +\pgfmath@def{atan}{228}{12.84388} \pgfmath@def{atan}{229}{12.89833} +\pgfmath@def{atan}{230}{12.95276} \pgfmath@def{atan}{231}{13.00717} +\pgfmath@def{atan}{232}{13.06155} \pgfmath@def{atan}{233}{13.11590} +\pgfmath@def{atan}{234}{13.17024} \pgfmath@def{atan}{235}{13.22455} +\pgfmath@def{atan}{236}{13.27883} \pgfmath@def{atan}{237}{13.33309} +\pgfmath@def{atan}{238}{13.38733} \pgfmath@def{atan}{239}{13.44154} +\pgfmath@def{atan}{240}{13.49573} \pgfmath@def{atan}{241}{13.54989} +\pgfmath@def{atan}{242}{13.60403} \pgfmath@def{atan}{243}{13.65814} +\pgfmath@def{atan}{244}{13.71223} \pgfmath@def{atan}{245}{13.76630} +\pgfmath@def{atan}{246}{13.82034} \pgfmath@def{atan}{247}{13.87435} +\pgfmath@def{atan}{248}{13.92834} \pgfmath@def{atan}{249}{13.98230} +\pgfmath@def{atan}{250}{14.03624} \pgfmath@def{atan}{251}{14.09015} +\pgfmath@def{atan}{252}{14.14404} \pgfmath@def{atan}{253}{14.19790} +\pgfmath@def{atan}{254}{14.25174} \pgfmath@def{atan}{255}{14.30555} +\pgfmath@def{atan}{256}{14.35933} \pgfmath@def{atan}{257}{14.41309} +\pgfmath@def{atan}{258}{14.46682} \pgfmath@def{atan}{259}{14.52053} +\pgfmath@def{atan}{260}{14.57421} \pgfmath@def{atan}{261}{14.62787} +\pgfmath@def{atan}{262}{14.68149} \pgfmath@def{atan}{263}{14.73510} +\pgfmath@def{atan}{264}{14.78867} \pgfmath@def{atan}{265}{14.84222} +\pgfmath@def{atan}{266}{14.89575} \pgfmath@def{atan}{267}{14.94924} +\pgfmath@def{atan}{268}{15.00271} \pgfmath@def{atan}{269}{15.05615} +\pgfmath@def{atan}{270}{15.10957} \pgfmath@def{atan}{271}{15.16296} +\pgfmath@def{atan}{272}{15.21632} \pgfmath@def{atan}{273}{15.26966} +\pgfmath@def{atan}{274}{15.32297} \pgfmath@def{atan}{275}{15.37625} +\pgfmath@def{atan}{276}{15.42950} \pgfmath@def{atan}{277}{15.48273} +\pgfmath@def{atan}{278}{15.53593} \pgfmath@def{atan}{279}{15.58910} +\pgfmath@def{atan}{280}{15.64224} \pgfmath@def{atan}{281}{15.69536} +\pgfmath@def{atan}{282}{15.74845} \pgfmath@def{atan}{283}{15.80151} +\pgfmath@def{atan}{284}{15.85454} \pgfmath@def{atan}{285}{15.90755} +\pgfmath@def{atan}{286}{15.96052} \pgfmath@def{atan}{287}{16.01347} +\pgfmath@def{atan}{288}{16.06640} \pgfmath@def{atan}{289}{16.11929} +\pgfmath@def{atan}{290}{16.17215} \pgfmath@def{atan}{291}{16.22499} +\pgfmath@def{atan}{292}{16.27780} \pgfmath@def{atan}{293}{16.33058} +\pgfmath@def{atan}{294}{16.38333} \pgfmath@def{atan}{295}{16.43605} +\pgfmath@def{atan}{296}{16.48875} \pgfmath@def{atan}{297}{16.54142} +\pgfmath@def{atan}{298}{16.59405} \pgfmath@def{atan}{299}{16.64666} +\pgfmath@def{atan}{300}{16.69924} \pgfmath@def{atan}{301}{16.75179} +\pgfmath@def{atan}{302}{16.80431} \pgfmath@def{atan}{303}{16.85680} +\pgfmath@def{atan}{304}{16.90927} \pgfmath@def{atan}{305}{16.96170} +\pgfmath@def{atan}{306}{17.01411} \pgfmath@def{atan}{307}{17.06648} +\pgfmath@def{atan}{308}{17.11883} \pgfmath@def{atan}{309}{17.17114} +\pgfmath@def{atan}{310}{17.22343} \pgfmath@def{atan}{311}{17.27569} +\pgfmath@def{atan}{312}{17.32792} \pgfmath@def{atan}{313}{17.38012} +\pgfmath@def{atan}{314}{17.43228} \pgfmath@def{atan}{315}{17.48442} +\pgfmath@def{atan}{316}{17.53653} \pgfmath@def{atan}{317}{17.58861} +\pgfmath@def{atan}{318}{17.64066} \pgfmath@def{atan}{319}{17.69268} +\pgfmath@def{atan}{320}{17.74467} \pgfmath@def{atan}{321}{17.79663} +\pgfmath@def{atan}{322}{17.84855} \pgfmath@def{atan}{323}{17.90045} +\pgfmath@def{atan}{324}{17.95232} \pgfmath@def{atan}{325}{18.00416} +\pgfmath@def{atan}{326}{18.05596} \pgfmath@def{atan}{327}{18.10774} +\pgfmath@def{atan}{328}{18.15949} \pgfmath@def{atan}{329}{18.21120} +\pgfmath@def{atan}{330}{18.26289} \pgfmath@def{atan}{331}{18.31454} +\pgfmath@def{atan}{332}{18.36616} \pgfmath@def{atan}{333}{18.41775} +\pgfmath@def{atan}{334}{18.46931} \pgfmath@def{atan}{335}{18.52084} +\pgfmath@def{atan}{336}{18.57234} \pgfmath@def{atan}{337}{18.62381} +\pgfmath@def{atan}{338}{18.67525} \pgfmath@def{atan}{339}{18.72665} +\pgfmath@def{atan}{340}{18.77803} \pgfmath@def{atan}{341}{18.82937} +\pgfmath@def{atan}{342}{18.88068} \pgfmath@def{atan}{343}{18.93196} +\pgfmath@def{atan}{344}{18.98321} \pgfmath@def{atan}{345}{19.03443} +\pgfmath@def{atan}{346}{19.08562} \pgfmath@def{atan}{347}{19.13677} +\pgfmath@def{atan}{348}{19.18789} \pgfmath@def{atan}{349}{19.23898} +\pgfmath@def{atan}{350}{19.29004} \pgfmath@def{atan}{351}{19.34107} +\pgfmath@def{atan}{352}{19.39206} \pgfmath@def{atan}{353}{19.44303} +\pgfmath@def{atan}{354}{19.49396} \pgfmath@def{atan}{355}{19.54486} +\pgfmath@def{atan}{356}{19.59572} \pgfmath@def{atan}{357}{19.64656} +\pgfmath@def{atan}{358}{19.69736} \pgfmath@def{atan}{359}{19.74813} +\pgfmath@def{atan}{360}{19.79887} \pgfmath@def{atan}{361}{19.84958} +\pgfmath@def{atan}{362}{19.90025} \pgfmath@def{atan}{363}{19.95089} +\pgfmath@def{atan}{364}{20.00150} \pgfmath@def{atan}{365}{20.05208} +\pgfmath@def{atan}{366}{20.10262} \pgfmath@def{atan}{367}{20.15313} +\pgfmath@def{atan}{368}{20.20361} \pgfmath@def{atan}{369}{20.25406} +\pgfmath@def{atan}{370}{20.30447} \pgfmath@def{atan}{371}{20.35485} +\pgfmath@def{atan}{372}{20.40520} \pgfmath@def{atan}{373}{20.45551} +\pgfmath@def{atan}{374}{20.50579} \pgfmath@def{atan}{375}{20.55604} +\pgfmath@def{atan}{376}{20.60626} \pgfmath@def{atan}{377}{20.65644} +\pgfmath@def{atan}{378}{20.70659} \pgfmath@def{atan}{379}{20.75670} +\pgfmath@def{atan}{380}{20.80679} \pgfmath@def{atan}{381}{20.85684} +\pgfmath@def{atan}{382}{20.90685} \pgfmath@def{atan}{383}{20.95684} +\pgfmath@def{atan}{384}{21.00678} \pgfmath@def{atan}{385}{21.05670} +\pgfmath@def{atan}{386}{21.10658} \pgfmath@def{atan}{387}{21.15643} +\pgfmath@def{atan}{388}{21.20625} \pgfmath@def{atan}{389}{21.25603} +\pgfmath@def{atan}{390}{21.30578} \pgfmath@def{atan}{391}{21.35549} +\pgfmath@def{atan}{392}{21.40517} \pgfmath@def{atan}{393}{21.45482} +\pgfmath@def{atan}{394}{21.50444} \pgfmath@def{atan}{395}{21.55402} +\pgfmath@def{atan}{396}{21.60356} \pgfmath@def{atan}{397}{21.65307} +\pgfmath@def{atan}{398}{21.70255} \pgfmath@def{atan}{399}{21.75200} +\pgfmath@def{atan}{400}{21.80140} \pgfmath@def{atan}{401}{21.85078} +\pgfmath@def{atan}{402}{21.90012} \pgfmath@def{atan}{403}{21.94943} +\pgfmath@def{atan}{404}{21.99870} \pgfmath@def{atan}{405}{22.04794} +\pgfmath@def{atan}{406}{22.09715} \pgfmath@def{atan}{407}{22.14632} +\pgfmath@def{atan}{408}{22.19546} \pgfmath@def{atan}{409}{22.24456} +\pgfmath@def{atan}{410}{22.29362} \pgfmath@def{atan}{411}{22.34266} +\pgfmath@def{atan}{412}{22.39166} \pgfmath@def{atan}{413}{22.44062} +\pgfmath@def{atan}{414}{22.48955} \pgfmath@def{atan}{415}{22.53845} +\pgfmath@def{atan}{416}{22.58731} \pgfmath@def{atan}{417}{22.63613} +\pgfmath@def{atan}{418}{22.68492} \pgfmath@def{atan}{419}{22.73368} +\pgfmath@def{atan}{420}{22.78240} \pgfmath@def{atan}{421}{22.83109} +\pgfmath@def{atan}{422}{22.87974} \pgfmath@def{atan}{423}{22.92836} +\pgfmath@def{atan}{424}{22.97694} \pgfmath@def{atan}{425}{23.02549} +\pgfmath@def{atan}{426}{23.07400} \pgfmath@def{atan}{427}{23.12248} +\pgfmath@def{atan}{428}{23.17092} \pgfmath@def{atan}{429}{23.21933} +\pgfmath@def{atan}{430}{23.26770} \pgfmath@def{atan}{431}{23.31604} +\pgfmath@def{atan}{432}{23.36434} \pgfmath@def{atan}{433}{23.41261} +\pgfmath@def{atan}{434}{23.46084} \pgfmath@def{atan}{435}{23.50904} +\pgfmath@def{atan}{436}{23.55720} \pgfmath@def{atan}{437}{23.60532} +\pgfmath@def{atan}{438}{23.65341} \pgfmath@def{atan}{439}{23.70147} +\pgfmath@def{atan}{440}{23.74949} \pgfmath@def{atan}{441}{23.79747} +\pgfmath@def{atan}{442}{23.84542} \pgfmath@def{atan}{443}{23.89334} +\pgfmath@def{atan}{444}{23.94122} \pgfmath@def{atan}{445}{23.98906} +\pgfmath@def{atan}{446}{24.03687} \pgfmath@def{atan}{447}{24.08464} +\pgfmath@def{atan}{448}{24.13238} \pgfmath@def{atan}{449}{24.18008} +\pgfmath@def{atan}{450}{24.22774} \pgfmath@def{atan}{451}{24.27537} +\pgfmath@def{atan}{452}{24.32296} \pgfmath@def{atan}{453}{24.37052} +\pgfmath@def{atan}{454}{24.41804} \pgfmath@def{atan}{455}{24.46553} +\pgfmath@def{atan}{456}{24.51298} \pgfmath@def{atan}{457}{24.56040} +\pgfmath@def{atan}{458}{24.60778} \pgfmath@def{atan}{459}{24.65512} +\pgfmath@def{atan}{460}{24.70243} \pgfmath@def{atan}{461}{24.74970} +\pgfmath@def{atan}{462}{24.79693} \pgfmath@def{atan}{463}{24.84413} +\pgfmath@def{atan}{464}{24.89130} \pgfmath@def{atan}{465}{24.93842} +\pgfmath@def{atan}{466}{24.98551} \pgfmath@def{atan}{467}{25.03257} +\pgfmath@def{atan}{468}{25.07959} \pgfmath@def{atan}{469}{25.12657} +\pgfmath@def{atan}{470}{25.17352} \pgfmath@def{atan}{471}{25.22043} +\pgfmath@def{atan}{472}{25.26731} \pgfmath@def{atan}{473}{25.31414} +\pgfmath@def{atan}{474}{25.36095} \pgfmath@def{atan}{475}{25.40771} +\pgfmath@def{atan}{476}{25.45444} \pgfmath@def{atan}{477}{25.50114} +\pgfmath@def{atan}{478}{25.54780} \pgfmath@def{atan}{479}{25.59442} +\pgfmath@def{atan}{480}{25.64100} \pgfmath@def{atan}{481}{25.68755} +\pgfmath@def{atan}{482}{25.73406} \pgfmath@def{atan}{483}{25.78054} +\pgfmath@def{atan}{484}{25.82698} \pgfmath@def{atan}{485}{25.87338} +\pgfmath@def{atan}{486}{25.91975} \pgfmath@def{atan}{487}{25.96608} +\pgfmath@def{atan}{488}{26.01237} \pgfmath@def{atan}{489}{26.05863} +\pgfmath@def{atan}{490}{26.10485} \pgfmath@def{atan}{491}{26.15103} +\pgfmath@def{atan}{492}{26.19718} \pgfmath@def{atan}{493}{26.24329} +\pgfmath@def{atan}{494}{26.28937} \pgfmath@def{atan}{495}{26.33541} +\pgfmath@def{atan}{496}{26.38141} \pgfmath@def{atan}{497}{26.42737} +\pgfmath@def{atan}{498}{26.47330} \pgfmath@def{atan}{499}{26.51919} +\pgfmath@def{atan}{500}{26.56505} \pgfmath@def{atan}{501}{26.61086} +\pgfmath@def{atan}{502}{26.65665} \pgfmath@def{atan}{503}{26.70239} +\pgfmath@def{atan}{504}{26.74810} \pgfmath@def{atan}{505}{26.79377} +\pgfmath@def{atan}{506}{26.83941} \pgfmath@def{atan}{507}{26.88500} +\pgfmath@def{atan}{508}{26.93057} \pgfmath@def{atan}{509}{26.97609} +\pgfmath@def{atan}{510}{27.02158} \pgfmath@def{atan}{511}{27.06703} +\pgfmath@def{atan}{512}{27.11244} \pgfmath@def{atan}{513}{27.15782} +\pgfmath@def{atan}{514}{27.20316} \pgfmath@def{atan}{515}{27.24846} +\pgfmath@def{atan}{516}{27.29373} \pgfmath@def{atan}{517}{27.33896} +\pgfmath@def{atan}{518}{27.38415} \pgfmath@def{atan}{519}{27.42931} +\pgfmath@def{atan}{520}{27.47443} \pgfmath@def{atan}{521}{27.51951} +\pgfmath@def{atan}{522}{27.56455} \pgfmath@def{atan}{523}{27.60956} +\pgfmath@def{atan}{524}{27.65453} \pgfmath@def{atan}{525}{27.69947} +\pgfmath@def{atan}{526}{27.74437} \pgfmath@def{atan}{527}{27.78923} +\pgfmath@def{atan}{528}{27.83405} \pgfmath@def{atan}{529}{27.87884} +\pgfmath@def{atan}{530}{27.92359} \pgfmath@def{atan}{531}{27.96830} +\pgfmath@def{atan}{532}{28.01297} \pgfmath@def{atan}{533}{28.05761} +\pgfmath@def{atan}{534}{28.10221} \pgfmath@def{atan}{535}{28.14678} +\pgfmath@def{atan}{536}{28.19130} \pgfmath@def{atan}{537}{28.23579} +\pgfmath@def{atan}{538}{28.28025} \pgfmath@def{atan}{539}{28.32466} +\pgfmath@def{atan}{540}{28.36904} \pgfmath@def{atan}{541}{28.41338} +\pgfmath@def{atan}{542}{28.45769} \pgfmath@def{atan}{543}{28.50196} +\pgfmath@def{atan}{544}{28.54619} \pgfmath@def{atan}{545}{28.59038} +\pgfmath@def{atan}{546}{28.63454} \pgfmath@def{atan}{547}{28.67865} +\pgfmath@def{atan}{548}{28.72274} \pgfmath@def{atan}{549}{28.76678} +\pgfmath@def{atan}{550}{28.81079} \pgfmath@def{atan}{551}{28.85476} +\pgfmath@def{atan}{552}{28.89869} \pgfmath@def{atan}{553}{28.94259} +\pgfmath@def{atan}{554}{28.98645} \pgfmath@def{atan}{555}{29.03027} +\pgfmath@def{atan}{556}{29.07405} \pgfmath@def{atan}{557}{29.11780} +\pgfmath@def{atan}{558}{29.16151} \pgfmath@def{atan}{559}{29.20519} +\pgfmath@def{atan}{560}{29.24882} \pgfmath@def{atan}{561}{29.29242} +\pgfmath@def{atan}{562}{29.33598} \pgfmath@def{atan}{563}{29.37951} +\pgfmath@def{atan}{564}{29.42299} \pgfmath@def{atan}{565}{29.46644} +\pgfmath@def{atan}{566}{29.50986} \pgfmath@def{atan}{567}{29.55323} +\pgfmath@def{atan}{568}{29.59657} \pgfmath@def{atan}{569}{29.63987} +\pgfmath@def{atan}{570}{29.68314} \pgfmath@def{atan}{571}{29.72636} +\pgfmath@def{atan}{572}{29.76955} \pgfmath@def{atan}{573}{29.81270} +\pgfmath@def{atan}{574}{29.85582} \pgfmath@def{atan}{575}{29.89890} +\pgfmath@def{atan}{576}{29.94194} \pgfmath@def{atan}{577}{29.98494} +\pgfmath@def{atan}{578}{30.02791} \pgfmath@def{atan}{579}{30.07084} +\pgfmath@def{atan}{580}{30.11373} \pgfmath@def{atan}{581}{30.15658} +\pgfmath@def{atan}{582}{30.19940} \pgfmath@def{atan}{583}{30.24218} +\pgfmath@def{atan}{584}{30.28492} \pgfmath@def{atan}{585}{30.32763} +\pgfmath@def{atan}{586}{30.37030} \pgfmath@def{atan}{587}{30.41293} +\pgfmath@def{atan}{588}{30.45552} \pgfmath@def{atan}{589}{30.49808} +\pgfmath@def{atan}{590}{30.54060} \pgfmath@def{atan}{591}{30.58308} +\pgfmath@def{atan}{592}{30.62553} \pgfmath@def{atan}{593}{30.66794} +\pgfmath@def{atan}{594}{30.71031} \pgfmath@def{atan}{595}{30.75264} +\pgfmath@def{atan}{596}{30.79494} \pgfmath@def{atan}{597}{30.83720} +\pgfmath@def{atan}{598}{30.87942} \pgfmath@def{atan}{599}{30.92160} +\pgfmath@def{atan}{600}{30.96375} \pgfmath@def{atan}{601}{31.00586} +\pgfmath@def{atan}{602}{31.04794} \pgfmath@def{atan}{603}{31.08997} +\pgfmath@def{atan}{604}{31.13197} \pgfmath@def{atan}{605}{31.17393} +\pgfmath@def{atan}{606}{31.21586} \pgfmath@def{atan}{607}{31.25775} +\pgfmath@def{atan}{608}{31.29960} \pgfmath@def{atan}{609}{31.34141} +\pgfmath@def{atan}{610}{31.38319} \pgfmath@def{atan}{611}{31.42493} +\pgfmath@def{atan}{612}{31.46663} \pgfmath@def{atan}{613}{31.50829} +\pgfmath@def{atan}{614}{31.54992} \pgfmath@def{atan}{615}{31.59151} +\pgfmath@def{atan}{616}{31.63306} \pgfmath@def{atan}{617}{31.67458} +\pgfmath@def{atan}{618}{31.71606} \pgfmath@def{atan}{619}{31.75750} +\pgfmath@def{atan}{620}{31.79891} \pgfmath@def{atan}{621}{31.84028} +\pgfmath@def{atan}{622}{31.88161} \pgfmath@def{atan}{623}{31.92290} +\pgfmath@def{atan}{624}{31.96416} \pgfmath@def{atan}{625}{32.00538} +\pgfmath@def{atan}{626}{32.04656} \pgfmath@def{atan}{627}{32.08771} +\pgfmath@def{atan}{628}{32.12882} \pgfmath@def{atan}{629}{32.16989} +\pgfmath@def{atan}{630}{32.21092} \pgfmath@def{atan}{631}{32.25192} +\pgfmath@def{atan}{632}{32.29288} \pgfmath@def{atan}{633}{32.33381} +\pgfmath@def{atan}{634}{32.37469} \pgfmath@def{atan}{635}{32.41554} +\pgfmath@def{atan}{636}{32.45636} \pgfmath@def{atan}{637}{32.49713} +\pgfmath@def{atan}{638}{32.53787} \pgfmath@def{atan}{639}{32.57857} +\pgfmath@def{atan}{640}{32.61924} \pgfmath@def{atan}{641}{32.65987} +\pgfmath@def{atan}{642}{32.70046} \pgfmath@def{atan}{643}{32.74101} +\pgfmath@def{atan}{644}{32.78153} \pgfmath@def{atan}{645}{32.82201} +\pgfmath@def{atan}{646}{32.86246} \pgfmath@def{atan}{647}{32.90286} +\pgfmath@def{atan}{648}{32.94323} \pgfmath@def{atan}{649}{32.98357} +\pgfmath@def{atan}{650}{33.02386} \pgfmath@def{atan}{651}{33.06412} +\pgfmath@def{atan}{652}{33.10435} \pgfmath@def{atan}{653}{33.14453} +\pgfmath@def{atan}{654}{33.18468} \pgfmath@def{atan}{655}{33.22479} +\pgfmath@def{atan}{656}{33.26487} \pgfmath@def{atan}{657}{33.30491} +\pgfmath@def{atan}{658}{33.34491} \pgfmath@def{atan}{659}{33.38488} +\pgfmath@def{atan}{660}{33.42481} \pgfmath@def{atan}{661}{33.46470} +\pgfmath@def{atan}{662}{33.50455} \pgfmath@def{atan}{663}{33.54437} +\pgfmath@def{atan}{664}{33.58416} \pgfmath@def{atan}{665}{33.62390} +\pgfmath@def{atan}{666}{33.66361} \pgfmath@def{atan}{667}{33.70328} +\pgfmath@def{atan}{668}{33.74292} \pgfmath@def{atan}{669}{33.78252} +\pgfmath@def{atan}{670}{33.82208} \pgfmath@def{atan}{671}{33.86161} +\pgfmath@def{atan}{672}{33.90110} \pgfmath@def{atan}{673}{33.94055} +\pgfmath@def{atan}{674}{33.97997} \pgfmath@def{atan}{675}{34.01935} +\pgfmath@def{atan}{676}{34.05869} \pgfmath@def{atan}{677}{34.09800} +\pgfmath@def{atan}{678}{34.13727} \pgfmath@def{atan}{679}{34.17650} +\pgfmath@def{atan}{680}{34.21570} \pgfmath@def{atan}{681}{34.25486} +\pgfmath@def{atan}{682}{34.29398} \pgfmath@def{atan}{683}{34.33307} +\pgfmath@def{atan}{684}{34.37212} \pgfmath@def{atan}{685}{34.41114} +\pgfmath@def{atan}{686}{34.45012} \pgfmath@def{atan}{687}{34.48906} +\pgfmath@def{atan}{688}{34.52797} \pgfmath@def{atan}{689}{34.56684} +\pgfmath@def{atan}{690}{34.60567} \pgfmath@def{atan}{691}{34.64447} +\pgfmath@def{atan}{692}{34.68323} \pgfmath@def{atan}{693}{34.72195} +\pgfmath@def{atan}{694}{34.76064} \pgfmath@def{atan}{695}{34.79930} +\pgfmath@def{atan}{696}{34.83791} \pgfmath@def{atan}{697}{34.87649} +\pgfmath@def{atan}{698}{34.91504} \pgfmath@def{atan}{699}{34.95354} +\pgfmath@def{atan}{700}{34.99202} \pgfmath@def{atan}{701}{35.03045} +\pgfmath@def{atan}{702}{35.06885} \pgfmath@def{atan}{703}{35.10721} +\pgfmath@def{atan}{704}{35.14554} \pgfmath@def{atan}{705}{35.18383} +\pgfmath@def{atan}{706}{35.22209} \pgfmath@def{atan}{707}{35.26031} +\pgfmath@def{atan}{708}{35.29849} \pgfmath@def{atan}{709}{35.33664} +\pgfmath@def{atan}{710}{35.37475} \pgfmath@def{atan}{711}{35.41282} +\pgfmath@def{atan}{712}{35.45086} \pgfmath@def{atan}{713}{35.48886} +\pgfmath@def{atan}{714}{35.52683} \pgfmath@def{atan}{715}{35.56476} +\pgfmath@def{atan}{716}{35.60266} \pgfmath@def{atan}{717}{35.64052} +\pgfmath@def{atan}{718}{35.67834} \pgfmath@def{atan}{719}{35.71613} +\pgfmath@def{atan}{720}{35.75388} \pgfmath@def{atan}{721}{35.79160} +\pgfmath@def{atan}{722}{35.82928} \pgfmath@def{atan}{723}{35.86692} +\pgfmath@def{atan}{724}{35.90453} \pgfmath@def{atan}{725}{35.94211} +\pgfmath@def{atan}{726}{35.97965} \pgfmath@def{atan}{727}{36.01715} +\pgfmath@def{atan}{728}{36.05461} \pgfmath@def{atan}{729}{36.09204} +\pgfmath@def{atan}{730}{36.12944} \pgfmath@def{atan}{731}{36.16680} +\pgfmath@def{atan}{732}{36.20412} \pgfmath@def{atan}{733}{36.24141} +\pgfmath@def{atan}{734}{36.27866} \pgfmath@def{atan}{735}{36.31588} +\pgfmath@def{atan}{736}{36.35306} \pgfmath@def{atan}{737}{36.39021} +\pgfmath@def{atan}{738}{36.42732} \pgfmath@def{atan}{739}{36.46440} +\pgfmath@def{atan}{740}{36.50144} \pgfmath@def{atan}{741}{36.53844} +\pgfmath@def{atan}{742}{36.57541} \pgfmath@def{atan}{743}{36.61234} +\pgfmath@def{atan}{744}{36.64924} \pgfmath@def{atan}{745}{36.68611} +\pgfmath@def{atan}{746}{36.72293} \pgfmath@def{atan}{747}{36.75973} +\pgfmath@def{atan}{748}{36.79648} \pgfmath@def{atan}{749}{36.83321} +\pgfmath@def{atan}{750}{36.86989} \pgfmath@def{atan}{751}{36.90654} +\pgfmath@def{atan}{752}{36.94316} \pgfmath@def{atan}{753}{36.97974} +\pgfmath@def{atan}{754}{37.01629} \pgfmath@def{atan}{755}{37.05280} +\pgfmath@def{atan}{756}{37.08928} \pgfmath@def{atan}{757}{37.12572} +\pgfmath@def{atan}{758}{37.16212} \pgfmath@def{atan}{759}{37.19849} +\pgfmath@def{atan}{760}{37.23483} \pgfmath@def{atan}{761}{37.27113} +\pgfmath@def{atan}{762}{37.30740} \pgfmath@def{atan}{763}{37.34363} +\pgfmath@def{atan}{764}{37.37982} \pgfmath@def{atan}{765}{37.41598} +\pgfmath@def{atan}{766}{37.45211} \pgfmath@def{atan}{767}{37.48820} +\pgfmath@def{atan}{768}{37.52426} \pgfmath@def{atan}{769}{37.56028} +\pgfmath@def{atan}{770}{37.59627} \pgfmath@def{atan}{771}{37.63222} +\pgfmath@def{atan}{772}{37.66814} \pgfmath@def{atan}{773}{37.70402} +\pgfmath@def{atan}{774}{37.73987} \pgfmath@def{atan}{775}{37.77568} +\pgfmath@def{atan}{776}{37.81146} \pgfmath@def{atan}{777}{37.84720} +\pgfmath@def{atan}{778}{37.88291} \pgfmath@def{atan}{779}{37.91859} +\pgfmath@def{atan}{780}{37.95423} \pgfmath@def{atan}{781}{37.98983} +\pgfmath@def{atan}{782}{38.02540} \pgfmath@def{atan}{783}{38.06094} +\pgfmath@def{atan}{784}{38.09644} \pgfmath@def{atan}{785}{38.13191} +\pgfmath@def{atan}{786}{38.16734} \pgfmath@def{atan}{787}{38.20274} +\pgfmath@def{atan}{788}{38.23811} \pgfmath@def{atan}{789}{38.27344} +\pgfmath@def{atan}{790}{38.30873} \pgfmath@def{atan}{791}{38.34399} +\pgfmath@def{atan}{792}{38.37922} \pgfmath@def{atan}{793}{38.41441} +\pgfmath@def{atan}{794}{38.44957} \pgfmath@def{atan}{795}{38.48469} +\pgfmath@def{atan}{796}{38.51979} \pgfmath@def{atan}{797}{38.55484} +\pgfmath@def{atan}{798}{38.58986} \pgfmath@def{atan}{799}{38.62485} +\pgfmath@def{atan}{800}{38.65980} \pgfmath@def{atan}{801}{38.69472} +\pgfmath@def{atan}{802}{38.72961} \pgfmath@def{atan}{803}{38.76446} +\pgfmath@def{atan}{804}{38.79928} \pgfmath@def{atan}{805}{38.83406} +\pgfmath@def{atan}{806}{38.86881} \pgfmath@def{atan}{807}{38.90353} +\pgfmath@def{atan}{808}{38.93821} \pgfmath@def{atan}{809}{38.97285} +\pgfmath@def{atan}{810}{39.00747} \pgfmath@def{atan}{811}{39.04205} +\pgfmath@def{atan}{812}{39.07659} \pgfmath@def{atan}{813}{39.11111} +\pgfmath@def{atan}{814}{39.14558} \pgfmath@def{atan}{815}{39.18003} +\pgfmath@def{atan}{816}{39.21444} \pgfmath@def{atan}{817}{39.24882} +\pgfmath@def{atan}{818}{39.28316} \pgfmath@def{atan}{819}{39.31747} +\pgfmath@def{atan}{820}{39.35175} \pgfmath@def{atan}{821}{39.38599} +\pgfmath@def{atan}{822}{39.42020} \pgfmath@def{atan}{823}{39.45438} +\pgfmath@def{atan}{824}{39.48852} \pgfmath@def{atan}{825}{39.52263} +\pgfmath@def{atan}{826}{39.55670} \pgfmath@def{atan}{827}{39.59074} +\pgfmath@def{atan}{828}{39.62475} \pgfmath@def{atan}{829}{39.65873} +\pgfmath@def{atan}{830}{39.69267} \pgfmath@def{atan}{831}{39.72658} +\pgfmath@def{atan}{832}{39.76045} \pgfmath@def{atan}{833}{39.79429} +\pgfmath@def{atan}{834}{39.82810} \pgfmath@def{atan}{835}{39.86188} +\pgfmath@def{atan}{836}{39.89562} \pgfmath@def{atan}{837}{39.92933} +\pgfmath@def{atan}{838}{39.96300} \pgfmath@def{atan}{839}{39.99665} +\pgfmath@def{atan}{840}{40.03025} \pgfmath@def{atan}{841}{40.06383} +\pgfmath@def{atan}{842}{40.09737} \pgfmath@def{atan}{843}{40.13088} +\pgfmath@def{atan}{844}{40.16436} \pgfmath@def{atan}{845}{40.19781} +\pgfmath@def{atan}{846}{40.23122} \pgfmath@def{atan}{847}{40.26459} +\pgfmath@def{atan}{848}{40.29794} \pgfmath@def{atan}{849}{40.33125} +\pgfmath@def{atan}{850}{40.36453} \pgfmath@def{atan}{851}{40.39778} +\pgfmath@def{atan}{852}{40.43099} \pgfmath@def{atan}{853}{40.46417} +\pgfmath@def{atan}{854}{40.49732} \pgfmath@def{atan}{855}{40.53044} +\pgfmath@def{atan}{856}{40.56352} \pgfmath@def{atan}{857}{40.59657} +\pgfmath@def{atan}{858}{40.62959} \pgfmath@def{atan}{859}{40.66257} +\pgfmath@def{atan}{860}{40.69553} \pgfmath@def{atan}{861}{40.72845} +\pgfmath@def{atan}{862}{40.76133} \pgfmath@def{atan}{863}{40.79419} +\pgfmath@def{atan}{864}{40.82701} \pgfmath@def{atan}{865}{40.85980} +\pgfmath@def{atan}{866}{40.89256} \pgfmath@def{atan}{867}{40.92528} +\pgfmath@def{atan}{868}{40.95798} \pgfmath@def{atan}{869}{40.99064} +\pgfmath@def{atan}{870}{41.02326} \pgfmath@def{atan}{871}{41.05586} +\pgfmath@def{atan}{872}{41.08842} \pgfmath@def{atan}{873}{41.12095} +\pgfmath@def{atan}{874}{41.15345} \pgfmath@def{atan}{875}{41.18592} +\pgfmath@def{atan}{876}{41.21836} \pgfmath@def{atan}{877}{41.25076} +\pgfmath@def{atan}{878}{41.28313} \pgfmath@def{atan}{879}{41.31547} +\pgfmath@def{atan}{880}{41.34777} \pgfmath@def{atan}{881}{41.38005} +\pgfmath@def{atan}{882}{41.41229} \pgfmath@def{atan}{883}{41.44450} +\pgfmath@def{atan}{884}{41.47668} \pgfmath@def{atan}{885}{41.50882} +\pgfmath@def{atan}{886}{41.54094} \pgfmath@def{atan}{887}{41.57302} +\pgfmath@def{atan}{888}{41.60507} \pgfmath@def{atan}{889}{41.63709} +\pgfmath@def{atan}{890}{41.66908} \pgfmath@def{atan}{891}{41.70103} +\pgfmath@def{atan}{892}{41.73296} \pgfmath@def{atan}{893}{41.76485} +\pgfmath@def{atan}{894}{41.79671} \pgfmath@def{atan}{895}{41.82854} +\pgfmath@def{atan}{896}{41.86034} \pgfmath@def{atan}{897}{41.89210} +\pgfmath@def{atan}{898}{41.92383} \pgfmath@def{atan}{899}{41.95554} +\pgfmath@def{atan}{900}{41.98721} \pgfmath@def{atan}{901}{42.01885} +\pgfmath@def{atan}{902}{42.05046} \pgfmath@def{atan}{903}{42.08203} +\pgfmath@def{atan}{904}{42.11358} \pgfmath@def{atan}{905}{42.14509} +\pgfmath@def{atan}{906}{42.17657} \pgfmath@def{atan}{907}{42.20802} +\pgfmath@def{atan}{908}{42.23944} \pgfmath@def{atan}{909}{42.27083} +\pgfmath@def{atan}{910}{42.30219} \pgfmath@def{atan}{911}{42.33352} +\pgfmath@def{atan}{912}{42.36481} \pgfmath@def{atan}{913}{42.39607} +\pgfmath@def{atan}{914}{42.42731} \pgfmath@def{atan}{915}{42.45851} +\pgfmath@def{atan}{916}{42.48968} \pgfmath@def{atan}{917}{42.52082} +\pgfmath@def{atan}{918}{42.55193} \pgfmath@def{atan}{919}{42.58300} +\pgfmath@def{atan}{920}{42.61405} \pgfmath@def{atan}{921}{42.64507} +\pgfmath@def{atan}{922}{42.67605} \pgfmath@def{atan}{923}{42.70701} +\pgfmath@def{atan}{924}{42.73793} \pgfmath@def{atan}{925}{42.76882} +\pgfmath@def{atan}{926}{42.79968} \pgfmath@def{atan}{927}{42.83051} +\pgfmath@def{atan}{928}{42.86131} \pgfmath@def{atan}{929}{42.89208} +\pgfmath@def{atan}{930}{42.92282} \pgfmath@def{atan}{931}{42.95353} +\pgfmath@def{atan}{932}{42.98421} \pgfmath@def{atan}{933}{43.01485} +\pgfmath@def{atan}{934}{43.04547} \pgfmath@def{atan}{935}{43.07605} +\pgfmath@def{atan}{936}{43.10661} \pgfmath@def{atan}{937}{43.13713} +\pgfmath@def{atan}{938}{43.16763} \pgfmath@def{atan}{939}{43.19809} +\pgfmath@def{atan}{940}{43.22853} \pgfmath@def{atan}{941}{43.25893} +\pgfmath@def{atan}{942}{43.28930} \pgfmath@def{atan}{943}{43.31964} +\pgfmath@def{atan}{944}{43.34996} \pgfmath@def{atan}{945}{43.38024} +\pgfmath@def{atan}{946}{43.41049} \pgfmath@def{atan}{947}{43.44071} +\pgfmath@def{atan}{948}{43.47090} \pgfmath@def{atan}{949}{43.50106} +\pgfmath@def{atan}{950}{43.53119} \pgfmath@def{atan}{951}{43.56130} +\pgfmath@def{atan}{952}{43.59137} \pgfmath@def{atan}{953}{43.62141} +\pgfmath@def{atan}{954}{43.65142} \pgfmath@def{atan}{955}{43.68140} +\pgfmath@def{atan}{956}{43.71135} \pgfmath@def{atan}{957}{43.74127} +\pgfmath@def{atan}{958}{43.77116} \pgfmath@def{atan}{959}{43.80102} +\pgfmath@def{atan}{960}{43.83086} \pgfmath@def{atan}{961}{43.86066} +\pgfmath@def{atan}{962}{43.89043} \pgfmath@def{atan}{963}{43.92017} +\pgfmath@def{atan}{964}{43.94988} \pgfmath@def{atan}{965}{43.97957} +\pgfmath@def{atan}{966}{44.00922} \pgfmath@def{atan}{967}{44.03884} +\pgfmath@def{atan}{968}{44.06844} \pgfmath@def{atan}{969}{44.09800} +\pgfmath@def{atan}{970}{44.12754} \pgfmath@def{atan}{971}{44.15704} +\pgfmath@def{atan}{972}{44.18652} \pgfmath@def{atan}{973}{44.21597} +\pgfmath@def{atan}{974}{44.24538} \pgfmath@def{atan}{975}{44.27477} +\pgfmath@def{atan}{976}{44.30413} \pgfmath@def{atan}{977}{44.33346} +\pgfmath@def{atan}{978}{44.36276} \pgfmath@def{atan}{979}{44.39203} +\pgfmath@def{atan}{980}{44.42127} \pgfmath@def{atan}{981}{44.45048} +\pgfmath@def{atan}{982}{44.47966} \pgfmath@def{atan}{983}{44.50882} +\pgfmath@def{atan}{984}{44.53794} \pgfmath@def{atan}{985}{44.56704} +\pgfmath@def{atan}{986}{44.59610} \pgfmath@def{atan}{987}{44.62514} +\pgfmath@def{atan}{988}{44.65415} \pgfmath@def{atan}{989}{44.68313} +\pgfmath@def{atan}{990}{44.71208} \pgfmath@def{atan}{991}{44.74100} +\pgfmath@def{atan}{992}{44.76989} \pgfmath@def{atan}{993}{44.79876} +\pgfmath@def{atan}{994}{44.82759} \pgfmath@def{atan}{995}{44.85640} +\pgfmath@def{atan}{996}{44.88517} \pgfmath@def{atan}{997}{44.91392} +\pgfmath@def{atan}{998}{44.94264} \pgfmath@def{atan}{999}{44.97133} +\pgfmath@def{atan}{1000}{45.00000} + +\pgfmath@def{acos}{0}{90.00000} \pgfmath@def{acos}{1}{89.94270} +\pgfmath@def{acos}{2}{89.88540} \pgfmath@def{acos}{3}{89.82811} +\pgfmath@def{acos}{4}{89.77081} \pgfmath@def{acos}{5}{89.71352} +\pgfmath@def{acos}{6}{89.65622} \pgfmath@def{acos}{7}{89.59892} +\pgfmath@def{acos}{8}{89.54162} \pgfmath@def{acos}{9}{89.48433} +\pgfmath@def{acos}{10}{89.42703} \pgfmath@def{acos}{11}{89.36973} +\pgfmath@def{acos}{12}{89.31243} \pgfmath@def{acos}{13}{89.25513} +\pgfmath@def{acos}{14}{89.19783} \pgfmath@def{acos}{15}{89.14053} +\pgfmath@def{acos}{16}{89.08322} \pgfmath@def{acos}{17}{89.02592} +\pgfmath@def{acos}{18}{88.96862} \pgfmath@def{acos}{19}{88.91131} +\pgfmath@def{acos}{20}{88.85400} \pgfmath@def{acos}{21}{88.79670} +\pgfmath@def{acos}{22}{88.73939} \pgfmath@def{acos}{23}{88.68208} +\pgfmath@def{acos}{24}{88.62476} \pgfmath@def{acos}{25}{88.56745} +\pgfmath@def{acos}{26}{88.51014} \pgfmath@def{acos}{27}{88.45282} +\pgfmath@def{acos}{28}{88.39550} \pgfmath@def{acos}{29}{88.33818} +\pgfmath@def{acos}{30}{88.28086} \pgfmath@def{acos}{31}{88.22354} +\pgfmath@def{acos}{32}{88.16622} \pgfmath@def{acos}{33}{88.10889} +\pgfmath@def{acos}{34}{88.05156} \pgfmath@def{acos}{35}{87.99423} +\pgfmath@def{acos}{36}{87.93690} \pgfmath@def{acos}{37}{87.87957} +\pgfmath@def{acos}{38}{87.82223} \pgfmath@def{acos}{39}{87.76489} +\pgfmath@def{acos}{40}{87.70755} \pgfmath@def{acos}{41}{87.65021} +\pgfmath@def{acos}{42}{87.59286} \pgfmath@def{acos}{43}{87.53552} +\pgfmath@def{acos}{44}{87.47817} \pgfmath@def{acos}{45}{87.42081} +\pgfmath@def{acos}{46}{87.36346} \pgfmath@def{acos}{47}{87.30610} +\pgfmath@def{acos}{48}{87.24874} \pgfmath@def{acos}{49}{87.19138} +\pgfmath@def{acos}{50}{87.13401} \pgfmath@def{acos}{51}{87.07664} +\pgfmath@def{acos}{52}{87.01927} \pgfmath@def{acos}{53}{86.96190} +\pgfmath@def{acos}{54}{86.90452} \pgfmath@def{acos}{55}{86.84714} +\pgfmath@def{acos}{56}{86.78975} \pgfmath@def{acos}{57}{86.73237} +\pgfmath@def{acos}{58}{86.67497} \pgfmath@def{acos}{59}{86.61758} +\pgfmath@def{acos}{60}{86.56018} \pgfmath@def{acos}{61}{86.50278} +\pgfmath@def{acos}{62}{86.44538} \pgfmath@def{acos}{63}{86.38797} +\pgfmath@def{acos}{64}{86.33056} \pgfmath@def{acos}{65}{86.27314} +\pgfmath@def{acos}{66}{86.21572} \pgfmath@def{acos}{67}{86.15830} +\pgfmath@def{acos}{68}{86.10087} \pgfmath@def{acos}{69}{86.04344} +\pgfmath@def{acos}{70}{85.98601} \pgfmath@def{acos}{71}{85.92857} +\pgfmath@def{acos}{72}{85.87113} \pgfmath@def{acos}{73}{85.81368} +\pgfmath@def{acos}{74}{85.75623} \pgfmath@def{acos}{75}{85.69877} +\pgfmath@def{acos}{76}{85.64131} \pgfmath@def{acos}{77}{85.58385} +\pgfmath@def{acos}{78}{85.52638} \pgfmath@def{acos}{79}{85.46891} +\pgfmath@def{acos}{80}{85.41143} \pgfmath@def{acos}{81}{85.35395} +\pgfmath@def{acos}{82}{85.29646} \pgfmath@def{acos}{83}{85.23897} +\pgfmath@def{acos}{84}{85.18147} \pgfmath@def{acos}{85}{85.12397} +\pgfmath@def{acos}{86}{85.06646} \pgfmath@def{acos}{87}{85.00895} +\pgfmath@def{acos}{88}{84.95144} \pgfmath@def{acos}{89}{84.89392} +\pgfmath@def{acos}{90}{84.83639} \pgfmath@def{acos}{91}{84.77886} +\pgfmath@def{acos}{92}{84.72132} \pgfmath@def{acos}{93}{84.66378} +\pgfmath@def{acos}{94}{84.60623} \pgfmath@def{acos}{95}{84.54868} +\pgfmath@def{acos}{96}{84.49112} \pgfmath@def{acos}{97}{84.43355} +\pgfmath@def{acos}{98}{84.37598} \pgfmath@def{acos}{99}{84.31841} +\pgfmath@def{acos}{100}{84.26083} \pgfmath@def{acos}{101}{84.20324} +\pgfmath@def{acos}{102}{84.14564} \pgfmath@def{acos}{103}{84.08805} +\pgfmath@def{acos}{104}{84.03044} \pgfmath@def{acos}{105}{83.97283} +\pgfmath@def{acos}{106}{83.91521} \pgfmath@def{acos}{107}{83.85759} +\pgfmath@def{acos}{108}{83.79996} \pgfmath@def{acos}{109}{83.74232} +\pgfmath@def{acos}{110}{83.68468} \pgfmath@def{acos}{111}{83.62703} +\pgfmath@def{acos}{112}{83.56938} \pgfmath@def{acos}{113}{83.51171} +\pgfmath@def{acos}{114}{83.45405} \pgfmath@def{acos}{115}{83.39637} +\pgfmath@def{acos}{116}{83.33869} \pgfmath@def{acos}{117}{83.28100} +\pgfmath@def{acos}{118}{83.22330} \pgfmath@def{acos}{119}{83.16560} +\pgfmath@def{acos}{120}{83.10789} \pgfmath@def{acos}{121}{83.05018} +\pgfmath@def{acos}{122}{82.99245} \pgfmath@def{acos}{123}{82.93472} +\pgfmath@def{acos}{124}{82.87698} \pgfmath@def{acos}{125}{82.81924} +\pgfmath@def{acos}{126}{82.76149} \pgfmath@def{acos}{127}{82.70373} +\pgfmath@def{acos}{128}{82.64596} \pgfmath@def{acos}{129}{82.58819} +\pgfmath@def{acos}{130}{82.53040} \pgfmath@def{acos}{131}{82.47261} +\pgfmath@def{acos}{132}{82.41482} \pgfmath@def{acos}{133}{82.35701} +\pgfmath@def{acos}{134}{82.29920} \pgfmath@def{acos}{135}{82.24138} +\pgfmath@def{acos}{136}{82.18355} \pgfmath@def{acos}{137}{82.12571} +\pgfmath@def{acos}{138}{82.06786} \pgfmath@def{acos}{139}{82.01001} +\pgfmath@def{acos}{140}{81.95215} \pgfmath@def{acos}{141}{81.89428} +\pgfmath@def{acos}{142}{81.83640} \pgfmath@def{acos}{143}{81.77851} +\pgfmath@def{acos}{144}{81.72062} \pgfmath@def{acos}{145}{81.66272} +\pgfmath@def{acos}{146}{81.60480} \pgfmath@def{acos}{147}{81.54688} +\pgfmath@def{acos}{148}{81.48895} \pgfmath@def{acos}{149}{81.43102} +\pgfmath@def{acos}{150}{81.37307} \pgfmath@def{acos}{151}{81.31511} +\pgfmath@def{acos}{152}{81.25715} \pgfmath@def{acos}{153}{81.19917} +\pgfmath@def{acos}{154}{81.14119} \pgfmath@def{acos}{155}{81.08320} +\pgfmath@def{acos}{156}{81.02520} \pgfmath@def{acos}{157}{80.96719} +\pgfmath@def{acos}{158}{80.90917} \pgfmath@def{acos}{159}{80.85114} +\pgfmath@def{acos}{160}{80.79310} \pgfmath@def{acos}{161}{80.73505} +\pgfmath@def{acos}{162}{80.67699} \pgfmath@def{acos}{163}{80.61893} +\pgfmath@def{acos}{164}{80.56085} \pgfmath@def{acos}{165}{80.50276} +\pgfmath@def{acos}{166}{80.44466} \pgfmath@def{acos}{167}{80.38656} +\pgfmath@def{acos}{168}{80.32844} \pgfmath@def{acos}{169}{80.27031} +\pgfmath@def{acos}{170}{80.21218} \pgfmath@def{acos}{171}{80.15403} +\pgfmath@def{acos}{172}{80.09587} \pgfmath@def{acos}{173}{80.03770} +\pgfmath@def{acos}{174}{79.97953} \pgfmath@def{acos}{175}{79.92134} +\pgfmath@def{acos}{176}{79.86314} \pgfmath@def{acos}{177}{79.80493} +\pgfmath@def{acos}{178}{79.74671} \pgfmath@def{acos}{179}{79.68848} +\pgfmath@def{acos}{180}{79.63024} \pgfmath@def{acos}{181}{79.57198} +\pgfmath@def{acos}{182}{79.51372} \pgfmath@def{acos}{183}{79.45545} +\pgfmath@def{acos}{184}{79.39716} \pgfmath@def{acos}{185}{79.33886} +\pgfmath@def{acos}{186}{79.28056} \pgfmath@def{acos}{187}{79.22224} +\pgfmath@def{acos}{188}{79.16391} \pgfmath@def{acos}{189}{79.10556} +\pgfmath@def{acos}{190}{79.04721} \pgfmath@def{acos}{191}{78.98885} +\pgfmath@def{acos}{192}{78.93047} \pgfmath@def{acos}{193}{78.87208} +\pgfmath@def{acos}{194}{78.81368} \pgfmath@def{acos}{195}{78.75527} +\pgfmath@def{acos}{196}{78.69685} \pgfmath@def{acos}{197}{78.63841} +\pgfmath@def{acos}{198}{78.57997} \pgfmath@def{acos}{199}{78.52151} +\pgfmath@def{acos}{200}{78.46304} \pgfmath@def{acos}{201}{78.40455} +\pgfmath@def{acos}{202}{78.34606} \pgfmath@def{acos}{203}{78.28755} +\pgfmath@def{acos}{204}{78.22903} \pgfmath@def{acos}{205}{78.17050} +\pgfmath@def{acos}{206}{78.11195} \pgfmath@def{acos}{207}{78.05339} +\pgfmath@def{acos}{208}{77.99482} \pgfmath@def{acos}{209}{77.93624} +\pgfmath@def{acos}{210}{77.87764} \pgfmath@def{acos}{211}{77.81903} +\pgfmath@def{acos}{212}{77.76041} \pgfmath@def{acos}{213}{77.70178} +\pgfmath@def{acos}{214}{77.64313} \pgfmath@def{acos}{215}{77.58447} +\pgfmath@def{acos}{216}{77.52579} \pgfmath@def{acos}{217}{77.46711} +\pgfmath@def{acos}{218}{77.40841} \pgfmath@def{acos}{219}{77.34969} +\pgfmath@def{acos}{220}{77.29096} \pgfmath@def{acos}{221}{77.23222} +\pgfmath@def{acos}{222}{77.17347} \pgfmath@def{acos}{223}{77.11470} +\pgfmath@def{acos}{224}{77.05591} \pgfmath@def{acos}{225}{76.99712} +\pgfmath@def{acos}{226}{76.93831} \pgfmath@def{acos}{227}{76.87948} +\pgfmath@def{acos}{228}{76.82064} \pgfmath@def{acos}{229}{76.76179} +\pgfmath@def{acos}{230}{76.70292} \pgfmath@def{acos}{231}{76.64404} +\pgfmath@def{acos}{232}{76.58515} \pgfmath@def{acos}{233}{76.52624} +\pgfmath@def{acos}{234}{76.46731} \pgfmath@def{acos}{235}{76.40837} +\pgfmath@def{acos}{236}{76.34942} \pgfmath@def{acos}{237}{76.29045} +\pgfmath@def{acos}{238}{76.23147} \pgfmath@def{acos}{239}{76.17247} +\pgfmath@def{acos}{240}{76.11346} \pgfmath@def{acos}{241}{76.05443} +\pgfmath@def{acos}{242}{75.99538} \pgfmath@def{acos}{243}{75.93632} +\pgfmath@def{acos}{244}{75.87725} \pgfmath@def{acos}{245}{75.81816} +\pgfmath@def{acos}{246}{75.75906} \pgfmath@def{acos}{247}{75.69994} +\pgfmath@def{acos}{248}{75.64080} \pgfmath@def{acos}{249}{75.58165} +\pgfmath@def{acos}{250}{75.52248} \pgfmath@def{acos}{251}{75.46330} +\pgfmath@def{acos}{252}{75.40410} \pgfmath@def{acos}{253}{75.34489} +\pgfmath@def{acos}{254}{75.28566} \pgfmath@def{acos}{255}{75.22641} +\pgfmath@def{acos}{256}{75.16715} \pgfmath@def{acos}{257}{75.10787} +\pgfmath@def{acos}{258}{75.04857} \pgfmath@def{acos}{259}{74.98926} +\pgfmath@def{acos}{260}{74.92993} \pgfmath@def{acos}{261}{74.87059} +\pgfmath@def{acos}{262}{74.81123} \pgfmath@def{acos}{263}{74.75185} +\pgfmath@def{acos}{264}{74.69245} \pgfmath@def{acos}{265}{74.63304} +\pgfmath@def{acos}{266}{74.57361} \pgfmath@def{acos}{267}{74.51417} +\pgfmath@def{acos}{268}{74.45471} \pgfmath@def{acos}{269}{74.39523} +\pgfmath@def{acos}{270}{74.33573} \pgfmath@def{acos}{271}{74.27621} +\pgfmath@def{acos}{272}{74.21668} \pgfmath@def{acos}{273}{74.15713} +\pgfmath@def{acos}{274}{74.09757} \pgfmath@def{acos}{275}{74.03798} +\pgfmath@def{acos}{276}{73.97838} \pgfmath@def{acos}{277}{73.91876} +\pgfmath@def{acos}{278}{73.85912} \pgfmath@def{acos}{279}{73.79946} +\pgfmath@def{acos}{280}{73.73979} \pgfmath@def{acos}{281}{73.68010} +\pgfmath@def{acos}{282}{73.62039} \pgfmath@def{acos}{283}{73.56066} +\pgfmath@def{acos}{284}{73.50091} \pgfmath@def{acos}{285}{73.44115} +\pgfmath@def{acos}{286}{73.38136} \pgfmath@def{acos}{287}{73.32156} +\pgfmath@def{acos}{288}{73.26174} \pgfmath@def{acos}{289}{73.20190} +\pgfmath@def{acos}{290}{73.14204} \pgfmath@def{acos}{291}{73.08216} +\pgfmath@def{acos}{292}{73.02226} \pgfmath@def{acos}{293}{72.96235} +\pgfmath@def{acos}{294}{72.90241} \pgfmath@def{acos}{295}{72.84246} +\pgfmath@def{acos}{296}{72.78248} \pgfmath@def{acos}{297}{72.72249} +\pgfmath@def{acos}{298}{72.66248} \pgfmath@def{acos}{299}{72.60244} +\pgfmath@def{acos}{300}{72.54239} \pgfmath@def{acos}{301}{72.48232} +\pgfmath@def{acos}{302}{72.42223} \pgfmath@def{acos}{303}{72.36212} +\pgfmath@def{acos}{304}{72.30198} \pgfmath@def{acos}{305}{72.24183} +\pgfmath@def{acos}{306}{72.18166} \pgfmath@def{acos}{307}{72.12147} +\pgfmath@def{acos}{308}{72.06125} \pgfmath@def{acos}{309}{72.00102} +\pgfmath@def{acos}{310}{71.94077} \pgfmath@def{acos}{311}{71.88049} +\pgfmath@def{acos}{312}{71.82019} \pgfmath@def{acos}{313}{71.75988} +\pgfmath@def{acos}{314}{71.69954} \pgfmath@def{acos}{315}{71.63918} +\pgfmath@def{acos}{316}{71.57880} \pgfmath@def{acos}{317}{71.51840} +\pgfmath@def{acos}{318}{71.45798} \pgfmath@def{acos}{319}{71.39754} +\pgfmath@def{acos}{320}{71.33707} \pgfmath@def{acos}{321}{71.27658} +\pgfmath@def{acos}{322}{71.21608} \pgfmath@def{acos}{323}{71.15555} +\pgfmath@def{acos}{324}{71.09499} \pgfmath@def{acos}{325}{71.03442} +\pgfmath@def{acos}{326}{70.97382} \pgfmath@def{acos}{327}{70.91321} +\pgfmath@def{acos}{328}{70.85257} \pgfmath@def{acos}{329}{70.79190} +\pgfmath@def{acos}{330}{70.73122} \pgfmath@def{acos}{331}{70.67051} +\pgfmath@def{acos}{332}{70.60978} \pgfmath@def{acos}{333}{70.54903} +\pgfmath@def{acos}{334}{70.48826} \pgfmath@def{acos}{335}{70.42746} +\pgfmath@def{acos}{336}{70.36664} \pgfmath@def{acos}{337}{70.30579} +\pgfmath@def{acos}{338}{70.24493} \pgfmath@def{acos}{339}{70.18404} +\pgfmath@def{acos}{340}{70.12312} \pgfmath@def{acos}{341}{70.06218} +\pgfmath@def{acos}{342}{70.00122} \pgfmath@def{acos}{343}{69.94024} +\pgfmath@def{acos}{344}{69.87923} \pgfmath@def{acos}{345}{69.81820} +\pgfmath@def{acos}{346}{69.75714} \pgfmath@def{acos}{347}{69.69606} +\pgfmath@def{acos}{348}{69.63496} \pgfmath@def{acos}{349}{69.57383} +\pgfmath@def{acos}{350}{69.51268} \pgfmath@def{acos}{351}{69.45150} +\pgfmath@def{acos}{352}{69.39030} \pgfmath@def{acos}{353}{69.32908} +\pgfmath@def{acos}{354}{69.26783} \pgfmath@def{acos}{355}{69.20655} +\pgfmath@def{acos}{356}{69.14525} \pgfmath@def{acos}{357}{69.08393} +\pgfmath@def{acos}{358}{69.02258} \pgfmath@def{acos}{359}{68.96120} +\pgfmath@def{acos}{360}{68.89980} \pgfmath@def{acos}{361}{68.83837} +\pgfmath@def{acos}{362}{68.77692} \pgfmath@def{acos}{363}{68.71544} +\pgfmath@def{acos}{364}{68.65394} \pgfmath@def{acos}{365}{68.59241} +\pgfmath@def{acos}{366}{68.53086} \pgfmath@def{acos}{367}{68.46928} +\pgfmath@def{acos}{368}{68.40767} \pgfmath@def{acos}{369}{68.34604} +\pgfmath@def{acos}{370}{68.28438} \pgfmath@def{acos}{371}{68.22269} +\pgfmath@def{acos}{372}{68.16098} \pgfmath@def{acos}{373}{68.09924} +\pgfmath@def{acos}{374}{68.03748} \pgfmath@def{acos}{375}{67.97568} +\pgfmath@def{acos}{376}{67.91386} \pgfmath@def{acos}{377}{67.85202} +\pgfmath@def{acos}{378}{67.79014} \pgfmath@def{acos}{379}{67.72824} +\pgfmath@def{acos}{380}{67.66631} \pgfmath@def{acos}{381}{67.60436} +\pgfmath@def{acos}{382}{67.54237} \pgfmath@def{acos}{383}{67.48036} +\pgfmath@def{acos}{384}{67.41832} \pgfmath@def{acos}{385}{67.35626} +\pgfmath@def{acos}{386}{67.29416} \pgfmath@def{acos}{387}{67.23204} +\pgfmath@def{acos}{388}{67.16988} \pgfmath@def{acos}{389}{67.10770} +\pgfmath@def{acos}{390}{67.04550} \pgfmath@def{acos}{391}{66.98326} +\pgfmath@def{acos}{392}{66.92099} \pgfmath@def{acos}{393}{66.85870} +\pgfmath@def{acos}{394}{66.79637} \pgfmath@def{acos}{395}{66.73402} +\pgfmath@def{acos}{396}{66.67164} \pgfmath@def{acos}{397}{66.60923} +\pgfmath@def{acos}{398}{66.54679} \pgfmath@def{acos}{399}{66.48432} +\pgfmath@def{acos}{400}{66.42182} \pgfmath@def{acos}{401}{66.35929} +\pgfmath@def{acos}{402}{66.29673} \pgfmath@def{acos}{403}{66.23414} +\pgfmath@def{acos}{404}{66.17152} \pgfmath@def{acos}{405}{66.10887} +\pgfmath@def{acos}{406}{66.04619} \pgfmath@def{acos}{407}{65.98348} +\pgfmath@def{acos}{408}{65.92074} \pgfmath@def{acos}{409}{65.85796} +\pgfmath@def{acos}{410}{65.79516} \pgfmath@def{acos}{411}{65.73233} +\pgfmath@def{acos}{412}{65.66946} \pgfmath@def{acos}{413}{65.60657} +\pgfmath@def{acos}{414}{65.54364} \pgfmath@def{acos}{415}{65.48068} +\pgfmath@def{acos}{416}{65.41769} \pgfmath@def{acos}{417}{65.35467} +\pgfmath@def{acos}{418}{65.29161} \pgfmath@def{acos}{419}{65.22853} +\pgfmath@def{acos}{420}{65.16541} \pgfmath@def{acos}{421}{65.10226} +\pgfmath@def{acos}{422}{65.03908} \pgfmath@def{acos}{423}{64.97586} +\pgfmath@def{acos}{424}{64.91261} \pgfmath@def{acos}{425}{64.84933} +\pgfmath@def{acos}{426}{64.78602} \pgfmath@def{acos}{427}{64.72267} +\pgfmath@def{acos}{428}{64.65929} \pgfmath@def{acos}{429}{64.59588} +\pgfmath@def{acos}{430}{64.53244} \pgfmath@def{acos}{431}{64.46896} +\pgfmath@def{acos}{432}{64.40544} \pgfmath@def{acos}{433}{64.34190} +\pgfmath@def{acos}{434}{64.27832} \pgfmath@def{acos}{435}{64.21470} +\pgfmath@def{acos}{436}{64.15105} \pgfmath@def{acos}{437}{64.08737} +\pgfmath@def{acos}{438}{64.02365} \pgfmath@def{acos}{439}{63.95990} +\pgfmath@def{acos}{440}{63.89611} \pgfmath@def{acos}{441}{63.83229} +\pgfmath@def{acos}{442}{63.76844} \pgfmath@def{acos}{443}{63.70455} +\pgfmath@def{acos}{444}{63.64062} \pgfmath@def{acos}{445}{63.57666} +\pgfmath@def{acos}{446}{63.51266} \pgfmath@def{acos}{447}{63.44863} +\pgfmath@def{acos}{448}{63.38456} \pgfmath@def{acos}{449}{63.32045} +\pgfmath@def{acos}{450}{63.25631} \pgfmath@def{acos}{451}{63.19213} +\pgfmath@def{acos}{452}{63.12792} \pgfmath@def{acos}{453}{63.06367} +\pgfmath@def{acos}{454}{62.99938} \pgfmath@def{acos}{455}{62.93506} +\pgfmath@def{acos}{456}{62.87070} \pgfmath@def{acos}{457}{62.80630} +\pgfmath@def{acos}{458}{62.74187} \pgfmath@def{acos}{459}{62.67740} +\pgfmath@def{acos}{460}{62.61289} \pgfmath@def{acos}{461}{62.54834} +\pgfmath@def{acos}{462}{62.48376} \pgfmath@def{acos}{463}{62.41913} +\pgfmath@def{acos}{464}{62.35447} \pgfmath@def{acos}{465}{62.28977} +\pgfmath@def{acos}{466}{62.22504} \pgfmath@def{acos}{467}{62.16026} +\pgfmath@def{acos}{468}{62.09545} \pgfmath@def{acos}{469}{62.03059} +\pgfmath@def{acos}{470}{61.96570} \pgfmath@def{acos}{471}{61.90077} +\pgfmath@def{acos}{472}{61.83580} \pgfmath@def{acos}{473}{61.77079} +\pgfmath@def{acos}{474}{61.70574} \pgfmath@def{acos}{475}{61.64065} +\pgfmath@def{acos}{476}{61.57552} \pgfmath@def{acos}{477}{61.51035} +\pgfmath@def{acos}{478}{61.44514} \pgfmath@def{acos}{479}{61.37988} +\pgfmath@def{acos}{480}{61.31459} \pgfmath@def{acos}{481}{61.24926} +\pgfmath@def{acos}{482}{61.18389} \pgfmath@def{acos}{483}{61.11847} +\pgfmath@def{acos}{484}{61.05302} \pgfmath@def{acos}{485}{60.98752} +\pgfmath@def{acos}{486}{60.92199} \pgfmath@def{acos}{487}{60.85641} +\pgfmath@def{acos}{488}{60.79078} \pgfmath@def{acos}{489}{60.72512} +\pgfmath@def{acos}{490}{60.65941} \pgfmath@def{acos}{491}{60.59367} +\pgfmath@def{acos}{492}{60.52787} \pgfmath@def{acos}{493}{60.46204} +\pgfmath@def{acos}{494}{60.39616} \pgfmath@def{acos}{495}{60.33025} +\pgfmath@def{acos}{496}{60.26428} \pgfmath@def{acos}{497}{60.19828} +\pgfmath@def{acos}{498}{60.13223} \pgfmath@def{acos}{499}{60.06613} +\pgfmath@def{acos}{500}{60.00000} \pgfmath@def{acos}{501}{59.93381} +\pgfmath@def{acos}{502}{59.86759} \pgfmath@def{acos}{503}{59.80132} +\pgfmath@def{acos}{504}{59.73500} \pgfmath@def{acos}{505}{59.66864} +\pgfmath@def{acos}{506}{59.60224} \pgfmath@def{acos}{507}{59.53579} +\pgfmath@def{acos}{508}{59.46929} \pgfmath@def{acos}{509}{59.40275} +\pgfmath@def{acos}{510}{59.33617} \pgfmath@def{acos}{511}{59.26953} +\pgfmath@def{acos}{512}{59.20285} \pgfmath@def{acos}{513}{59.13613} +\pgfmath@def{acos}{514}{59.06936} \pgfmath@def{acos}{515}{59.00254} +\pgfmath@def{acos}{516}{58.93568} \pgfmath@def{acos}{517}{58.86876} +\pgfmath@def{acos}{518}{58.80180} \pgfmath@def{acos}{519}{58.73480} +\pgfmath@def{acos}{520}{58.66774} \pgfmath@def{acos}{521}{58.60064} +\pgfmath@def{acos}{522}{58.53349} \pgfmath@def{acos}{523}{58.46629} +\pgfmath@def{acos}{524}{58.39905} \pgfmath@def{acos}{525}{58.33175} +\pgfmath@def{acos}{526}{58.26441} \pgfmath@def{acos}{527}{58.19702} +\pgfmath@def{acos}{528}{58.12957} \pgfmath@def{acos}{529}{58.06208} +\pgfmath@def{acos}{530}{57.99454} \pgfmath@def{acos}{531}{57.92695} +\pgfmath@def{acos}{532}{57.85931} \pgfmath@def{acos}{533}{57.79162} +\pgfmath@def{acos}{534}{57.72388} \pgfmath@def{acos}{535}{57.65608} +\pgfmath@def{acos}{536}{57.58824} \pgfmath@def{acos}{537}{57.52035} +\pgfmath@def{acos}{538}{57.45240} \pgfmath@def{acos}{539}{57.38441} +\pgfmath@def{acos}{540}{57.31636} \pgfmath@def{acos}{541}{57.24826} +\pgfmath@def{acos}{542}{57.18010} \pgfmath@def{acos}{543}{57.11190} +\pgfmath@def{acos}{544}{57.04364} \pgfmath@def{acos}{545}{56.97533} +\pgfmath@def{acos}{546}{56.90697} \pgfmath@def{acos}{547}{56.83855} +\pgfmath@def{acos}{548}{56.77008} \pgfmath@def{acos}{549}{56.70156} +\pgfmath@def{acos}{550}{56.63298} \pgfmath@def{acos}{551}{56.56435} +\pgfmath@def{acos}{552}{56.49567} \pgfmath@def{acos}{553}{56.42693} +\pgfmath@def{acos}{554}{56.35813} \pgfmath@def{acos}{555}{56.28928} +\pgfmath@def{acos}{556}{56.22038} \pgfmath@def{acos}{557}{56.15141} +\pgfmath@def{acos}{558}{56.08240} \pgfmath@def{acos}{559}{56.01333} +\pgfmath@def{acos}{560}{55.94420} \pgfmath@def{acos}{561}{55.87501} +\pgfmath@def{acos}{562}{55.80577} \pgfmath@def{acos}{563}{55.73647} +\pgfmath@def{acos}{564}{55.66712} \pgfmath@def{acos}{565}{55.59770} +\pgfmath@def{acos}{566}{55.52823} \pgfmath@def{acos}{567}{55.45871} +\pgfmath@def{acos}{568}{55.38912} \pgfmath@def{acos}{569}{55.31947} +\pgfmath@def{acos}{570}{55.24977} \pgfmath@def{acos}{571}{55.18001} +\pgfmath@def{acos}{572}{55.11019} \pgfmath@def{acos}{573}{55.04030} +\pgfmath@def{acos}{574}{54.97036} \pgfmath@def{acos}{575}{54.90036} +\pgfmath@def{acos}{576}{54.83030} \pgfmath@def{acos}{577}{54.76018} +\pgfmath@def{acos}{578}{54.69000} \pgfmath@def{acos}{579}{54.61976} +\pgfmath@def{acos}{580}{54.54945} \pgfmath@def{acos}{581}{54.47909} +\pgfmath@def{acos}{582}{54.40866} \pgfmath@def{acos}{583}{54.33817} +\pgfmath@def{acos}{584}{54.26762} \pgfmath@def{acos}{585}{54.19701} +\pgfmath@def{acos}{586}{54.12633} \pgfmath@def{acos}{587}{54.05559} +\pgfmath@def{acos}{588}{53.98479} \pgfmath@def{acos}{589}{53.91392} +\pgfmath@def{acos}{590}{53.84299} \pgfmath@def{acos}{591}{53.77199} +\pgfmath@def{acos}{592}{53.70093} \pgfmath@def{acos}{593}{53.62981} +\pgfmath@def{acos}{594}{53.55862} \pgfmath@def{acos}{595}{53.48736} +\pgfmath@def{acos}{596}{53.41604} \pgfmath@def{acos}{597}{53.34466} +\pgfmath@def{acos}{598}{53.27320} \pgfmath@def{acos}{599}{53.20168} +\pgfmath@def{acos}{600}{53.13010} \pgfmath@def{acos}{601}{53.05844} +\pgfmath@def{acos}{602}{52.98672} \pgfmath@def{acos}{603}{52.91494} +\pgfmath@def{acos}{604}{52.84308} \pgfmath@def{acos}{605}{52.77115} +\pgfmath@def{acos}{606}{52.69916} \pgfmath@def{acos}{607}{52.62710} +\pgfmath@def{acos}{608}{52.55497} \pgfmath@def{acos}{609}{52.48276} +\pgfmath@def{acos}{610}{52.41049} \pgfmath@def{acos}{611}{52.33815} +\pgfmath@def{acos}{612}{52.26574} \pgfmath@def{acos}{613}{52.19326} +\pgfmath@def{acos}{614}{52.12070} \pgfmath@def{acos}{615}{52.04808} +\pgfmath@def{acos}{616}{51.97538} \pgfmath@def{acos}{617}{51.90261} +\pgfmath@def{acos}{618}{51.82976} \pgfmath@def{acos}{619}{51.75685} +\pgfmath@def{acos}{620}{51.68386} \pgfmath@def{acos}{621}{51.61080} +\pgfmath@def{acos}{622}{51.53766} \pgfmath@def{acos}{623}{51.46445} +\pgfmath@def{acos}{624}{51.39117} \pgfmath@def{acos}{625}{51.31781} +\pgfmath@def{acos}{626}{51.24437} \pgfmath@def{acos}{627}{51.17086} +\pgfmath@def{acos}{628}{51.09728} \pgfmath@def{acos}{629}{51.02361} +\pgfmath@def{acos}{630}{50.94987} \pgfmath@def{acos}{631}{50.87606} +\pgfmath@def{acos}{632}{50.80216} \pgfmath@def{acos}{633}{50.72819} +\pgfmath@def{acos}{634}{50.65414} \pgfmath@def{acos}{635}{50.58001} +\pgfmath@def{acos}{636}{50.50580} \pgfmath@def{acos}{637}{50.43152} +\pgfmath@def{acos}{638}{50.35715} \pgfmath@def{acos}{639}{50.28270} +\pgfmath@def{acos}{640}{50.20818} \pgfmath@def{acos}{641}{50.13357} +\pgfmath@def{acos}{642}{50.05888} \pgfmath@def{acos}{643}{49.98411} +\pgfmath@def{acos}{644}{49.90926} \pgfmath@def{acos}{645}{49.83432} +\pgfmath@def{acos}{646}{49.75930} \pgfmath@def{acos}{647}{49.68420} +\pgfmath@def{acos}{648}{49.60902} \pgfmath@def{acos}{649}{49.53375} +\pgfmath@def{acos}{650}{49.45839} \pgfmath@def{acos}{651}{49.38296} +\pgfmath@def{acos}{652}{49.30743} \pgfmath@def{acos}{653}{49.23182} +\pgfmath@def{acos}{654}{49.15613} \pgfmath@def{acos}{655}{49.08035} +\pgfmath@def{acos}{656}{49.00448} \pgfmath@def{acos}{657}{48.92852} +\pgfmath@def{acos}{658}{48.85248} \pgfmath@def{acos}{659}{48.77634} +\pgfmath@def{acos}{660}{48.70012} \pgfmath@def{acos}{661}{48.62381} +\pgfmath@def{acos}{662}{48.54741} \pgfmath@def{acos}{663}{48.47092} +\pgfmath@def{acos}{664}{48.39434} \pgfmath@def{acos}{665}{48.31767} +\pgfmath@def{acos}{666}{48.24091} \pgfmath@def{acos}{667}{48.16405} +\pgfmath@def{acos}{668}{48.08710} \pgfmath@def{acos}{669}{48.01006} +\pgfmath@def{acos}{670}{47.93293} \pgfmath@def{acos}{671}{47.85570} +\pgfmath@def{acos}{672}{47.77838} \pgfmath@def{acos}{673}{47.70096} +\pgfmath@def{acos}{674}{47.62345} \pgfmath@def{acos}{675}{47.54585} +\pgfmath@def{acos}{676}{47.46814} \pgfmath@def{acos}{677}{47.39034} +\pgfmath@def{acos}{678}{47.31244} \pgfmath@def{acos}{679}{47.23445} +\pgfmath@def{acos}{680}{47.15635} \pgfmath@def{acos}{681}{47.07816} +\pgfmath@def{acos}{682}{46.99987} \pgfmath@def{acos}{683}{46.92147} +\pgfmath@def{acos}{684}{46.84298} \pgfmath@def{acos}{685}{46.76439} +\pgfmath@def{acos}{686}{46.68569} \pgfmath@def{acos}{687}{46.60690} +\pgfmath@def{acos}{688}{46.52800} \pgfmath@def{acos}{689}{46.44899} +\pgfmath@def{acos}{690}{46.36989} \pgfmath@def{acos}{691}{46.29068} +\pgfmath@def{acos}{692}{46.21136} \pgfmath@def{acos}{693}{46.13194} +\pgfmath@def{acos}{694}{46.05241} \pgfmath@def{acos}{695}{45.97278} +\pgfmath@def{acos}{696}{45.89304} \pgfmath@def{acos}{697}{45.81319} +\pgfmath@def{acos}{698}{45.73323} \pgfmath@def{acos}{699}{45.65317} +\pgfmath@def{acos}{700}{45.57299} \pgfmath@def{acos}{701}{45.49271} +\pgfmath@def{acos}{702}{45.41231} \pgfmath@def{acos}{703}{45.33180} +\pgfmath@def{acos}{704}{45.25118} \pgfmath@def{acos}{705}{45.17045} +\pgfmath@def{acos}{706}{45.08961} \pgfmath@def{acos}{707}{45.00865} +\pgfmath@def{acos}{708}{44.92757} \pgfmath@def{acos}{709}{44.84638} +\pgfmath@def{acos}{710}{44.76508} \pgfmath@def{acos}{711}{44.68366} +\pgfmath@def{acos}{712}{44.60212} \pgfmath@def{acos}{713}{44.52046} +\pgfmath@def{acos}{714}{44.43869} \pgfmath@def{acos}{715}{44.35680} +\pgfmath@def{acos}{716}{44.27478} \pgfmath@def{acos}{717}{44.19265} +\pgfmath@def{acos}{718}{44.11039} \pgfmath@def{acos}{719}{44.02802} +\pgfmath@def{acos}{720}{43.94552} \pgfmath@def{acos}{721}{43.86289} +\pgfmath@def{acos}{722}{43.78014} \pgfmath@def{acos}{723}{43.69727} +\pgfmath@def{acos}{724}{43.61427} \pgfmath@def{acos}{725}{43.53115} +\pgfmath@def{acos}{726}{43.44790} \pgfmath@def{acos}{727}{43.36452} +\pgfmath@def{acos}{728}{43.28101} \pgfmath@def{acos}{729}{43.19737} +\pgfmath@def{acos}{730}{43.11360} \pgfmath@def{acos}{731}{43.02970} +\pgfmath@def{acos}{732}{42.94567} \pgfmath@def{acos}{733}{42.86151} +\pgfmath@def{acos}{734}{42.77721} \pgfmath@def{acos}{735}{42.69278} +\pgfmath@def{acos}{736}{42.60821} \pgfmath@def{acos}{737}{42.52351} +\pgfmath@def{acos}{738}{42.43867} \pgfmath@def{acos}{739}{42.35370} +\pgfmath@def{acos}{740}{42.26858} \pgfmath@def{acos}{741}{42.18333} +\pgfmath@def{acos}{742}{42.09793} \pgfmath@def{acos}{743}{42.01240} +\pgfmath@def{acos}{744}{41.92672} \pgfmath@def{acos}{745}{41.84090} +\pgfmath@def{acos}{746}{41.75493} \pgfmath@def{acos}{747}{41.66882} +\pgfmath@def{acos}{748}{41.58257} \pgfmath@def{acos}{749}{41.49617} +\pgfmath@def{acos}{750}{41.40962} \pgfmath@def{acos}{751}{41.32292} +\pgfmath@def{acos}{752}{41.23607} \pgfmath@def{acos}{753}{41.14908} +\pgfmath@def{acos}{754}{41.06193} \pgfmath@def{acos}{755}{40.97463} +\pgfmath@def{acos}{756}{40.88717} \pgfmath@def{acos}{757}{40.79956} +\pgfmath@def{acos}{758}{40.71180} \pgfmath@def{acos}{759}{40.62388} +\pgfmath@def{acos}{760}{40.53580} \pgfmath@def{acos}{761}{40.44756} +\pgfmath@def{acos}{762}{40.35916} \pgfmath@def{acos}{763}{40.27061} +\pgfmath@def{acos}{764}{40.18189} \pgfmath@def{acos}{765}{40.09300} +\pgfmath@def{acos}{766}{40.00396} \pgfmath@def{acos}{767}{39.91474} +\pgfmath@def{acos}{768}{39.82537} \pgfmath@def{acos}{769}{39.73582} +\pgfmath@def{acos}{770}{39.64611} \pgfmath@def{acos}{771}{39.55622} +\pgfmath@def{acos}{772}{39.46617} \pgfmath@def{acos}{773}{39.37594} +\pgfmath@def{acos}{774}{39.28554} \pgfmath@def{acos}{775}{39.19496} +\pgfmath@def{acos}{776}{39.10421} \pgfmath@def{acos}{777}{39.01328} +\pgfmath@def{acos}{778}{38.92218} \pgfmath@def{acos}{779}{38.83089} +\pgfmath@def{acos}{780}{38.73942} \pgfmath@def{acos}{781}{38.64777} +\pgfmath@def{acos}{782}{38.55594} \pgfmath@def{acos}{783}{38.46392} +\pgfmath@def{acos}{784}{38.37171} \pgfmath@def{acos}{785}{38.27932} +\pgfmath@def{acos}{786}{38.18673} \pgfmath@def{acos}{787}{38.09396} +\pgfmath@def{acos}{788}{38.00100} \pgfmath@def{acos}{789}{37.90784} +\pgfmath@def{acos}{790}{37.81448} \pgfmath@def{acos}{791}{37.72093} +\pgfmath@def{acos}{792}{37.62719} \pgfmath@def{acos}{793}{37.53324} +\pgfmath@def{acos}{794}{37.43909} \pgfmath@def{acos}{795}{37.34474} +\pgfmath@def{acos}{796}{37.25019} \pgfmath@def{acos}{797}{37.15542} +\pgfmath@def{acos}{798}{37.06046} \pgfmath@def{acos}{799}{36.96528} +\pgfmath@def{acos}{800}{36.86989} \pgfmath@def{acos}{801}{36.77429} +\pgfmath@def{acos}{802}{36.67848} \pgfmath@def{acos}{803}{36.58245} +\pgfmath@def{acos}{804}{36.48621} \pgfmath@def{acos}{805}{36.38974} +\pgfmath@def{acos}{806}{36.29305} \pgfmath@def{acos}{807}{36.19615} +\pgfmath@def{acos}{808}{36.09901} \pgfmath@def{acos}{809}{36.00165} +\pgfmath@def{acos}{810}{35.90406} \pgfmath@def{acos}{811}{35.80625} +\pgfmath@def{acos}{812}{35.70820} \pgfmath@def{acos}{813}{35.60991} +\pgfmath@def{acos}{814}{35.51139} \pgfmath@def{acos}{815}{35.41263} +\pgfmath@def{acos}{816}{35.31364} \pgfmath@def{acos}{817}{35.21440} +\pgfmath@def{acos}{818}{35.11491} \pgfmath@def{acos}{819}{35.01518} +\pgfmath@def{acos}{820}{34.91520} \pgfmath@def{acos}{821}{34.81497} +\pgfmath@def{acos}{822}{34.71449} \pgfmath@def{acos}{823}{34.61375} +\pgfmath@def{acos}{824}{34.51276} \pgfmath@def{acos}{825}{34.41150} +\pgfmath@def{acos}{826}{34.30999} \pgfmath@def{acos}{827}{34.20821} +\pgfmath@def{acos}{828}{34.10616} \pgfmath@def{acos}{829}{34.00385} +\pgfmath@def{acos}{830}{33.90126} \pgfmath@def{acos}{831}{33.79840} +\pgfmath@def{acos}{832}{33.69526} \pgfmath@def{acos}{833}{33.59184} +\pgfmath@def{acos}{834}{33.48814} \pgfmath@def{acos}{835}{33.38416} +\pgfmath@def{acos}{836}{33.27989} \pgfmath@def{acos}{837}{33.17533} +\pgfmath@def{acos}{838}{33.07047} \pgfmath@def{acos}{839}{32.96532} +\pgfmath@def{acos}{840}{32.85988} \pgfmath@def{acos}{841}{32.75413} +\pgfmath@def{acos}{842}{32.64807} \pgfmath@def{acos}{843}{32.54171} +\pgfmath@def{acos}{844}{32.43504} \pgfmath@def{acos}{845}{32.32806} +\pgfmath@def{acos}{846}{32.22076} \pgfmath@def{acos}{847}{32.11314} +\pgfmath@def{acos}{848}{32.00520} \pgfmath@def{acos}{849}{31.89693} +\pgfmath@def{acos}{850}{31.78833} \pgfmath@def{acos}{851}{31.67939} +\pgfmath@def{acos}{852}{31.57012} \pgfmath@def{acos}{853}{31.46051} +\pgfmath@def{acos}{854}{31.35056} \pgfmath@def{acos}{855}{31.24026} +\pgfmath@def{acos}{856}{31.12961} \pgfmath@def{acos}{857}{31.01860} +\pgfmath@def{acos}{858}{30.90724} \pgfmath@def{acos}{859}{30.79551} +\pgfmath@def{acos}{860}{30.68341} \pgfmath@def{acos}{861}{30.57095} +\pgfmath@def{acos}{862}{30.45811} \pgfmath@def{acos}{863}{30.34489} +\pgfmath@def{acos}{864}{30.23128} \pgfmath@def{acos}{865}{30.11729} +\pgfmath@def{acos}{866}{30.00291} \pgfmath@def{acos}{867}{29.88813} +\pgfmath@def{acos}{868}{29.77294} \pgfmath@def{acos}{869}{29.65736} +\pgfmath@def{acos}{870}{29.54136} \pgfmath@def{acos}{871}{29.42494} +\pgfmath@def{acos}{872}{29.30810} \pgfmath@def{acos}{873}{29.19084} +\pgfmath@def{acos}{874}{29.07315} \pgfmath@def{acos}{875}{28.95502} +\pgfmath@def{acos}{876}{28.83645} \pgfmath@def{acos}{877}{28.71743} +\pgfmath@def{acos}{878}{28.59796} \pgfmath@def{acos}{879}{28.47803} +\pgfmath@def{acos}{880}{28.35763} \pgfmath@def{acos}{881}{28.23677} +\pgfmath@def{acos}{882}{28.11542} \pgfmath@def{acos}{883}{27.99360} +\pgfmath@def{acos}{884}{27.87128} \pgfmath@def{acos}{885}{27.74847} +\pgfmath@def{acos}{886}{27.62516} \pgfmath@def{acos}{887}{27.50134} +\pgfmath@def{acos}{888}{27.37700} \pgfmath@def{acos}{889}{27.25214} +\pgfmath@def{acos}{890}{27.12675} \pgfmath@def{acos}{891}{27.00082} +\pgfmath@def{acos}{892}{26.87434} \pgfmath@def{acos}{893}{26.74731} +\pgfmath@def{acos}{894}{26.61973} \pgfmath@def{acos}{895}{26.49157} +\pgfmath@def{acos}{896}{26.36283} \pgfmath@def{acos}{897}{26.23351} +\pgfmath@def{acos}{898}{26.10359} \pgfmath@def{acos}{899}{25.97306} +\pgfmath@def{acos}{900}{25.84193} \pgfmath@def{acos}{901}{25.71017} +\pgfmath@def{acos}{902}{25.57778} \pgfmath@def{acos}{903}{25.44475} +\pgfmath@def{acos}{904}{25.31106} \pgfmath@def{acos}{905}{25.17671} +\pgfmath@def{acos}{906}{25.04169} \pgfmath@def{acos}{907}{24.90598} +\pgfmath@def{acos}{908}{24.76958} \pgfmath@def{acos}{909}{24.63247} +\pgfmath@def{acos}{910}{24.49464} \pgfmath@def{acos}{911}{24.35608} +\pgfmath@def{acos}{912}{24.21678} \pgfmath@def{acos}{913}{24.07672} +\pgfmath@def{acos}{914}{23.93588} \pgfmath@def{acos}{915}{23.79427} +\pgfmath@def{acos}{916}{23.65185} \pgfmath@def{acos}{917}{23.50863} +\pgfmath@def{acos}{918}{23.36457} \pgfmath@def{acos}{919}{23.21967} +\pgfmath@def{acos}{920}{23.07391} \pgfmath@def{acos}{921}{22.92728} +\pgfmath@def{acos}{922}{22.77975} \pgfmath@def{acos}{923}{22.63132} +\pgfmath@def{acos}{924}{22.48195} \pgfmath@def{acos}{925}{22.33164} +\pgfmath@def{acos}{926}{22.18036} \pgfmath@def{acos}{927}{22.02810} +\pgfmath@def{acos}{928}{21.87483} \pgfmath@def{acos}{929}{21.72053} +\pgfmath@def{acos}{930}{21.56518} \pgfmath@def{acos}{931}{21.40876} +\pgfmath@def{acos}{932}{21.25124} \pgfmath@def{acos}{933}{21.09260} +\pgfmath@def{acos}{934}{20.93281} \pgfmath@def{acos}{935}{20.77185} +\pgfmath@def{acos}{936}{20.60969} \pgfmath@def{acos}{937}{20.44630} +\pgfmath@def{acos}{938}{20.28165} \pgfmath@def{acos}{939}{20.11570} +\pgfmath@def{acos}{940}{19.94844} \pgfmath@def{acos}{941}{19.77982} +\pgfmath@def{acos}{942}{19.60981} \pgfmath@def{acos}{943}{19.43837} +\pgfmath@def{acos}{944}{19.26546} \pgfmath@def{acos}{945}{19.09105} +\pgfmath@def{acos}{946}{18.91509} \pgfmath@def{acos}{947}{18.73754} +\pgfmath@def{acos}{948}{18.55835} \pgfmath@def{acos}{949}{18.37748} +\pgfmath@def{acos}{950}{18.19487} \pgfmath@def{acos}{951}{18.01047} +\pgfmath@def{acos}{952}{17.82423} \pgfmath@def{acos}{953}{17.63609} +\pgfmath@def{acos}{954}{17.44598} \pgfmath@def{acos}{955}{17.25385} +\pgfmath@def{acos}{956}{17.05962} \pgfmath@def{acos}{957}{16.86322} +\pgfmath@def{acos}{958}{16.66457} \pgfmath@def{acos}{959}{16.46359} +\pgfmath@def{acos}{960}{16.26020} \pgfmath@def{acos}{961}{16.05430} +\pgfmath@def{acos}{962}{15.84580} \pgfmath@def{acos}{963}{15.63459} +\pgfmath@def{acos}{964}{15.42057} \pgfmath@def{acos}{965}{15.20360} +\pgfmath@def{acos}{966}{14.98357} \pgfmath@def{acos}{967}{14.76033} +\pgfmath@def{acos}{968}{14.53374} \pgfmath@def{acos}{969}{14.30364} +\pgfmath@def{acos}{970}{14.06986} \pgfmath@def{acos}{971}{13.83221} +\pgfmath@def{acos}{972}{13.59049} \pgfmath@def{acos}{973}{13.34447} +\pgfmath@def{acos}{974}{13.09392} \pgfmath@def{acos}{975}{12.83856} +\pgfmath@def{acos}{976}{12.57811} \pgfmath@def{acos}{977}{12.31225} +\pgfmath@def{acos}{978}{12.04060} \pgfmath@def{acos}{979}{11.76278} +\pgfmath@def{acos}{980}{11.47834} \pgfmath@def{acos}{981}{11.18676} +\pgfmath@def{acos}{982}{10.88748} \pgfmath@def{acos}{983}{10.57984} +\pgfmath@def{acos}{984}{10.26309} \pgfmath@def{acos}{985}{9.93636} +\pgfmath@def{acos}{986}{9.59863} \pgfmath@def{acos}{987}{9.24870} +\pgfmath@def{acos}{988}{8.88512} \pgfmath@def{acos}{989}{8.50614} +\pgfmath@def{acos}{990}{8.10961} \pgfmath@def{acos}{991}{7.69281} +\pgfmath@def{acos}{992}{7.25224} \pgfmath@def{acos}{993}{6.78328} +\pgfmath@def{acos}{994}{6.27958} \pgfmath@def{acos}{995}{5.73196} +\pgfmath@def{acos}{996}{5.12640} \pgfmath@def{acos}{997}{4.43922} +\pgfmath@def{acos}{998}{3.62430} \pgfmath@def{acos}{999}{2.56255} +\pgfmath@def{acos}{1000}{0.00000} + + + +% Local Variables: +% tab-width: 2 +% End: diff --git a/graphics/pgf/base/tex/generic/math/pgfmathode.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathode.code.tex new file mode 100644 index 0000000000..f072c2361e --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathode.code.tex @@ -0,0 +1,178 @@ +% Copyright 2019 by Christophe Jorssen +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +\def\pgfmathode@stopadd{\pgfmathode@stopadd} + +\def\pgfmathode@addindextofunc[#1]#2{% + \begingroup + \gdef\pgfmathode@func{}% + \pgfmathode@addindextofunc@i[#1]#2\pgfmathode@stopadd} + +\def\pgfmathode@addindextofunc@i[#1]#2#3{% + \ifx#1#2 + \expandafter\gdef\expandafter\pgfmathode@func\expandafter{% + \pgfmathode@func #2[\pgfmathode@timeindex]}% + \else + \expandafter\gdef\expandafter\pgfmathode@func\expandafter{% + \pgfmathode@func #2}% + \fi + \ifx#3\pgfmathode@stopadd + \expandafter\gdef\expandafter\pgfmathode@func\expandafter{% + \expandafter{\pgfmathode@func}}% + \let\next\endgroup + \else + \def\next{\pgfmathode@addindextofunc@i[#1]#3}% + \fi + \next} + +%********************************************************************** +% Know limitation: fk cannot be a time function. Should be possible to +% use \Sol[0] as time in the set of equations. +%********************************************************************** + +% Numerically solve a differential system with 1st order Runge-Kutta +% (Euler method) +% dq1/dt = f1(t,q1,q2,...,qN) +% dq2/dt = f2(t,q1,q2,...,qN) +% ... +% dqN/dt = fN(t,q1,q2,...,qN) +% +% #1: A pgf array where the solution will be stored. +% At the end: +% #1 -> {{t(0),q1(t(0)),q2(t(0)),...,qN(t(0))}, +% {t(1),q1(t(1)),q2(t(1)),...,qN(t(1))}, +% ... +% {t(Nstep),q1(t(Nstep)),q2(t(Nstep)),...,qN(t(Nstep))}} +% #2: A pgf array with f1,f2,...,fN +% {f1} +% #3: A pgf array with initial conditions. +% {t(0),q1(t(0)),q2(t(0)),...,qN(t(0))} +% #4: t(Nstep) +% #5: Nstep (number of steps) +% +% * First order example: dq/dt = -q + 5 with IC=(t=0,q(0)=0) +% \pgfmathodeRKI{\Sol}{{-\Sol[1]+5}}{{0,0}}{3.5}{100} +% * Second order example: {dq1/dt=q2, dq2/dt=-q2/2-sin(q1)} (damped +% pendulum) +% \pgfmathodeRKI{\Sol}{{\Sol[2],-\Sol[2]/2-sin(deg(\Sol[1]))}}% +% {{0,-1,5}}{15}{50} + +\def\pgfmathode@generic@init@RK{% + \begingroup + % Sol array (#1) first element is given by the set of initial + % conditions (#3). We need to enclose it in brace so that is a now + % a "matrix" array. + \gdef#1{{#3}}% + % The set of rhs {f1(t,q1,q2,...,qN),...,fN(t,q1,q2,...,qN)} is + % given in terms of #1[0],#1[1],...,#1[N]. We need to transform to + % #1[\pgfmathode@timeindex][0],...,#1[\pgfmathode@timeindex][N], that is + % add [\pgfmathode@timeindex] after every occurrence of #1 in #2. + % No need to brace #2 since it is already surrounded by braces. The + % result is stored in \pgfmathode@func + \pgfmathode@addindextofunc[#1]#2% + % Set time step. Actually the number of time steps is #5-1, so we + % divide by (#5-1)+1 = #5. + \pgfmathsetmacro\pgfmathode@Sol@t{#1[0][0]}% + \pgfmathsetmacro\pgfmathode@Deltat{(#4-\pgfmathode@Sol@t)/#5}% + % Compute the order of the system: it is equal to the number of IC + % minus one (time). + \pgfmathsetmacro\pgfmathode@dimfunc{dim(#3)-1}% + \pgfmathsetmacro\pgfmathode@numstep{#5-1}} + +\def\pgfmathodeRKI#1#2#3#4#5{% + \pgfmathode@generic@init@RK + % Start the time loop for Runge-Kutta 1st order + \foreach \pgfmathode@timeindex in {0,...,\pgfmathode@numstep} {% + \message{Step \pgfmathode@timeindex...}% + % Start the function loop + \foreach \pgfmathode@funcindex in {1,...,\pgfmathode@dimfunc} {% + % The RKI algorithm + % qk[t(i)] = Deltat*fk(t(i-1),q1(t(i-1)),...qN(t(i-1))) + + % qk[t(i-1)] + % Note: this part can be really slow due to array management in + % pgfmath. + % TODO: find a better way (at least inside this loop) + \pgfmathparse{% + \pgfmathode@Deltat*(\pgfmathode@func[\pgfmathode@funcindex-1])+ + #1[\pgfmathode@timeindex][\pgfmathode@funcindex]}% + % Store the result in a helper macro + \expandafter\xdef\csname pgfmathode@Sol@\pgfmathode@funcindex + \endcsname{\pgfmathresult}% + } + % Store step i + \pgfmathparse{\pgfmathode@Sol@t+\pgfmathode@Deltat}% + \xdef\pgfmathode@Sol@t{\pgfmathresult}% + \xdef\pgfmathode@temp{}% + \foreach \pgfmathode@funcindex in {1,...,\pgfmathode@dimfunc} {% + \ifx\pgfmathode@temp\pgfutil@empty + \xdef\pgfmathode@temp{% + \csname pgfmathode@Sol@\pgfmathode@funcindex\endcsname}% + \else + \xdef\pgfmathode@temp{% + \pgfmathode@temp, + \csname pgfmathode@Sol@\pgfmathode@funcindex\endcsname}% + \fi} + \xdef#1{% + {\expandafter\pgfutil@firstofone#1,% + {\pgfmathode@Sol@t,\pgfmathode@temp}}}% + } + \endgroup} + +% RKIV: far from working yet! +\def\pgfmathodeRKIV#1#2#3#4#5{% + \pgfmathode@generic@init@RK + % Start the time loop for Runge-Kutta 4th order + \foreach \pgfmathode@timeindex in {0,...,\pgfmathode@numstep} {% + \message{Step \pgfmathode@timeindex...}% + % Start the function loop + \foreach \pgfmathode@funcindex in {1,...,\pgfmathode@dimfunc} {% + % The RKIV algorithm + % qk[t(i)] = qk[t(i-1)] + + % (1/6) * (j1k + 2j2k + 2j3k + j4k) + % where j1k = fk(t(i-1),q1(t(i-1)),...qN(t(i-1))) * Deltat + % j2k = fk(t(i-1)+.5*Deltat, + % q1(t(i-1))+.5*j11,...qN(t(i-1))+.5*j1N) * Deltat + % j3k = fk(t(i-1)+.5*Deltat, + % q1(t(i-1))+.5*j21,...qN(t(i-1))+.5*j2N) * Deltat + % j4k = fk(t(i-1)+Deltat, + % q1(t(i-1))+j31,...qN(t(i-1))+j3N) * Deltat + % + % Compute j1k + \pgfmathparse{% + \pgfmathode@Deltat*(\pgfmathode@func[\pgfmathode@funcindex-1])+ + #1[\pgfmathode@timeindex][\pgfmathode@funcindex]}% + \expandafter\xdef\csname pgfmathode@RKIV@1@\pgfmathode@funcindex + \endcsname{\pgfmathresult}% + % Compute j2k + \pgfmathparse{% + \pgfmathode@Deltat*(\pgfmathode@func[\pgfmathode@funcindex-1])+ + #1[\pgfmathode@timeindex][\pgfmathode@funcindex]}% + \expandafter\xdef\csname pgfmathode@RKIV@1@\pgfmathode@funcindex + \endcsname{\pgfmathresult}% + } + % Store step i + \pgfmathparse{\pgfmathode@Sol@t+\pgfmathode@Deltat}% + \xdef\pgfmathode@Sol@t{\pgfmathresult}% + \xdef\pgfmathode@temp{}% + \foreach \pgfmathode@funcindex in {1,...,\pgfmathode@dimfunc} {% + \ifx\pgfmathode@temp\pgfutil@empty + \xdef\pgfmathode@temp{% + \csname pgfmathode@Sol@\pgfmathode@funcindex\endcsname}% + \else + \xdef\pgfmathode@temp{% + \pgfmathode@temp, + \csname pgfmathode@Sol@\pgfmathode@funcindex\endcsname}% + \fi} + \xdef#1{% + {\expandafter\pgfutil@firstofone#1,% + {\pgfmathode@Sol@t,\pgfmathode@temp}}}% + } + \endgroup} + + +\endinput diff --git a/graphics/pgf/base/tex/generic/math/pgfmathparser.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathparser.code.tex new file mode 100644 index 0000000000..8a560ff114 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathparser.code.tex @@ -0,0 +1,1017 @@ + +\newdimen\pgfmath@dimen +\newcount\pgfmath@count +\newbox\pgfmath@box +\newtoks\pgfmath@toks + +\newif\ifpgfmath@quickparse +\newif\ifpgfmathfloat +\newif\ifpgfmathunitsdeclared +\newif\ifpgfmathmathunitsdeclared +\newif\ifpgfmathignoreunitscale + +\let\pgfmath@protected@edef=\edef +\ifcsname protected@edef\endcsname + \let\pgfmath@protected@edef=\protected@edef +\fi + +\def\pgfmathprint#1{\pgfmathparse{#1}\pgfmathresult} + +\def\pgfmathparse{% + \begingroup + \pgfmath@catcodes + \pgfmath@quickparsefalse + % Test for the fpu library + \ifpgfmathfloat + \let\pgfmath@parse@next=\pgfmathfloatparsenumber + \else + \let\pgfmath@parse@next=\pgfmathparse@ + \fi + \pgfmath@parse@next} + +\begingroup + \lccode`\~=`\" + \lowercase{\endgroup + \def\pgfmath@catcodes{% + \catcode`\==12 % + \catcode`\,=12 % + \catcode`\|=12 % + \catcode`\&=12 % + \let~\pgfmath@char@quote + }}% + +\def\pgfmathqparse{% + \begingroup + \pgfmath@catcodes + \pgfmath@quickparsetrue + \pgfmathparse@} + +\def\pgfmathparse@#1{% + % No (math) units yet. + \global\pgfmathunitsdeclaredfalse + \global\pgfmathmathunitsdeclaredfalse + % Expand expression so any remaining CSs are registers + % or box dimensions (i.e. |\wd|, |\ht|, |\dp|). + \pgfmath@protected@edef\pgfmath@expression{#1}% + % + \expandafter\pgfmathparse@trynumber@loop\pgfmath@expression\pgfmath@parse@stop + % + % this here is the _real_ parser. it is invoked by + % \pgfmathparse@trynumber@loop if that says "this is no number" + %\pgfmathparse@@\pgfmath@parse@stop% +} + +\def\pgfmath@parse@stop{\pgfmath@parse@stop}% equals only itself + +\def\pgfmathparse@trynumber@token{numeric} +\begingroup +\def\\{\global\let\pgf@let@space@token= } \\ % now, \pgf@let@space@token is a space token +\endgroup + +% This a "fast-lane": if the expressions consist merely of number +% tokens, we can simply return the number as-is. +% +% This is significantly faster and should resemble the 80% use-case. +% +% #1 a single token +\def\pgfmathparse@trynumber@loop{% + \futurelet\pgfmath@token@let\pgfmathparse@trynumber@loop@ +}% +\def\pgfmathparse@trynumber@loop@#1{% + \ifx\pgfmath@token@let\pgf@let@space@token + % Hm. we found a white space... and we have no support for + % trimming. That means we have to assume that the white space + % occurred somewhere in the middle - and fall back to the + % expensive method. + \def\pgfmath@parse@next{\pgfmathparse@@#1}% + \else + \ifx\pgfmath@token@let\bgroup% + % oh! We found '{' #1. + % Well, these braces appear to be special; fall back to + % the complicated routine... + \let\pgfmath@parse@next=\pgfmathparse@@ + \else + \ifx\pgfmath@token@let\pgfmath@parse@stop + % Ah: we have passed the check! The expression consists only + % of 0123456789. , so do not parse anything and return it + % as-is! + \let\pgfmath@parse@next=\pgfmathparse@expression@is@number + \else + \expandafter\ifx\csname pgfmath@token@\pgfmathparse@trynumber@token @\string#1\endcsname\relax% + % hm. It is none of 0123456789. + \let\pgfmath@parse@next=\pgfmathparse@@ + \else + % continue... we only found one of 0123456789. so + % far... + \let\pgfmath@parse@next=\pgfmathparse@trynumber@loop + \fi + \fi + \fi + \fi + \pgfmath@parse@next +}% + +\def\pgfmathparse@expression@is@number{% + \let\pgfmathresult=\pgfmath@expression + \pgfmath@smuggleone\pgfmathresult% + \endgroup + \ignorespaces +}% +\def\pgfmathparse@@#1\pgfmath@parse@stop{% + % We are inside a group (opened in |\pgfmathparse| or + % |\pgfmathqparse|). + % Stuff for calc compatibility. + \let\real=\pgfmath@calc@real + \let\minof=\pgfmath@calc@minof + \let\maxof=\pgfmath@calc@maxof + \let\ratio=\pgfmath@calc@ratio + \let\widthof=\pgfmath@calc@widthof + \let\heightof=\pgfmath@calc@heightof + \let\depthof=\pgfmath@calc@depthof + % Restore font (defined in pgfmathutil.code.tex) + \pgfmath@selectfont + % Set up stack. + \pgfmath@stack@operation={{}{}{}}% + \pgfmath@stack@operand={{}{}{}}% + \let\pgfmath@stack@operation@top=\pgfmath@stack@empty + \let\pgfmath@stack@operand@top=\pgfmath@stack@empty + % An expression always begins with an operand. + \expandafter\pgfmath@bgroup@strip\expandafter{\pgfmath@expression}% + % |\pgfmath@bgroup@stripped| is the result of + % |\pgfmath@bgroup@strip| + \expandafter\pgfmath@parse@@operand\pgfmath@bgroup@stripped @@@@\pgfmath@parse@stop% +} + +\def\pgfmath@parse@end#1\pgfmath@parse@stop{% + \pgfmathpostparse + \pgfmath@smuggleone\pgfmathresult% + \endgroup + \ignorespaces} + +\let\pgfmathpostparse=\relax + +% For compatibility with older version. +% +\def\pgfmathscaleresult{% + \ifpgfmathunitsdeclared + \else + \ifpgfmathignoreunitscale + \else + \afterassignment\pgfmath@gobbletilpgfmath@% + \pgfmath@x\pgfmathresultunitscale pt\relax\pgfmath@% + \expandafter\pgfmath@x\pgfmathresult\pgfmath@x% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}% + \fi + \fi +} + +\def\pgfmathsetresultunitscale#1{\def\pgfmathresultunitscale{#1}} + +\def\pgfmathresultunitscale{1} + + +% A utility function which evaluates expression '#1' and invokes '#2' +% if the expression is true and '#3' if it is false. +\def\pgfmathifexpression#1#2#3{% + \pgfmathparse{#1}% + \pgfmath@iftrue{#2}{#3}% +}% +% Executes '#1' if \pgfmathresult is 'true', '#2' otherwise. +% WARNING : overwritten in fpu lib! +\def\pgfmath@iftrue{% + \ifdim\pgfmathresult pt=1.0pt % + \let\pgfmath@next=\pgfutil@firstoftwo + \else + \let\pgfmath@next=\pgfutil@secondoftwo + \fi + \pgfmath@next% +}% + +% Stuff for computability with the calc package. +% +\def\pgfmath@calc@real#1{#1} +\def\pgfmath@calc@minof#1#2{min(#1,#2)} +\def\pgfmath@calc@maxof#1#2{max(#1,#2)} +\def\pgfmath@calc@ratio#1#2{#1/#2} +\def\pgfmath@calc@widthof#1{width("#1")} +\def\pgfmath@calc@heightof#1{height("#1")} +\def\pgfmath@calc@depthof#1{depth("#1")} + +\def\pgfmath@bgroup{\string\pgfmath@bgroup} +\def\pgfmath@egroup{\string\pgfmath@egroup} +\def\pgfmath@egroup@token{\pgfmath@egroup} + +\def\pgfmath@text@@{@} +\def\pgfmath@text@operator{operator} +\def\pgfmath@text@function{function} +\def\pgfmath@dots{...} +\def\pgfmath@char@zero{0} +\def\pgfmath@char@quote{"} +\def\pgfmath@char@exclamation{!} +\def\pgfmath@char@plus{+} +\def\pgfmath@char@minus{-} +\def\pgfmath@char@period{.} +\def\pgfmath@char@leftangle{<} +\def\pgfmath@char@leftbracket{[} +\pgfmath@toks={#} +\edef\pgfmath@char@hash{\the\pgfmath@toks} + +\def\pgfmath@tokens@make#1#2{% + % Defines for each token or balanced text in |#2| a control sequence + % |\pgfmath@token@<#1>@\string<one token from #2>| and stores |#2| + % in it. + \def\pgfmath@prefix{#1}% + % Note the empty group |{}| at the end that ends the loop in + % |\pgfmath@token@@make|. + \expandafter\pgfmath@tokens@@make#2{}} + +\def\pgfmath@tokens@@make#1{% + \def\pgfmath@token{#1}% + \ifx\pgfmath@token\pgfmath@empty + % End of loop: all tokens or balanced texts were parsed. + \else + \pgfmath@namedef{pgfmath@token@\pgfmath@prefix @\string#1}{#1}% + \expandafter\pgfmath@tokens@@make% + \fi} + +\pgfmath@tokens@make{box}{\wd\ht\dp} +\ifx\dimexpr\@undefined\else % needed for classic tex + \pgfmath@tokens@make{dimexpr}{\dimexpr\glueexpr} +\fi +\pgfmath@tokens@make{unit}{{bp}{cc}{cm}{dd}{em}{ex}{in}{mm}{pc}{pt}{sp}} +\ifx\pdftexversion\@undefined\else % for pdfTeX + \pgfmath@tokens@make{unit}{{nc}{nd}{px}} +\fi +\ifx\directlua\@undefined\else % for LuaTeX + \pgfmath@tokens@make{unit}{{nc}{nd}{px}} +\fi +\ifx\kanjiskip\@undefined\else % for pTeX, upTeX + \pgfmath@tokens@make{unit}{{H}{Q}{zh}{zw}} +\fi +% +\pgfmath@tokens@make{mathunit}{{mu}} +\pgfmath@tokens@make{numeric}{.0123456789} +\pgfmath@tokens@make{number}{0123456789} +\pgfmath@tokens@make{functional}{_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ} +\pgfmath@tokens@make{exponent}{eE} +\pgfmath@tokens@make{group}{{()}{[]}{\pgfmath@bgroup\pgfmath@egroup}} +\pgfmath@tokens@make{specials}{@)]\pgfmath@egroup} +\pgfmath@tokens@make{hexadecimal}{0123456789ABCDEFabcdef} +\pgfmath@tokens@make{octal}{01234567} +\pgfmath@tokens@make{binary}{01} + +\pgfmath@namedef{pgfmath@base@0x}{16} +\pgfmath@namedef{pgfmath@base@0X}{16} +\pgfmath@namedef{pgfmath@base@0b}{2} +\pgfmath@namedef{pgfmath@base@0B}{2} + +% Determine if a register is a count or a dimension/skip register. +\newif\ifpgfmath@dimen@ +\def\pgfmath@dimen@#1{% + \begingroup + \afterassignment\pgfmath@dimen@@% + #1=0.0pt\relax\pgfmath@} +\def\pgfmath@dimen@@#1#2\pgfmath@{% + \endgroup + \ifx#1.% + \pgfmath@dimen@false + \else + \pgfmath@dimen@true + \fi} + +\def\pgfmath@parse@ifbgroup#1#2{% + \let\pgfmath@parse@bgroup@after=#1% + \let\pgfmath@parse@nobgroup@after=#2% + \futurelet\pgfmath@token@let% + \pgfmath@parse@@ifbgroup} + +\def\pgfmath@parse@@ifbgroup{% + \ifx\pgfmath@token@let\bgroup + \let\pgfmath@parse@next=\pgfmath@parse@@@ifbgroup + \else + % |\pgfmath@sptoken| defined in \file{pgfmathutil.code.tex}. + \ifx\pgfmath@token@let\pgfmath@sptoken + \let\pgfmath@parse@next=\pgfmath@parse@@@@ifbgroup + \else + \let\pgfmath@parse@next=\pgfmath@parse@nobgroup@after + \fi + \fi + \pgfmath@parse@next} + +% TT: If false, octal parsing is switched off (needed for time parsing) +\newif\ifpgfmath@octalparsing +\pgfmath@octalparsingtrue + +% I (CJ) *think* it replaces |{| and |}| by |\pgfmath@bgroup| and +% |\pgfmath@egroup|? +\def\pgfmath@parse@@@ifbgroup#1{% + \pgfmath@parse@bgroup@after\pgfmath@bgroup#1\pgfmath@egroup} + +{ +\def\:{\pgfmath@parse@@@@ifbgroup} +\expandafter\gdef\: {\futurelet\pgfmath@token@let\pgfmath@parse@@ifbgroup} +} + +% Parse an operand. +\def\pgfmath@parse@operand{% + \expandafter\pgfmath@parse@@operand\pgfmath@token@next} + +% This is the entry point for the parser. It is called at the end of +% |\pgfmathparse@| with the following syntax +% |\expandafter\pgfmath@parse@@operand\pgfmath@bgroup@stripped +% @@@@\pgfmath@parse@stop|. +% Note: we are inside a group. +\def\pgfmath@parse@@operand{% + \pgfmath@parse@ifbgroup{\pgfmath@parse@@operand}{\pgfmath@parse@@operand@}} + +% An operand is +% * |+| (unary plus), +% * |-| (unary minus), +% * a prefix operator +\def\pgfmath@parse@@operand@#1{% + \def\pgfmath@token{#1}% + \ifx\pgfmath@token\pgfmath@char@plus + % Unary (prefix) plus + \let\pgfmath@parse@next=\pgfmath@parse@@operand% + \else + \ifx\pgfmath@token\pgfmath@char@minus + % Unary (prefix) minus + \pgfmath@stack@push@operation{neg}% + \let\pgfmath@parse@next=\pgfmath@parse@@operand + \else + % See |\pgfmathdeclareoperator| (below). Note that |+| and |-| + % that are also declared as operators have been tested before so + % they should never be parsed as binary (infix) operator at this stage. + \expandafter\ifx\csname pgfmath@operation@\expandafter\string\pgfmath@token @prefix\endcsname\pgfmath@token + \let\pgfmath@parse@next=\pgfmath@parse@prefix@operator + \else + \ifpgfmath@quickparse + \let\pgfmath@parse@next=\pgfmath@qparse@operand + \else + \let\pgfmath@number=\pgfmath@empty + \expandafter\ifx\csname pgfmath@token@functional@\string#1\endcsname\relax% + \let\pgfmath@base=\pgfmath@empty% + \let\pgfmath@token@next=\pgfmath@token% + \if#10% Check for octal prefix. + \ifpgfmath@octalparsing% + \def\pgfmath@base{8}% + \fi% + \fi% + \let\pgfmath@parse@next=\pgfmath@parse@number% + \else% + \let\pgfmath@function=\pgfmath@token% + \let\pgfmath@parse@next=\pgfmath@parse@function% + \fi% + \fi% + \fi% + \fi% + \fi% + \pgfmath@parse@next% +} + +% Parse prefix operators. +% +\def\pgfmath@parse@prefix@operator{% + \ifx\pgfmath@token\pgfmath@char@quote% Quote character. + \let\pgfmath@parse@next=\pgfmath@parse@operand@quote% + \else% + \ifx\pgfmath@token\pgfmath@char@exclamation% Prefix !. + \pgfmath@stack@push@operation{not}% + \let\pgfmath@parse@next=\pgfmath@parse@@operand% + \else% Anything else, just push and hope. + \expandafter\pgfmath@stack@push@operation\expandafter{\pgfmath@token}% + \let\pgfmath@parse@next=\pgfmath@parse@@operand% + \fi% + \fi% + \pgfmath@parse@next% +}% + + +% Quote part of an expression. +% +\def\pgfmath@parse@operand@quote#1"{% + \def\pgfmathresult{#1}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +} + +% Quick operand parsing. Should always have units. +% No functions, base conversion, quoting or scientific notation +% are permitted. +\def\pgfmath@qparse@operand{% + \afterassignment\pgfmath@qparse@@operand% + \pgfmath@dimen\pgfmath@token} +\def\pgfmath@qparse@@operand{% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +} + +% Parse a number, which can take the form: +% +% 1. An integer, or a decimal, with or without units. +% 2. A dimension/skip or a count register. +% 3. A dimension register preceded by a number or count register. +% 4. A box dimension (e.g., \wd\mybox). +% 5. A box dimension preceded by a number or a count register. +% 6. Scientific notation (e.g., 1.234567e-10). +% 7. A binary, hexadecimal, or octal number. +% +\def\pgfmath@parse@number{\pgfmath@parse@ifbgroup{\pgfmath@parse@number}{\pgfmath@parse@number@}} +\def\pgfmath@parse@number@#1{% + \let\pgfmath@token=\pgfmath@token@next% + \def\pgfmath@token@next{#1}% + \pgfmath@parse@@number} + +\def\pgfmath@parse@@number{% + \ifx\pgfmath@token\pgfmath@egroup@token% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmath@number}% + \let\pgfmath@parse@next=\pgfmath@parse@@@operator% + \else% + \expandafter\ifcat\pgfmath@token\relax% A CS? + \expandafter\ifx\csname pgfmath@token@dimexpr@\expandafter\string\pgfmath@token\endcsname\relax% + \expandafter\ifx\pgfmath@token\numexpr% + \let\pgfmath@parse@next=\pgfmath@parse@numexpr% + \else% + \expandafter\ifx\pgfmath@token\muexpr% + \let\pgfmath@parse@next=\pgfmath@parse@muexpr% + \else% + \expandafter\ifx\csname pgfmath@token@box@\expandafter\string\pgfmath@token\endcsname\relax% + % So, is the CS is a dimension or a count register? + \expandafter\pgfmath@dimen@\pgfmath@token% + \ifpgfmath@dimen@% A dimension register. + \global\pgfmathunitsdeclaredtrue% + \pgfmath@dimen=\pgfmath@number\pgfmath@token% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@operator% + \else% A count register. + \pgfmath@count=\pgfmath@token% + \expandafter\def\expandafter\pgfmath@number\expandafter{\the\pgfmath@count}% + \expandafter\ifcat\pgfmath@token@next\relax% + % A CS following a count register should be \wd, \ht or \dp. + \let\pgfmath@parse@next=\pgfmath@parse@number% + \else% + \let\pgfmathresult=\pgfmath@number% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@operator% + \fi% + \fi% + \else% + % This should be a box specification, for example, 0.5\wd\mybox. + \global\pgfmathunitsdeclaredtrue% + \pgfmath@dimen=\pgfmath@number\pgfmath@token\pgfmath@token@next% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@@operator% + \fi% + \fi% + \fi% + \else% + \global\pgfmathunitsdeclaredtrue% + \let\pgfmath@parse@next=\pgfmath@parse@dimexpr% + \fi% + \else% + \expandafter\ifx\csname pgfmath@token@numeric@\expandafter\string\pgfmath@token\endcsname\relax% + % It isn't numeric (i.e., 012345679.), so it might be units... + % first double-character units... + \expandafter\ifx\csname pgfmath@token@unit@\pgfmath@token\expandafter\string\pgfmath@token@next\endcsname\relax% + % then single-character units... + \expandafter\ifx\csname pgfmath@token@unit@\pgfmath@token\endcsname\relax% + % ...or the exponent characters... + \expandafter\ifx\csname pgfmath@token@exponent@\pgfmath@token\endcsname\relax% + % ...or a base prefix... + \expandafter\ifx\csname pgfmath@base@\pgfmath@number\pgfmath@token\endcsname\relax% + % ...or a math unit... + \expandafter\ifx\csname pgfmath@token@mathunit@\pgfmath@token\expandafter\string\pgfmath@token@next\endcsname\relax% + % ...none of the above... + \ifx\pgfmath@base\pgfmath@empty% + \let\pgfmathresult=\pgfmath@number% + \else% + \ifx\pgfmath@number\pgfmath@char@zero% + \let\pgfmathresult=\pgfmath@number% + \else% + % Convert from octal. + \expandafter\pgfmathbasetobase\expandafter\pgfmathresult\expandafter{\pgfmath@number}{8}{10}% + \fi% + \fi% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@@@operator% + \else% + % ...here, it is a math unit (mu). Treat it as a pt. + \global\pgfmathunitsdeclaredtrue% + \global\pgfmathmathunitsdeclaredtrue% + \pgfmath@dimen=\pgfmath@number pt\relax% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@@operator% + \fi% + \else% + % ...here, it is a base prefix 0x, 0X, 0b or 0B + \expandafter\let\expandafter\pgfmath@base\expandafter=% + \csname pgfmath@base@\pgfmath@number\pgfmath@token\endcsname% + \let\pgfmath@parse@next=\pgfmath@parse@base% + \fi% + \else% ... and here, it is the exponent characters. + \let\pgfmath@parse@next=\pgfmath@parse@exponent% + \fi% + \else% ...but here it is single-character units. + \global\pgfmathunitsdeclaredtrue% + \pgfmath@dimen=\pgfmath@number\pgfmath@token\relax% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@@operator% + \fi% + \else% ...but here it is double-character units. + \global\pgfmathunitsdeclaredtrue% + \pgfmath@dimen=\pgfmath@number\pgfmath@token\pgfmath@token@next\relax% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@@operator% + \fi% + \else% It is numeric. + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfmath@number% + \expandafter\expandafter\expandafter{\expandafter\pgfmath@number\pgfmath@token}% + \ifx\pgfmath@token\pgfmath@char@period% + \let\pgfmath@base=\pgfmath@empty% + \fi% + \let\pgfmath@parse@next=\pgfmath@parse@number% + \fi% + \fi% + \fi% + \pgfmath@parse@next% +} + + +% Parse a \dimexpr +\def\pgfmath@parse@dimexpr{% + \afterassignment\pgfmath@parse@dimexpr@% + \expandafter\expandafter\expandafter\pgfmath@dimen\expandafter\pgfmath@token\pgfmath@token@next% +} +\def\pgfmath@parse@dimexpr@{% + \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@dimen}}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +} + + +% Parse a \muexpr +\def\pgfmath@parse@muexpr{% + \begingroup% + \afterassignment\pgfmath@parse@muexpr@% + \expandafter\expandafter\expandafter\muskip\expandafter\expandafter\expandafter0\expandafter\pgfmath@token\expandafter\pgfmath@token@next% +} +\def\pgfmath@parse@muexpr@{% + \expandafter\endgroup% + \expandafter\edef\expandafter\pgfmathresult\expandafter{\expandafter\pgfMATH@STRIPMU\the\muskip0}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +} + +{ +\catcode`\m=12 +\catcode`\u=12 +\gdef\pgfMATH@STRIPMU#1mu{#1} +} + + +% Parse a \numexpr +\def\pgfmath@parse@numexpr{% + \afterassignment\pgfmath@parse@numexpr@% + \expandafter\expandafter\expandafter\pgfmath@count\expandafter\pgfmath@token\pgfmath@token@next% +} +\def\pgfmath@parse@numexpr@#1{% + \expandafter\def\expandafter\pgfmath@number\expandafter{\the\pgfmath@count}% + \def\pgfmath@token@next{#1}% + \expandafter\ifcat\pgfmath@token@next\relax% + % A CS following a count register should be \wd, \ht or \dp. + \let\pgfmath@parse@next=\pgfmath@parse@number% + \else% + \let\pgfmathresult=\pgfmath@number% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@operator% + \fi% + \pgfmath@parse@next% +} + + +% Parse the exponent of a number. +% +% REMARK: this method will be overwritten by the FPU library. Please +% keep changes consistent... +\def\pgfmath@parse@exponent{% + \afterassignment\pgfmath@parse@@exponent% + \pgfmath@count\pgfmath@token@next} +\def\pgfmath@parse@@exponent{% + \pgfmathscientific{\pgfmath@number}{\the\pgfmath@count}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +} + +% Parse binary or hexadecimal numbers (octal numbers done elsewhere). +% +\def\pgfmath@parse@base{% + \ifnum\pgfmath@base=2\relax% + \let\pgfmath@parse@next=\pgfmath@parse@binary% + \else% + \ifnum\pgfmath@base=16\relax% + \let\pgfmath@parse@next=\pgfmath@parse@hexadecimal% + \else% + \pgfmath@error{Unexpected numerical base `\pgfmath@base'}{}% + \def\pgfmathresult{0}% + \let\pgfmath@parse@next=\pgfmath@parse@end% + \fi% + \fi% + \let\pgfmath@number=\pgfmath@empty% + \expandafter\pgfmath@parse@next\pgfmath@token@next% +} + +\def\pgfmath@parse@binary#1{% + \expandafter\ifx\csname pgfmath@token@binary@#1\endcsname\relax% + \expandafter\pgfmathbasetobase\expandafter\pgfmathresult\expandafter{\pgfmath@number}{2}{10}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \def\pgfmath@token@next{#1}% + \let\pgfmath@parse@next=\pgfmath@parse@operator% + \else% + \expandafter\def\expandafter\pgfmath@number\expandafter{\pgfmath@number#1}% + \let\pgfmath@parse@next=\pgfmath@parse@binary% + \fi% + \pgfmath@parse@next% +} + +\def\pgfmath@parse@hexadecimal#1{% + \expandafter\ifx\csname pgfmath@token@hexadecimal@#1\endcsname\relax% + \expandafter\pgfmathbasetobase\expandafter\pgfmathresult\expandafter{\pgfmath@number}{16}{10}% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \def\pgfmath@token@next{#1}% + \let\pgfmath@parse@next=\pgfmath@parse@operator% + \else% + \expandafter\def\expandafter\pgfmath@number\expandafter{\pgfmath@number#1}% + \let\pgfmath@parse@next=\pgfmath@parse@hexadecimal% + \fi% + \pgfmath@parse@next% +} + +% Parse a function. +% +\def\pgfmath@parse@function{\pgfmath@parse@ifbgroup{\pgfmath@parse@function}{\pgfmath@parse@@function}} +\def\pgfmath@parse@function@{\futurelet\pgfmath@token@let\pgfmath@parse@@function} +\def\pgfmath@parse@@function{% + \ifx\pgfmath@token@let\pgfmath@sptoken% + \let\pgfmath@token=\pgfmath@empty% + \let\pgfmath@parse@next=\pgfmath@parse@@@@function% + \else% + \let\pgfmath@parse@next=\pgfmath@parse@@@function% + \fi% + \pgfmath@parse@next} + +\def\pgfmath@parse@@@function#1{% + \expandafter\ifx\csname pgfmath@token@functional@\expandafter\string#1\endcsname\relax% + \expandafter\ifx\csname pgfmath@token@number@\expandafter\string#1\endcsname\relax% + \def\pgfmath@token{#1}% Not from A-Z, a-z, 0-9, or _. + \let\pgfmath@parse@next=\pgfmath@parse@@@@function% + \else% It is from 0-9. + \expandafter\def\expandafter\pgfmath@function\expandafter{\pgfmath@function#1}% + \let\pgfmath@parse@next=\pgfmath@parse@function@% + \fi% + \else% It is from A-Z, a-z, or _. + \edef\pgfmath@function{\pgfmath@function#1}% + \let\pgfmath@parse@next=\pgfmath@parse@function@% + \fi% + \pgfmath@parse@next} + +\def\pgfmath@parse@@@@function{% + \expandafter\ifx\csname pgfmath@function@\pgfmath@function\endcsname\relax% + \pgfmath@error{Unknown function `\pgfmath@function'}{}% + \def\pgfmathresult{0}% + \let\pgfmath@parse@next=\pgfmath@parse@end% + \else% + \expandafter\ifnum\csname pgfmath@operation@\pgfmath@function @arity\endcsname=0\relax% + % Functions with zero arity are called directly. + \csname pgfmath\pgfmath@function @\endcsname% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \let\pgfmath@parse@next=\pgfmath@parse@@operator% + \else% Otherwise, they are pushed onto the operator stack + \expandafter\pgfmath@stack@push@operation\expandafter{\pgfmath@function}% + \let\pgfmath@parse@next=\pgfmath@parse@@operand% + \fi% + \fi% + \expandafter\pgfmath@parse@next\pgfmath@token} + +% Parse an operator. +% +\def\pgfmath@parse@operator{\pgfmath@parse@ifbgroup{\pgfmath@parse@operator}{\pgfmath@parse@operator@}}% +\def\pgfmath@parse@operator@#1{% Get one token. + \let\pgfmath@token=\pgfmath@token@next% + \def\pgfmath@token@next{#1}% + \pgfmath@parse@@@operator} + +\def\pgfmath@parse@@operator{\pgfmath@parse@ifbgroup{\pgfmath@parse@@operator}{\pgfmath@parse@@operator@}}% +\def\pgfmath@parse@@operator@#1{% Get first token... + \def\pgfmath@token{#1}% + \pgfmath@parse@ifbgroup{\pgfmath@parse@@operator@@}{\pgfmath@parse@@operator@@}}% +\def\pgfmath@parse@@operator@@#1{% ...and second token. + \def\pgfmath@token@next{#1}% + \pgfmath@parse@@@operator} + +\def\pgfmath@parse@@@operator{% + \expandafter\ifx\csname pgfmath@operator@\pgfmath@token\expandafter\string\pgfmath@token@next\endcsname\relax% + % Not a double character operator. + \expandafter\ifx\csname pgfmath@operator@\pgfmath@token\endcsname\relax% + % Not a single character operator. + \pgfmath@error{Unknown operator `\pgfmath@token' or `\pgfmath@token\pgfmath@token@next'}{}% + \def\pgfmathresult{0}% + \let\pgfmath@parse@next=\pgfmath@parse@end% + \else% + \expandafter\pgfmath@operation@process\expandafter{\pgfmath@token}% + \ifx\pgfmath@token\pgfmath@text@@% + \let\pgfmath@parse@next=\pgfmath@parse@end% + \else% + \expandafter\ifx\csname pgfmath@operation@\pgfmath@token @postfix\endcsname\pgfmath@token% + % Postfix operators are followed by an operator. + \ifx\pgfmath@token@next\pgfmath@char@leftbracket% Except [. + \let\pgfmath@parse@next=\pgfmath@parse@operand% + \else% + \let\pgfmath@parse@next=\pgfmath@parse@operator% + \fi% + \else% + % Any other operator is followed by an operand. + \let\pgfmath@parse@next=\pgfmath@parse@operand% + \fi% + \fi% + \fi% + \else% + % A double character operator... + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% + \pgfmath@token\expandafter\expandafter\expandafter% + {\expandafter\pgfmath@token\pgfmath@token@next}% + \expandafter\pgfmath@operation@process\expandafter{\pgfmath@token}% + % ...is always followed by an operand. + \let\pgfmath@parse@next=\pgfmath@parse@@operand% + \fi% + \pgfmath@parse@next% +} + + +% Process an operation. +% +\def\pgfmath@operation@process#1{% + \def\pgfmath@operator{#1}% + \ifx\pgfmath@stack@operation@top\pgfmath@stack@empty% + \else% + \pgfmath@operation@@process% + \fi% + \expandafter\ifx\csname pgfmath@token@specials@#1\endcsname\relax% + \pgfmath@stack@push@operation{#1}% + \fi% +} + +% Process the operation stack. +% +\def\pgfmath@operation@@process{% + \ifx\pgfmath@stack@operation@top\pgfmath@stack@empty% + \let\pgfmath@parse@next=\relax% + \else% + \ifnum\csname pgfmath@operation@\pgfmath@operator @precedence\endcsname>% + \csname pgfmath@operation@\pgfmath@stack@operation@top @precedence\endcsname\relax% + % If the precedence of the scanned operator is greater than the + % precedence of the operator at the top of the stack, do nothing. + \let\pgfmath@parse@next=\relax% + \else% + \let\pgfmath@stack@operation@last=\pgfmath@stack@operation@top% + \expandafter\ifx\csname pgfmath@operator@\pgfmath@stack@operation@top\endcsname\relax% + \pgfmath@function@@@process% + \else% + \pgfmath@operator@@@process% + \fi% + \expandafter\pgfmath@stack@push@operand\expandafter{\pgfmathresult}% + \expandafter\ifx\csname pgfmath@token@group@\pgfmath@stack@operation@last\pgfmath@operator\endcsname\relax% + \let\pgfmath@parse@next=\pgfmath@operation@@process% + \else% + \let\pgfmath@parse@next=\relax% + \fi% + \fi% + \fi% + \pgfmath@parse@next% +} + +% Process an operator. +% +\def\pgfmath@operator@@@process{% Process an operator. + \pgfmath@stack@pop@operation\pgfmath@@operator% + \pgfmath@stack@pop@operand\pgfmath@operand@a% + \ifcase\csname pgfmath@operation@\pgfmath@@operator @arity\endcsname\relax% + % Zero arity operators (!). + \or% + \pgfmath@operator@@@@process{\pgfmath@operand@a}% + \or% + \pgfmath@stack@pop@operand\pgfmath@operand@b% + \pgfmath@operator@@@@process{\pgfmath@operand@b}{\pgfmath@operand@a}% + \or% + \pgfmath@stack@pop@operand\pgfmath@operand@b% + \expandafter\pgfmath@operator@@@@process\expandafter% + {\expandafter\pgfmath@operand@b\expandafter}\pgfmath@operand@a% + \else% + % No operators with more than tenary arity. + \fi% +} + +\def\pgfmath@operator@@@@process{% + \csname pgfmath% + \csname pgfmath@operation@\pgfmath@@operator @name\endcsname% + @\endcsname} + +% Process a function. +% +\def\pgfmath@function@@@process{% Process a function. + \ifnum\csname pgfmath@operation@\pgfmath@stack@operation@top @arity\endcsname>0\relax% + \pgfmath@stack@pop@operation\pgfmath@@function% + \pgfmath@stack@pop@operand\pgfmath@@operand% + \ifnum\csname pgfmath@operation@\pgfmath@@function @arity\endcsname>1\relax% + \ifnum\csname pgfmath@operation@\pgfmath@@function @arity\endcsname>9\relax% + \csname pgfmath\pgfmath@@function @\endcsname{\pgfmath@@operand}% + \else% + \expandafter\pgfmath@function@@@@process\pgfmath@@operand% + \fi + \else% + \expandafter\pgfmath@function@@@@process\expandafter{\pgfmath@@operand}% + \fi% + \fi% +} + +\def\pgfmath@function@@@@process{\csname pgfmath\pgfmath@@function @\endcsname} + +% Stack. +% +\newtoks\pgfmath@stack@operand +\newtoks\pgfmath@stack@operation +\let\pgfmath@stack@empty=\pgfmath@empty + +\def\pgfmath@stack@push#1#2{% + \def\pgfmath@stack@top{#2}% + \expandafter\expandafter\expandafter#1% + \expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter% + {\expandafter\pgfmath@stack@top\expandafter}\the#1}}% + +\def\pgfmath@stack@pop#1#2{\expandafter\pgfmath@stack@@pop\the#1\pgfmath@stack@stop{#1}{#2}} +\def\pgfmath@stack@@pop#1#2#3\pgfmath@stack@stop#4#5{\def#5{#1}#4={{#2}#3}\def\pgfmath@stack@top{#2}} + +\def\pgfmath@stack@push@operation#1{% + \pgfmath@stack@push\pgfmath@stack@operation{#1}% + \let\pgfmath@stack@operation@top=\pgfmath@stack@top} + +\def\pgfmath@stack@pop@operation#1{% + \pgfmath@stack@pop\pgfmath@stack@operation{#1}% + \let\pgfmath@stack@operation@top=\pgfmath@stack@top} + +% REMARK: This method will be overwritten by the FPU library. Please +% keep any changes consistent. +\def\pgfmath@stack@push@operand#1{% + \pgfmath@stack@push\pgfmath@stack@operand{#1}% + \let\pgfmath@stack@operand@top=\pgfmath@stack@top} + +\def\pgfmath@stack@pop@operand#1{% + \pgfmath@stack@pop\pgfmath@stack@operand{#1}% + \let\pgfmath@stack@operand@top=\pgfmath@stack@top} + + +% Declare an operator for the parser. +% +% It is not recommended that new operators be created as +% the parser is not fully robust for arbitrary operators. +% +\def\pgfmathdeclareoperator#1#2#3#4#5{% + \ifx\pgfmath@operatorlist\pgfutil@empty + \edef\pgfmath@operatorlist{{\string#1}}% + \else + \edef\pgfmath@operatorlist{\pgfmath@operatorlist,{\string#1}}% + \fi + \pgfmath@namedef{pgfmath@operator@\string#1}{#1}% + \pgfmath@namedef{pgfmath@operation@\string#1@name}{#2}% + \pgfmath@namedef{pgfmath@operation@\string#1@arity}{#3}% + \pgfmath@namedef{pgfmath@operation@\string#1@#4}{#1}% + \pgfmath@namedef{pgfmath@operation@\string#1@precedence}{#5}% +} + +\def\pgfmath@operatorlist{} + +\pgfmathdeclareoperator{+}{add} {2}{infix}{500} +\pgfmathdeclareoperator{-}{subtract}{2}{infix}{500} +\pgfmathdeclareoperator{*}{multiply}{2}{infix}{700} +\pgfmathdeclareoperator{/}{divide} {2}{infix}{700} +\pgfmathdeclareoperator{^}{pow} {2}{infix}{900} + +\pgfmathdeclareoperator{<} {} {1}{prefix} {1} + +\pgfmathdeclareoperator{>} {greater} {2}{infix} {250} +\pgfmathdeclareoperator{<} {less} {2}{infix} {250} +\pgfmathdeclareoperator{==}{equal} {2}{infix} {250} +\pgfmathdeclareoperator{>=}{notless} {2}{infix} {250} +\pgfmathdeclareoperator{<=}{notgreater}{2}{infix} {250} +\pgfmathdeclareoperator{&&}{and} {2}{infix} {200} +\pgfmathdeclareoperator{||}{or} {2}{infix} {200} +\pgfmathdeclareoperator{!=}{notequal} {2}{infix} {250} +\pgfmathdeclareoperator{!} {not} {1}{prefix}{975} +\pgfmathdeclareoperator{?} {ifthenelse}{3}{infix} {100} +\pgfmathdeclareoperator{:} {@@collect} {2}{infix}{101} + +\pgfmathdeclareoperator{!}{factorial}{1}{postfix}{800}% Must be defined after prefix ! operator. +\pgfmathdeclareoperator{r}{deg} {1}{postfix}{600} + +\pgfmathdeclareoperator{,}{@collect} {2}{infix} {10} +\pgfmathdeclareoperator{[}{@startindex}{2}{prefix} {7} +\pgfmathdeclareoperator{]}{@endindex} {0}{postfix}{6} +\pgfmathdeclareoperator{(}{@startgroup}{1}{prefix} {5} +\pgfmathdeclareoperator{)}{@endgroup} {0}{postfix}{4} + +\pgfmathdeclareoperator{\pgfmath@bgroup}{@startarray}{1}{prefix} {3} +\pgfmathdeclareoperator{\pgfmath@egroup}{@endarray} {1}{postfix}{2}% + +% Special operators. +\pgfmathdeclareoperator{"}{}{1}{prefix}{1} +\pgfmathdeclareoperator{@}{}{0}{postfix}{0} + +% Internal functions. + +% Begin and end parenthesis (). +% +\def\pgfmath@startgroup@#1{\pgfmath@protected@edef\pgfmathresult{#1}} +\def\pgfmath@endgroup@{}% Never actually called. + +% Begin and end array access []. +% +\def\pgfmath@startindex@#1#2{% + \expandafter\pgfmatharray@#1{#2}% + \expandafter\pgfmath@bgroup@strip\expandafter{\pgfmathresult}% + \ifx\pgfmath@token@let\bgroup% + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter{\pgfmathresult}}% + \fi} +\def\pgfmath@endindex@{}% Never actually called. + +% Begin and end array {}. +% +\def\pgfmath@startarray@#1{\expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter{#1}}} +\def\pgfmath@endarray@#1{\expandafter\def\expandafter\pgfmathresult\expandafter{#1}}% Never actually called. + + +\def\pgfmath@@collect@#1#2{% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% + \pgfmathresult\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter% + {\expandafter#1\expandafter}\expandafter{#2}}% +} +% Collect items separated by ,. +% +\def\pgfmath@collect@#1#2{% + \expandafter\def\expandafter\pgfmath@collect@original\expandafter{#1}% + \expandafter\pgfmath@bgroup@strip\expandafter{#1}% + \ifx\pgfmath@token@let\bgroup% + \ifx\pgfmath@collect@original\pgfmath@bgroup@stripped% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmath@bgroup@stripped}% + \else% + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter{\pgfmath@bgroup@stripped}}% + \fi% + \else% + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter{\pgfmath@bgroup@stripped}}% + \fi% + \expandafter\pgfmath@bgroup@strip\expandafter{#2}% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% + \pgfmathresult\expandafter\expandafter\expandafter% + {\expandafter\pgfmathresult\expandafter{\pgfmath@bgroup@stripped}}% +} + +% Strip braces from a token sequence. +% +\def\pgfmath@bgroup@strip#1{% + \def\pgfmath@bgroup@strip@last{#1}% + \pgfmath@bgroup@@strip{#1}\pgfmath@\pgfmath@@\pgfmath@@@} + +\def\pgfmath@bgroup@strip@#1{% + \def\pgfmath@bgroup@strip@last{#1}% + \pgfmath@bgroup@@strip#1\pgfmath@\pgfmath@@\pgfmath@@@} + +\def\pgfmath@bgroup@pgfmath@{\pgfmath@} + +\def\pgfmath@bgroup@@strip{% + \futurelet\pgfmath@token@let\pgfmath@bgroup@@@strip} + +\def\pgfmath@bgroup@@@strip#1#2#3\pgfmath@@@{% + \ifx\pgfmath@token@let\bgroup + \def\pgfmath@bgroup@test{#2}% + \ifx\pgfmath@bgroup@test\pgfmath@bgroup@pgfmath@ + \def\pgfmath@next{\pgfmath@bgroup@strip@{#1}}% + \else + \let\pgfmath@bgroup@stripped=\pgfmath@bgroup@strip@last + \let\pgfmath@next=\relax + \fi + \else + \pgfmath@bgroup@@@@strip#1#2#3% + \let\pgfmath@next=\relax + \fi + \pgfmath@next} + +\def\pgfmath@bgroup@@@@strip#1\pgfmath@\pgfmath@@{% + \def\pgfmath@bgroup@stripped{#1}} + +% Local Variables: +% tab-width: 2 +% End: diff --git a/graphics/pgf/base/tex/generic/math/pgfmathutil.code.tex b/graphics/pgf/base/tex/generic/math/pgfmathutil.code.tex new file mode 100644 index 0000000000..d8d67dd841 --- /dev/null +++ b/graphics/pgf/base/tex/generic/math/pgfmathutil.code.tex @@ -0,0 +1,298 @@ +% Copyright 2019 Mark Wibrow +% +% but subject to the LaTeX Project Public License +% (http://www.latex-project.org/lppl.txt) +% +% and the GNU Public License +% (http://www.gnu.org/licenses/gpl.txt) +% + +% This file defines utilities common to the \pgfmath files. +% +% Version 1.414213 29/9/2007 + +\def\pgfmathincluded{} + +% Helper macros for \pgfmath@ifregister +% +\def\pgfmath@grabv#1#2#3#4#5#6#7\pgfmath@grabv{#2#3#4#5\ifx#6!!\fi} +\def\pgfmath@ifskip@extract#1{\expandafter\pgfmath@grabv\meaning#1!!!!!!\pgfmath@grabv} +\def\pgfmath@iftoks@extract#1{\expandafter\pgfmath@grabv\meaning#1!!!!!!\pgfmath@grabv} + +\def\pgfmath@grabvi#1#2#3#4#5#6#7#8\pgfmath@grabvi{#2#3#4#5#6\ifx#7!!\fi} +\def\pgfmath@ifdimen@extract#1{\expandafter\pgfmath@grabvi\meaning#1!!!!!!\pgfmath@grabvi} +\def\pgfmath@ifcount@extract#1{\expandafter\pgfmath@grabvi\meaning#1!!!!!!\pgfmath@grabvi} + +\def\pgfmath@grabvii#1#2#3#4#5#6#7#8#9\pgfmath@grabvii{#2#3#4#5#6#7\ifx#8!!\fi} +\def\pgfmath@ifmuskip@extract#1{\expandafter\pgfmath@grabvii\meaning#1!!!!!!\pgfmath@grabvii} + +% \pgfmath@ifdimen@unguarded +% +% Check if #2 is a register of type #1. +% Credits to Frank: https://tex.stackexchange.com/a/56905 +% +% #1 register type (count, dimen, skip, muskip, toks) +% #2 single token +% +\def\pgfmath@ifregister@unguarded#1#2{% + \expandafter\ifx\csname\csname pgfmath@if#1@extract\endcsname{#2}\expandafter\endcsname\csname #1\endcsname + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi} + +% \pgfmath@ifregister +% +% Checks if a token is a a certain type of register +% +% #1 register type (count, dimen, skip, muskip, toks) +% #2 single token +% +\def\pgfmath@ifregister#1#2{% + \pgfutil@IfUndefined{pgfmath@if#1@extract}% + {\errmessage{Package PGF Math Error: Cannot test for #1 register}}% + {\pgfutil@IfUndefined{\csname pgfmath@if#1@extract\endcsname{#2}}% + {\pgfutil@secondoftwo}}% + {\pgfmath@ifregister@unguarded{#1}{#2}}} + +% \pgfmath@ensureregister +% +% Ensure a control sequence exists as a TeX count/dimen register. +% +% #1 - count or dimen. +% #2 - a control sequence. +% +\def\pgfmath@ensureregister#1#2{% + \pgfmath@ifregister{#1}{#2}% + {}% + {\csname new#1\endcsname#2}% +} + +% Check registers exist. If not, create them. +% +\pgfmath@ensureregister{dimen}{\pgf@x} +\pgfmath@ensureregister{dimen}{\pgf@xa} +\pgfmath@ensureregister{dimen}{\pgf@xb} +\pgfmath@ensureregister{dimen}{\pgf@xc} + +\pgfmath@ensureregister{dimen}{\pgf@y} +\pgfmath@ensureregister{dimen}{\pgf@ya} +\pgfmath@ensureregister{dimen}{\pgf@yb} +\pgfmath@ensureregister{dimen}{\pgf@yc} + +\pgfmath@ensureregister{dimen}{\pgfutil@tempdima} +\pgfmath@ensureregister{dimen}{\pgfutil@tempdimb} + +\pgfmath@ensureregister{count}{\c@pgf@counta} +\pgfmath@ensureregister{count}{\c@pgf@countb} +\pgfmath@ensureregister{count}{\c@pgf@countc} +\pgfmath@ensureregister{count}{\c@pgf@countd} + +\pgfmath@ensureregister{count}{\pgfutil@tempcnta} +\pgfmath@ensureregister{count}{\pgfutil@tempcntb} + +% Alias for \pgfmath. +% +\let\pgfmath@x\pgf@x +\let\pgfmath@xa\pgf@xa +\let\pgfmath@xb\pgf@xb +\let\pgfmath@xc\pgf@xc + +\let\pgfmath@y\pgf@y +\let\pgfmath@ya\pgf@ya +\let\pgfmath@yb\pgf@yb +\let\pgfmath@yc\pgf@yc + +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempdimb\pgfutil@tempdimb + +\let\c@pgfmath@counta\c@pgf@counta +\let\c@pgfmath@countb\c@pgf@countb +\let\c@pgfmath@countc\c@pgf@countc +\let\c@pgfmath@countd\c@pgf@countd + +\let\pgfmath@tempcnta\pgfutil@tempcnta +\let\pgfmath@tempcntb\pgfutil@tempcntb + +% Now check if pgfutil and pgf@sys stuff exists. If it does, fine. +% Just \let pgfmath versions. If not, define pgfmath versions (Arghhh). +% + +% \...ifnextchar +% +\ifx\pgfutil@ifnextchar\pgfmath@undefined% + \long\def\pgfmath@ifnextchar#1#2#3{% + \let\pgfmath@reserved@d#1% + \def\pgfmath@reserved@a{#2}% + \def\pgfmath@reserved@b{#3}% + \futurelet\pgfmath@let@token\pgfmath@ifnch} + \def\pgfmath@ifnch{% + \ifx\pgfmath@let@token\pgfmath@sptoken% + \let\pgfmath@reserved@c\pgfmath@xifnch% + \else% + \ifx\pgfmath@let@token\pgfmath@reserved@d% + \let\pgfmath@reserved@c\pgfmath@reserved@a% + \else% + \let\pgfmath@reserved@c\pgfmath@reserved@b% + \fi% + \fi% + \pgfmath@reserved@c} + {% + \def\:{\global\let\pgfmath@sptoken= } \: + \def\:{\pgfmath@xifnch} \expandafter\gdef\: {\futurelet\pgfmath@let@token\pgfmath@ifnch} + }% +\else% + \let\pgfmath@ifnextchar\pgfutil@ifnextchar% + % Still need to define \pgfmath@sptoken (cannot \let). + {% + \def\:{\global\let\pgfmath@sptoken= } \: + }% +\fi% + +% \...ifundefined +% +\ifx\pgfutil@ifundefined\pgfmath@undefined% + \long\def\pgfmath@ifundefined#1{% + \expandafter\ifx\csname#1\endcsname\relax% + \expandafter\pgfmath@firstoftwo% + \else% + \expandafter\pgfmath@secondoftwo% + \fi}% +\else% + \let\pgfmath@ifundefined\pgfutil@ifundefined% +\fi% + +% \...selectfont +% +\ifx\pgfutil@selectfont\pgfmath@undefined% + \ifx\selectfont\pgfmath@undefined% + \let\pgfmath@selectfont\rm% Plain TeX and ConTeXt. + \else% + \let\pgfmath@selectfont\selectfont% LaTeX. + \fi% +\else% + \let\pgfmath@selectfont\pgfutil@selectfont% +\fi% + +% New definition easier than fussing around with let. +% +\newif\ifpgfmath@in@ +\def\pgfmath@in@#1#2{% + \def\pgfmath@in@@##1#1##2##3\pgfmath@in@@{% + \ifx\pgfmath@in@##2\pgfmath@in@false\else\pgfmath@in@true\fi}% + \pgfmath@in@@#2#1\pgfmath@in@\pgfmath@in@@} + + +% \...tonumber +% +\ifx\pgf@sys@tonumber\pgfmath@undefined% + {\catcode`\p=12\catcode`\t=12\gdef\Pgf@geT#1pt{#1}} + \def\pgfmath@tonumber#1{\expandafter\Pgf@geT\the#1} +\else% + \let\pgfmath@tonumber\pgf@sys@tonumber% +\fi% + + +% \PackageWarning and \PackageError +% +\ifx\PackageWarning\pgfmath@undefined + \def\pgfmath@PackageWarning#1#2{\immediate\write-1{Package #1: Warning! #2.}}% +\else% + \let\pgfmath@PackageWarning\PackageWarning% +\fi% +\ifx\PackageError\pgfmath@undefined + \def\pgfmath@PackageError#1#2#3{\errmessage{Package #1 Error: #2.}}% +\else% + \let\pgfmath@PackageError\PackageError% +\fi% + +\def\pgfmath@error#1#2{% + \pgfmath@PackageError{PGF Math}{% + #1% + \pgfutil@ifundefined{pgfmath@expression}{}{ (in '\pgfmath@expression')}% + }{#2}% +} +\def\pgfmath@warning#1{% + \pgfmath@PackageWarning{PGF Math}{% + #1% + \pgfutil@ifundefined{pgfmath@expression}{}{ (in '\pgfmath@expression')}% + }% +} + +% \pgfmath@pt +% +% Needed to test for 'pt' resulting from expansion using \the. +% +{\catcode`\p=12\catcode`\t=12\gdef\PgfmaTh@PT{pt}} +\edef\pgfmath@pt{\PgfmaTh@PT}% + +% \pgfmath@empty +% +% A handy macro. +% +\def\pgfmath@empty{} + +\def\pgfmath@firstoftwo#1#2{#1} +\def\pgfmath@secondoftwo#1#2{#2} + +% \pgfmath@gobbletilpgfmath@ +% +% Gobble stream until \pgfmath@ {which is undefined}. +% +\def\pgfmath@gobbletilpgfmath@#1\pgfmath@{} +\def\pgfmath@gobbleone#1{}% + + +\def\pgfmath@namedef#1{\expandafter\def\csname#1\endcsname} +\def\pgfmath@nameedef#1{\expandafter\edef\csname#1\endcsname} + +% \pgfmathloop +% +% A version of the standard TeX and LaTeX +% \loop, with an additional macro \pgfmathcounter +% (which is *not* a TeX counter) which keeps +% track of the iterations. +% +\newif\ifpgfmathcontinueloop +\def\pgfmathloop#1\repeatpgfmathloop{% + \def\pgfmathcounter{1}% + \def\pgfmath@iterate{% + #1\relax% + {% Do this inside a group, just in case... + \c@pgfmath@counta\pgfmathcounter% + \advance\c@pgfmath@counta1\relax% + \xdef\pgfmathloop@temp{\the\c@pgfmath@counta}% + }% + \edef\pgfmathcounter{\pgfmathloop@temp}% + \expandafter\pgfmath@iterate\fi}% + \pgfmath@iterate\let\pgfmath@iterate\relax} +\let\repeatpgfmathloop\fi +\def\pgfmathbreakloop{\let\pgfmath@iterate\relax}% + +% \pgfmath@returnone +% +% #1 - a dimension representing a number or dimension. +% +% Changed by TT: made faster and simpler since it is used +% *heavily*. #1 must be something that can be assigned to a +% dimension. +% +\def\pgfmath@returnone#1\endgroup{% + \pgfmath@x#1% + \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@x}}% + \expandafter\endgroup\expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmath@temp}% +} + +\let\pgfmathreturn=\pgfmath@returnone + +% \pgfmath@smuggleone +% +% Smuggle a macro outside a group. +% +% Changed by TT: Speedup by insisting, that smuggleone is directly +% followed by \endgroup +% +\def\pgfmath@smuggleone#1\endgroup{% + \expandafter\endgroup\expandafter\def\expandafter#1\expandafter{#1}} + +\let\pgfmathsmuggle=\pgfmath@smuggleone |