summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex130
1 files changed, 88 insertions, 42 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex
index 8af2ed312c6..ad8f8bd36a9 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex
@@ -1,3 +1,6 @@
+%
+%
+%
%--------------------------------------------
%
% Package pgfplots
@@ -522,7 +525,9 @@
%
% This is the (accidentally) the same as \pgfplotsforeachentryinCSV.
\long\def\pgfplotsutilforeachcommasep#1\as#2#3{%
- \pgfplotsforeachentryinCSVisterminated@loop{#2}{#3}#1,\pgfplots@EOI
+ \pgfplots@for@reset@break{%
+ \pgfplotsforeachentryinCSVisterminated@loop{#2}{#3}#1,\pgfplots@EOI
+ }%
}%
% Usage:
@@ -538,7 +543,9 @@
% @see \pgfplotsforeachungrouped
% This loop can be nested.
\long\def\pgfplotsforeachentryinCSV#1#2#3{%
- \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2,\pgfplots@EOI
+ \pgfplots@for@reset@break{%
+ \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2,\pgfplots@EOI
+ }%
}%
% A variant of \pgfplotsforeachentryinCSV where a trailing comma
% indicates the end of input.
@@ -551,7 +558,9 @@
%
% This loop can be nested.
\long\def\pgfplotsforeachentryinCSVisterminated#1#2#3{%
- \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2\pgfplots@EOI
+ \pgfplots@for@reset@break{%
+ \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2\pgfplots@EOI
+ }%
}%
% #1 : the loop macro
% #2 : the loop BODY
@@ -567,7 +576,12 @@
\long\def\pgfplotsforeachentryinCSV@next#1#2#3,{%
\def#1{#3}%
#2\relax
- \pgfplotsforeachentryinCSVisterminated@loop{#1}{#2}%
+ \ifpgffor@continue
+ \expandafter\pgfplotsforeachentryinCSVisterminated@loop
+ \else
+ \expandafter\pgfplots@gobble@until@EOI
+ \fi
+ {#1}{#2}%
}%
@@ -606,22 +620,38 @@
\pgfplots@error{Found unexpected characters: expected 'in '.}%
}%
}
+
+\long\def\pgfplots@for@reset@break#1{%
+ \ifpgffor@continue
+ \pgffor@continuetrue
+ #1\relax
+ \pgffor@continuetrue
+ \else
+ \pgffor@continuetrue
+ #1\relax
+ \pgffor@continuefalse
+ \fi
+}%
+
\long\def\pgfplotsforeachungrouped@@#1#2#3#4{%
- \def\pgfplots@foreach@loc@TMPa{#2}%
- \ifx\pgfplots@foreach@loc@TMPa\pgfutil@empty
- \pgfplotsforeachungrouped@isuniform{#3}%
- \ifpgfplots@loc@tmp
- % special handling:
- % \foreach #1 in {a,b,...,c} can be improved:
- \pgfplotsforeachungroupeduniform@{#1}#3\relax{#4}%
+ \pgfplots@for@reset@break{%
+ %
+ \def\pgfplots@foreach@loc@TMPa{#2}%
+ \ifx\pgfplots@foreach@loc@TMPa\pgfutil@empty
+ \pgfplotsforeachungrouped@isuniform{#3}%
+ \ifpgfplots@loc@tmp
+ % special handling:
+ % \foreach #1 in {a,b,...,c} can be improved:
+ \pgfplotsforeachungroupeduniform@{#1}#3\relax{#4}%
+ \else
+ % invoke \foreach #1 in {#3} and transport results:
+ \pgfplotsforeachungroupednonuniform@#1{#3}{#4}%
+ \fi
\else
- % invoke \foreach #1 in {#3} and transport results:
- \pgfplotsforeachungroupednonuniform@#1{#3}{#4}%
+ % invoke \foreach #1/#2 in {#3} and transport results:
+ \pgfplotsforeachungroupedslashed@#1/#2{#3}{#4}%
\fi
- \else
- % invoke \foreach #1/#2 in {#3} and transport results:
- \pgfplotsforeachungroupedslashed@#1/#2{#3}{#4}%
- \fi
+ }%
}
\let\pgfplots@original@pgfmathadd@=\pgfmathadd@
@@ -667,10 +697,21 @@
% This here is much more accurate and does not suffer from the
% numerical stability issues of the other loop.
%
-% TO DO: test it (optimize it?) and enable it for some future compat=<version>
-% switch!
-\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@PRECISE@CURRENTLY@UNUSED@#1#2#3#4#5#6#7{%
- \pgfmathparse{#2+#7*#5}% is this significantly slower than the direct calls?
+% #1: comparison fct
+% #2: lower limit
+% #3: upper limit
+% #4: the loop macro name
+% #5: h
+% #6: code to invoke
+% #7: the loop variable (number samples)
+\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@precise#1#2#3#4#5#6#7{%
+ \pgflibraryfpuifactive{%
+ \pgfmathfloatparsenumber{#7}%
+ }{%
+ \edef\pgfmathresult{#7}%
+ }%
+ \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{#5}%
+ \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#2}%
\let#4=\pgfmathresult
#1{#4}{#3}% substitute this by integer arithmetics
\ifdim\pgfmathresult pt=0pt %
@@ -695,32 +736,37 @@
\expandafter\pgfplots@loc@TMPa
\fi
}%
-\long\def\pgfplotsforeachungroupeduniform@loop@mathengine#1#2#3#4#5#6#7{%
+\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@legacy#1#2#3#4#5#6#7{%
#1{#2}{#3}%
- \ifdim\pgfmathresult pt=0pt
- \pgfutil@in@{.0\relax}{#2\relax}%
- \ifpgfutil@in@
- \def\pgfplotsforeach@loc@TMP##1.0\relax{%
- \def#4{##1}%
- }%
- \pgfplotsforeach@loc@TMP#2\relax
- \else
- \def#4{#2}%
+ \ifpgffor@continue
+ \ifdim\pgfmathresult pt=0pt
+ \pgfutil@in@{.0\relax}{#2\relax}%
+ \ifpgfutil@in@
+ \def\pgfplotsforeach@loc@TMP##1.0\relax{%
+ \def#4{##1}%
+ }%
+ \pgfplotsforeach@loc@TMP#2\relax
+ \else
+ \def#4{#2}%
+ \fi
+ #6\relax
+ \pgfmathadd@{#2}{#5}%
+ \t@pgfplots@toka={{#1}}%
+ \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
+ \t@pgfplots@tokc={{#3}{#4}{#5}{#6}{--}}%
+ % loop!
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine
+ \the\t@pgfplots@toka
+ {\the\t@pgfplots@tokb}%
+ \the\t@pgfplots@tokc}%
+ \expandafter\expandafter\expandafter\pgfplots@loc@TMPa
\fi
- #6\relax
- \pgfmathadd@{#2}{#5}%
- \t@pgfplots@toka={{#1}}%
- \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
- \t@pgfplots@tokc={{#3}{#4}{#5}{#6}{--}}%
- % loop!
- \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine
- \the\t@pgfplots@toka
- {\the\t@pgfplots@tokb}%
- \the\t@pgfplots@tokc}%
- \expandafter\pgfplots@loc@TMPa
\fi
}%
+\let\pgfplotsforeachungroupeduniform@loop@mathengine=\pgfplotsforeachungroupeduniform@loop@mathengine@legacy
+
+
\long\def\pgfplotsforeachungroupednonuniform@#1#2#3{%
\pgfplotsapplistXXglobalnewempty
\foreach\pgfplots@foreach@loc@TMPa in {#2} {%