summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex27
1 files changed, 24 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex
index 65460e4b3cc..e00786d7a37 100644
--- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex
+++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex
@@ -160,6 +160,9 @@
\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%
@@ -191,7 +194,7 @@
\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\fi%
\pgfmath@returnone\pgfmath@x%
\endgroup}
@@ -263,6 +266,24 @@
\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{%
+ \ifx\pgfmath@token@stop#1%
+ \else
+ \advance\pgfmath@count by 1\relax
+ \expandafter\pgfmath@dim@i
+ \fi}
+
% max function.
%
@@ -287,7 +308,7 @@
% For compatability with old code.
\def\pgfmathmax#1#2{%
- \pgfmathparse{getargs(#1,#2)}%
+ \pgfmathparse{#1,#2}%
\expandafter\pgfmathmax@\expandafter{\pgfmathresult}%
}
@@ -314,7 +335,7 @@
% For compatability with old code.
\def\pgfmathmin#1#2{%
- \pgfmathparse{getargs(#1,#2)}%
+ \pgfmathparse{#1,#2}%
\expandafter\pgfmathmin@\expandafter{\pgfmathresult}%
}