diff options
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.tex | 340 |
1 files changed, 328 insertions, 12 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 67d2be8c72b..62a33269d8b 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 @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% +%%% Date of this copy: Mi 31. Mär 21:41:41 CEST 2010 %%% @@ -643,11 +643,13 @@ \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 @@ -721,7 +723,10 @@ % #2: mantisse % #3: exponent % #4: CODE to display if the mantisse is drawn. -% #5: CODE to display if the mantisse is NOT draw. (unused) +% This code will be shown just before the exponent. +% Example: #4=\cdot +% #5: CODE to display if the mantisse 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 @@ -733,7 +738,7 @@ \or\pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax% \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% \or - \pgfmathfloatrounddisplaystyle@shared@impl@@{NaN}{}% + \pgfmathfloatrounddisplaystyle@shared@impl@@{\hbox{NaN}}{}% \or \ifpgfmathprintnumber@showpositive \pgfmathfloatrounddisplaystyle@shared@impl@@{+\infty}{}% @@ -802,6 +807,20 @@ \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/mantisse sep}\pgfmathdisplay@aftermantisse + \pgfkeysgetvalue{/pgf/number format/sci generic/empty mantisse sep}\pgfmathdisplay@nomantisse + \pgfkeysgetvalue{/pgf/number format/sci generic/exponent}\pgfmathdisplay@e + \toks0=\expandafter{\pgfmathdisplay@aftermantisse}% + \toks1=\expandafter{\pgfmathdisplay@nomantisse}% + \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. @@ -817,15 +836,22 @@ \newif\ifpgfmathfloat@usezerofill@fixed \newif\ifpgfmathprintnumber@assumemathmode \newif\ifpgfmathprintnumber@showpositive +\newif\ifpgfmathprintnumber@frac@warn \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}, + std/.code= {\pgfmath@set@number@printer{pgfmathprintnumber@STD}\pgfmathprintnumber@STD@setparam{#1}}, + std/.default=,% 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 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, @@ -835,6 +861,16 @@ 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}, @@ -859,6 +895,26 @@ 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/mantisse sep/.initial=,% + sci generic/empty mantisse sep/.initial=,% + sci generic/exponent/.initial=,% + sci generic/.value required, + verbatim/.style={% + sci generic={mantisse sep=,exponent={e##1}}, + 1000 sep=, + skip 0.=false, + print sign=false, + dec sep=., + assume math mode, + @dec sep mark=, + @sci exponent mark=, + }, % sci may skip mantisse/.is if=pgfmathfloatround@allow@empty@mantisse, % sci may skip mantisse/.default=true, } @@ -872,14 +928,44 @@ \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\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>4 + \expandafter\ifnum#3>\pgfmathprintnumber@STD@upperbound\relax \pgfmathprintnumber@SCI@issci#1#2e#3\relax% \else \begingroup - \c@pgf@counta=\pgfmathfloat@round@precision\relax - \divide\c@pgf@counta by-2\relax + \pgfmathprintnumber@STD@getlowerbound \ifnum#3<\c@pgf@counta \pgfmathprintnumber@SCI@issci#1#2e#3\relax% \else @@ -893,6 +979,198 @@ \fi } +\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 + % FIXME : doesn't respect show pos! + \fi + \toks1=\expandafter{\pgfmathfloat@loc@TMPa}% + \edef\pgfmathresult{% + \the\toks1 \the\toks0 {#2}{#3}% + }% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% Defines \pgfmathresult to contain three sets of braces containing +% the sign (optionally containing any components >1), the counter and the denominator for #1. +% +% \pgfmathfloatgetfrac{0.5} -> \pgfmathresult contains {}{1}{2} +% \pgfmathfloatgetfrac{-0.5} -> \pgfmathresult contains {-}{1}{2} +\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}{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 + \pgfmathfloattofixed{#1}% + \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 + \pgfmathfloat@a@E=-\pgfmathfloat@a@E + % + \def\pgfmathfloat@loc@TMPa##1.##2\relax{% + \def\pgfmathfloat@mantisse@first{##1}% + \def\pgfmathfloat@mantisse@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 + }% + % + \ifdim\pgfmathfloat@mantisse@ltone pt=0pt + \def\pgfmathfloat@factor{1}% + \edef\pgfmathfloat@scaled@counter{\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@mantisse@ltone}% + \pgfmathfloatreciprocal@{\pgfmathresult}% + }{% + % \usepackage{fp}. + % yields higher absolute precision. + \FPmessagesfalse% + \FPdebugfalse% + \FPdiv\pgfmathresult{1}{\pgfmathfloat@mantisse@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@counter=\pgfmathresult + % + \pgfmathfloattofixed\pgfmathfloat@factor + \expandafter\pgfmathfloat@loc@@to@int\pgfmathresult\relax{\pgfmathfloat@b@S}% + \edef\pgfmathfloat@factor{\the\pgfmathfloat@b@S}% + \fi + % + \let\pgfmathresultcounter=\pgfmathfloat@b@S + \let\pgfmathresultdenom=\pgfmathfloat@b@E + % + \pgfmathresultdenom=\pgfmathfloat@factor\relax + \pgfmathfloat@multiply@ten@to@the@E\pgfmathresultdenom + % + \expandafter\pgfmathfloat@loc@@to@int\pgfmathfloat@scaled@counter\relax{\pgfmathresultcounter}% +%\message{scale = \pgfmathfloat@factor; Z = \the\pgfmathresultcounter\space ( von \pgfmathfloat@scaled@counter), N = \the\pgfmathresultdenom.}% + % + \pgfmathgreatestcommondivisor{\pgfmathresultcounter}{\pgfmathresultdenom}% + \divide\pgfmathresultcounter by\pgfmathresult\relax + \divide\pgfmathresultdenom by\pgfmathresult\relax + \ifpgfmathprintnumber@frac@warn + \ifnum\pgfmathresultdenom>1000 + \pgfutil@ifundefined{FPdiv}{% + \pgfmathfloattosci@\pgfmathfloat@arg + \immediate\write16{! Package pgf /pgf/number format/frac warning=true: /pgf/number format/frac of `\pgfmathresult' = \the\pgfmathresultcounter\space / \the\pgfmathresultdenom\space might be large due to instabilities. Try \string\usepackage{fp} to improve accuracy.}% + }{}% + \fi + \fi + \ifnum\pgfmathfloat@a@S<0 + \edef\pgfmathresult{{-\pgfmathfloat@wholenumber}{\the\pgfmathresultcounter}{\the\pgfmathresultdenom}}% + \else + \edef\pgfmathresult{{\pgfmathfloat@wholenumber}{\the\pgfmathresultcounter}{\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}% @@ -914,6 +1192,37 @@ \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}% @@ -926,8 +1235,10 @@ \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 @@ -979,7 +1290,9 @@ } \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 @@ -987,6 +1300,8 @@ \fi \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathfloatrounddisplaystyle\pgfmathresult\relax + \pgfmath@smuggleone\pgfmathresult + \endgroup } % Prints argument #1 using the current pretty printer environment (all @@ -994,6 +1309,11 @@ % % You may specify optional arguments with \pgfmathprintnumber[...]. \def\pgfmathprintnumber{% + % \protect allows to supply \pgfmathprintnumber inside of latex + % captions. The \csname yields \relax in case protect is undefined. + \csname protect\endcsname\pgfmathprintnumber@protected +}% +\def\pgfmathprintnumber@protected{% \pgfutil@ifnextchar[% {\pgfmathprintnumber@OPT}% {\pgfmathprintnumber@noopt}% @@ -1063,11 +1383,7 @@ \expandafter\let\expandafter\pgfmathprintnumber@issci\csname #1@issci\endcsname } -\pgfmath@set@number@printer{pgfmathprintnumber@STD} -%\pgfmath@set@number@printer{pgfmathprintnumber@FIXED} -%\pgfmath@set@number@printer{pgfmathprintnumber@FIXED@ZEROFILL} -%\pgfmath@set@number@printer{pgfmathprintnumber@SCI@ZEROFILL} -%\pgfmath@set@number@printer{pgfmathprintnumber@SCI} +\pgfkeys{/pgf/number format/std} %%%%%%%%%%%%%%%%%%%%%%%%%% % |