summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex345
1 files changed, 270 insertions, 75 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex
index 3d0cad1b196..67d2be8c72b 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex
@@ -1,3 +1,23 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% This file is a copy of some part of PGF/Tikz.
+%%% It has been copied here to provide :
+%%% - compatibility with older PGF versions
+%%% - availability of PGF contributions by Christian Feuersaenger
+%%% which are necessary or helpful for pgfplots.
+%%%
+%%% For reasons of simplicity, I have copied the whole file, including own contributions AND
+%%% PGF parts. The copyrights are as they appear in PGF.
+%%%
+%%% Note that pgfplots has compatible licenses.
+%%%
+%%% This copy has been modified in the following ways:
+%%% - nested \input commands have been updated
+%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%%
+
+
+
% Copyright 2008 by Christian Feuersaenger
%
% This file may be distributed and/or modified
@@ -100,17 +120,48 @@
}
% The same as \pgfmathfloatparsenumber, but does not perform sanity checking.
-\def\pgfmathfloatqparsenumber#1{%
+% 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, mantisse 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 mantisse 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{%
\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
+ \edef\pgfmathfloat@loc@TMPa{#1}%
+ \expandafter\pgfmathfloat@decompose@F\pgfmathfloat@loc@TMPa\relax{\count0}%
+ \xdef\pgfmathfloat@glob@TMP{\the\count0 }%
\endgroup
+ \let#2=\pgfmathfloat@glob@TMP
+}%
+
+% Extracts the mantisse of #1 into the dimen register #2.
+\def\pgfmathfloatgetmantisse#1#2{%
+ \expandafter\pgfmathfloat@decompose@M#1\relax{#2}%
+}
+% Extracts the mantisse of #1 into the token register #2.
+\def\pgfmathfloatgetmantissetok#1#2{%
+ \expandafter\pgfmathfloat@decompose@Mtok#1\relax{#2}%
}
+% 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>
@@ -121,8 +172,26 @@
% ->
% \pgfmathresult is now '12.0e10' regardless of the internal float
% format.
-\def\pgfmathfloat@to@FMeE@style#1{\expandafter\pgfmathfloat@to@FMeE@style@#1\relax}%
-\def\pgfmathfloat@to@FMeE@style@#1Y#2e#3]\relax{\def\pgfmathresult{#1#2e#3}}%
+\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,
% mantisse and exponent.
@@ -130,23 +199,131 @@
% #4: integer register for the flags.
% #5: dimen registers for the mantisse.
% #6: integer register for the exponent.
-\def\pgfmathfloat@decompose#1Y#2e#3]\relax#4#5#6{%
+%
+% \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E
+% -> the three temp registers contain flags, mantisse 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%
+ #5=#2pt % keep space here.
#6=#3\relax%
}
+
% overloaded, #5 needs to be a token register for the mantisse.
-\def\pgfmathfloat@decompose@tok#1Y#2e#3]\relax#4#5#6{%
+% @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, mantisse 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:
-\def\pgfmathfloat@decompose@F#1Y#2e#3]\relax#4{#4=#1\relax}%
-\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}%
+% \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@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@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, mantisse to macro #3 and exponent to macro #4.
\def\pgfmathfloattomacro#1#2#3#4{%
@@ -161,34 +338,6 @@
\pgfmathfloat@glob@TMP
}
-% Takes a floating point number #1 as input and writes flags to count
-% register #2, mantisse 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 mantisse 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 mantisse of #1 into the dimen register #2.
-\def\pgfmathfloatgetmantisse#1#2{%
- \expandafter\pgfmathfloat@decompose@M#1\relax{#2}%
-}
-% Extracts the mantisse of #1 into the token register #2.
-\def\pgfmathfloatgetmantissetok#1#2{%
- \expandafter\pgfmathfloat@decompose@Mtok#1\relax{#2}%
-}
-% Extracts the exponent of #1 into the count register #2.
-\def\pgfmathfloatgetexponent#1#2{%
- \expandafter\pgfmathfloat@decompose@E#1\relax{#2}%
-}
% Defines \pgfmathresult as the floating point number encoded by
% the flags #1, mantisse #2 and exponent #3.
@@ -250,6 +399,23 @@
}%
\let\pgfmathfloattosci=\pgfmathfloattosci@
+% Expands a floating point number to scientific format 1.234e5.
+%
+% This operation is very fast.
+\def\pgfmathfloatvalueof#1{\expandafter\pgfmathfloatvalueof@@#1\relax}%
+\def\pgfmathfloatvalueof@@#1Y#2e#3]\relax{%
+ \ifcase#1 %
+ 0.0e0%
+ \or
+ #2e#3%
+ \or
+ -#2e#3%
+ \or nan%
+ \or inf%
+ \or -inf%
+ \fi
+}%
+
% Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns
% the result into \pgfmathresult.
@@ -1489,14 +1655,29 @@
/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 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
@@ -1545,45 +1726,47 @@
\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@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@I\endcsname{\pgfflt@readinf}% FIXME: inlining?
+\expandafter\def\csname pgffltA@.\endcsname{% read '.9' like '0.9'
+ \pgfmathfloat@a@E=-1
+ \pgfflt@leadingzero@foundperiod}%
\def\pgfflt@finish#1\pgfflt@EOI{}
-\def\pgfflt@readnan an{%
- \pgfmathfloat@a@S=3\relax%
- \pgfmathfloat@a@Mtok={0.0}%
- \pgfmathfloat@a@E=0%
- \pgfflt@finish
-}
-\def\pgfflt@readNaN aN{%
- \pgfmathfloat@a@S=3\relax%
- \pgfmathfloat@a@Mtok={0.0}%
- \pgfmathfloat@a@E=0%
- \pgfflt@finish
-}
-\def\pgfflt@readinf nf{%
- \ifnum\pgfmathfloat@a@S=1
- \pgfmathfloat@a@S=4\relax%
+\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
- \pgfmathfloat@a@S=5\relax%
- \pgfmathfloat@a@Mtok={0.0}%
+ \def\pgfflt@readnan@{\pgfflt@error #1#2}%
+ \expandafter\pgfflt@readnan@
\fi
- \pgfmathfloat@a@E=0%
- \pgfflt@finish
}
-\def\pgfflt@readINF NF{%
- \ifnum\pgfmathfloat@a@S=1
- \pgfmathfloat@a@S=4\relax%
- \pgfmathfloat@a@Mtok={0.0}%
+\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
- \pgfmathfloat@a@S=5\relax%
- \pgfmathfloat@a@Mtok={0.0}%
+ \def\pgfflt@readinf@{\pgfflt@error #1#2}%
+ \expandafter\pgfflt@readinf@
\fi
- \pgfmathfloat@a@E=0%
- \pgfflt@finish
}
\def\pgfflt@leadingzero#1{%
\expandafter\ifx\csname pgffltB@#1\endcsname\relax
@@ -1693,7 +1876,19 @@
}%
\def\pgfflt@readexponent#1\pgfflt@EOI{%
- \advance\pgfmathfloat@a@E by#1\relax
+ \afterassignment\pgfflt@readexponent@
+ \pgfmathfloat@b@E=#1\relax\pgfflt@EOI
+}
+\def\pgfflt@readexponent@{%
+ \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E\relax
+ \afterassignment\pgfflt@readexponent@@
+ \let\pgfmathfloat@loc@TMPb=}%
+\def\pgfflt@readexponent@@#1\pgfflt@EOI{%
+ \ifx\pgfmathfloat@loc@TMPb\relax
+ \else
+ \def\pgfmathfloat@loc@TMPb{\pgfflt@error#1\pgfflt@EOI}%
+ \expandafter\pgfmathfloat@loc@TMPb
+ \fi
}
\def\pgfflt@pendingzeros@positiveexp#1{%