diff options
author | Karl Berry <karl@freefriends.org> | 2019-05-05 21:38:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-05-05 21:38:50 +0000 |
commit | 675266a469958f9238613ad9e8ce6ae637736923 (patch) | |
tree | 869733d71acafaa19a1ce89c0c430d475448ae03 /Master/texmf-dist/source/generic/pgf | |
parent | 89916d9520fa753d876b1c3d0b300c91be1eb5d3 (diff) |
pgf
git-svn-id: svn://tug.org/texlive/trunk@51018 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic/pgf')
4 files changed, 843 insertions, 843 deletions
diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.code.tex b/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.code.tex index 8a200fcf991..153a074255a 100644 --- a/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.code.tex +++ b/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.code.tex @@ -4,23 +4,23 @@ A small image with a filled circle follows here (with baseline): \tikz[baseline] \fill[red] (0,1cm) circle(2pt); \tikzsetnextfilename{\tikzexternalrealjob-setnextfilename} -The next one uses +The next one uses \begin{tikzpicture}[baseline] - \draw (0,0) grid (4,4); + \draw (0,0) grid (4,4); \end{tikzpicture} an explizit file name. \begin{tikzpicture} - \node[draw,rounded corners] {A node with a ref (\ref{eq:1})}; + \node[draw,rounded corners] {A node with a ref (\ref{eq:1})}; \end{tikzpicture} \begin{equation} - 1+1=3 - \label{eq:1} + 1+1=3 + \label{eq:1} \end{equation} \begin{tikzpicture} - \node[draw,rounded corners] {A node which contains a label\label{a:label:in:a:picture}}; + \node[draw,rounded corners] {A node which contains a label\label{a:label:in:a:picture}}; \end{tikzpicture} The label inside of a node is on page~\pageref{a:label:in:a:picture}. @@ -29,12 +29,12 @@ The label inside of a node is on page~\pageref{a:label:in:a:picture}. \else The following picture exports a legend to the aux file (if possible). \begin{tikzpicture} - \begin{axis}[legend entries={1,2,3,4},legend to name=legend:name] - \addplot {x}; - \addplot {x+1}; - \addplot {x+2}; - \addplot {x+3}; - \end{axis} + \begin{axis}[legend entries={1,2,3,4},legend to name=legend:name] + \addplot {x}; + \addplot {x+1}; + \addplot {x+2}; + \addplot {x+3}; + \end{axis} \end{tikzpicture} Here is the legend: \pgfplotslegendfromname{legend:name}. diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.sharedpreamble.tex b/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.sharedpreamble.tex index 87e94f899eb..d2577b01b13 100644 --- a/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.sharedpreamble.tex +++ b/Master/texmf-dist/source/generic/pgf/testsuite/external/tikzexternaltest.sharedpreamble.tex @@ -5,16 +5,16 @@ \usepackage{hyperref} \IfFileExists{pgfplots.sty}{% - \usepackage{pgfplots} + \usepackage{pgfplots} }{}% \IfFileExists{tikzlibraryexternal.code.tex}{% - \usetikzlibrary{external} + \usetikzlibrary{external} }{% - \message{TEST IS RUNNING IN COMPATIBILITY MODE}% - % a test to check for pgf 2.00 compatibility, to check whether the - % external library copy shipped with pgfplots works: - \usepgfplotslibrary{external} + \message{TEST IS RUNNING IN COMPATIBILITY MODE}% + % a test to check for pgf 2.00 compatibility, to check whether the + % external library copy shipped with pgfplots works: + \usepgfplotslibrary{external} }% \pgfkeys{/pgf/images/include external/.code={\href{file:#1}{\pgfimage{#1}}}} diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex index ecae8941fe1..6baf5ddba49 100644 --- a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex +++ b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex @@ -1,5 +1,5 @@ -% FIXME: this class is MESSY. -% +% FIXME: this class is MESSY. +% % rewrite with proper assertions ... it goes back to a time where I % merely wanted to inspect the results! % @@ -13,20 +13,20 @@ \usepackage{ifpdf} \ifpdf - \usepackage{hyperref} + \usepackage{hyperref} \else - \def\pgfsysdriver{pgfsys-dvipdfm.def} - \usepackage[dvipdfm]{hyperref} + \def\pgfsysdriver{pgfsys-dvipdfm.def} + \usepackage[dvipdfm]{hyperref} \fi \usepackage{tikz} \usepackage{fp} \makeatletter \pgfutil@ifundefined{pgfmathdeclarefunction}{ - % load pgfplots with its pgf 2.00 compatibility code: - \usepackage{pgfplots} + % load pgfplots with its pgf 2.00 compatibility code: + \usepackage{pgfplots} }{ - \usepgflibrary{fpu} + \usepgflibrary{fpu} } \makeatother @@ -46,93 +46,93 @@ \def\compare#1#2{% - \begingroup - \message{COMPUTING LOG(#1)}% - \pgfmathlog{#1}% - \let\actual=\pgfmathresult - \def\expected{#2}% - \pgfmathsubtract\actual\expected% - \let\abserr=\pgfmathresult - \pgfmathdivide\abserr\expected - \let\relerr=\pgfmathresult - \noindent - log(#1)\hfill= - \expected;\hfill% - actual=\actual;\hfill% - abserr=\abserr;\hfill% - relerr=\relerr;\hfill% - \endgroup - \par + \begingroup + \message{COMPUTING LOG(#1)}% + \pgfmathlog{#1}% + \let\actual=\pgfmathresult + \def\expected{#2}% + \pgfmathsubtract\actual\expected% + \let\abserr=\pgfmathresult + \pgfmathdivide\abserr\expected + \let\relerr=\pgfmathresult + \noindent + log(#1)\hfill= + \expected;\hfill% + actual=\actual;\hfill% + abserr=\abserr;\hfill% + relerr=\relerr;\hfill% + \endgroup + \par }% %-------------------------------------------------- % \def\showlowlevelfloat#1#2e#3\relax{% -% \ensuremath{[#1] \cdot #2 \cdot 10^{#3}}% +% \ensuremath{[#1] \cdot #2 \cdot 10^{#3}}% % }% -%-------------------------------------------------- +%-------------------------------------------------- \long\def\showlowlevelfloatmacro#1{#1} \long\def\showlowlevelfloatmacrolong#1{% - #1 is decomposed into - - {% - \gdef\testerror{}% - \pgfmathfloattoregisters{#1}{\count0 }{\dimen0 }{\count1 }% - pgfmathfloattoregisters: flags \the\count0; M=\the\dimen0; E=\the\count1 - \ifx\testerror\empty - \else - \par (caught \texttt{\testerror})% - \fi - }% - - {% - \gdef\testerror{}% - pgfmathfloattoregisterstok: \pgfmathfloattoregisterstok{#1}{\count0 }{\toks0 }{\count1 }% - flags \the\count0; M=\the\toks0; E=\the\count1 - \ifx\testerror\empty - \else - \par (caught \texttt{\testerror})% - \fi - }% - - {% - \gdef\testerror{}% - pgfmathfloatgetflags \pgfmathfloatgetflags{#1}{\count0 } - flags \the\count0; - \ifx\testerror\empty - \else - \par (caught \texttt{\testerror})% - \fi - }% - - \medskip - %\expandafter\showlowlevelfloat#1\relax + #1 is decomposed into + + {% + \gdef\testerror{}% + \pgfmathfloattoregisters{#1}{\count0 }{\dimen0 }{\count1 }% + pgfmathfloattoregisters: flags \the\count0; M=\the\dimen0; E=\the\count1 + \ifx\testerror\empty + \else + \par (caught \texttt{\testerror})% + \fi + }% + + {% + \gdef\testerror{}% + pgfmathfloattoregisterstok: \pgfmathfloattoregisterstok{#1}{\count0 }{\toks0 }{\count1 }% + flags \the\count0; M=\the\toks0; E=\the\count1 + \ifx\testerror\empty + \else + \par (caught \texttt{\testerror})% + \fi + }% + + {% + \gdef\testerror{}% + pgfmathfloatgetflags \pgfmathfloatgetflags{#1}{\count0 } + flags \the\count0; + \ifx\testerror\empty + \else + \par (caught \texttt{\testerror})% + \fi + }% + + \medskip + %\expandafter\showlowlevelfloat#1\relax }% \def\showsinglenumberparsing#1{% %\tracingmacros=2\tracingcommands=2 - \begingroup - \message{PARSING NUMBER #1...}% - \gdef\testerror{}% - \pgfmathfloatparsenumber{#1}% - \let\resultasfloat=\pgfmathresult - \pgfmathfloattofixed\resultasfloat - \let\resultasfixed=\pgfmathresult - \[ #1 \mapsto \resultasfloat = \showlowlevelfloatmacro\resultasfloat \mapsto \resultasfixed - \] - \ifx\testerror\empty - \else - \par (caught \texttt{\testerror})% - \fi - \endgroup + \begingroup + \message{PARSING NUMBER #1...}% + \gdef\testerror{}% + \pgfmathfloatparsenumber{#1}% + \let\resultasfloat=\pgfmathresult + \pgfmathfloattofixed\resultasfloat + \let\resultasfixed=\pgfmathresult + \[ #1 \mapsto \resultasfloat = \showlowlevelfloatmacro\resultasfloat \mapsto \resultasfixed + \] + \ifx\testerror\empty + \else + \par (caught \texttt{\testerror})% + \fi + \endgroup %\tracingmacros=0\tracingcommands=0 } \def\pretty#1{% - \message{Pretty-printing #1...}% - \pgfmathprintnumberto{#1}\result - {\pgfkeys{/pgf/number format/showpos}\pgfmathprintnumberto{#1}\resultpos\global\let\resultpos=\resultpos}% - \[ #1 \mapsto \pgfmathprintnumber{#1} [=\resultpos] \] - \message{#1 mapsto \meaning\result}% + \message{Pretty-printing #1...}% + \pgfmathprintnumberto{#1}\result + {\pgfkeys{/pgf/number format/showpos}\pgfmathprintnumberto{#1}\resultpos\global\let\resultpos=\resultpos}% + \[ #1 \mapsto \pgfmathprintnumber{#1} [=\resultpos] \] + \message{#1 mapsto \meaning\result}% } \begin{document} @@ -146,7 +146,7 @@ % \showit{4.0} % log(1200)=\pgfmathlog{1.2}\pgfmathadd{\pgfmathresult}{6.9077}\pgfmathresult\par % log(6.241e-7)=\pgfmathlog{6.241}\pgfmathadd{\pgfmathresult}{-16.11809}\pgfmathresult\par -%-------------------------------------------------- +%-------------------------------------------------- \testsection{Conversion to normalised floating point numbers basis 10} \showsinglenumberparsing{123.41251}% @@ -203,36 +203,36 @@ \testsubsection{Error handling} { - \pgfkeys{ - /pgf/fpu/handlers/empty number/.code 2 args={% - \gdef\testerror{handlers/empty number=\{#1\}\{#2\}}% - }, - /pgf/fpu/handlers/invalid number/.code 2 args={% - \gdef\testerror{handlers/invalid number=\{#1\}\{#2\}}% - }, - /pgf/fpu/handlers/wrong lowlevel format/.code 2 args={% - \gdef\testerror{handlers/wrong lowlevel format=\{#1\}\{#2\}}% - }, - } - \showsinglenumberparsing{-53e-5 not terminated} - %\showsinglenumberparsing{-53e-} - \showsinglenumberparsing{} - \showsinglenumberparsing{ ASDZ@414e12} - - This one has trailing spaces and should work: - \showsinglenumberparsing{10 } - - This one has leading spaces and should work: - \showsinglenumberparsing{ 10} - - \testsubsection{Error handling of decompose routines} - - \pgfmathfloatparsenumber{100} - \showlowlevelfloatmacrolong{\pgfmathresult} - - \showlowlevelfloatmacrolong{132} - - \showlowlevelfloatmacrolong{Z} + \pgfkeys{ + /pgf/fpu/handlers/empty number/.code 2 args={% + \gdef\testerror{handlers/empty number=\{#1\}\{#2\}}% + }, + /pgf/fpu/handlers/invalid number/.code 2 args={% + \gdef\testerror{handlers/invalid number=\{#1\}\{#2\}}% + }, + /pgf/fpu/handlers/wrong lowlevel format/.code 2 args={% + \gdef\testerror{handlers/wrong lowlevel format=\{#1\}\{#2\}}% + }, + } + \showsinglenumberparsing{-53e-5 not terminated} + %\showsinglenumberparsing{-53e-} + \showsinglenumberparsing{} + \showsinglenumberparsing{ ASDZ@414e12} + + This one has trailing spaces and should work: + \showsinglenumberparsing{10 } + + This one has leading spaces and should work: + \showsinglenumberparsing{ 10} + + \testsubsection{Error handling of decompose routines} + + \pgfmathfloatparsenumber{100} + \showlowlevelfloatmacrolong{\pgfmathresult} + + \showlowlevelfloatmacrolong{132} + + \showlowlevelfloatmacrolong{Z} } \testsection{logarithms, compared with PGF arithmetics} @@ -298,65 +298,65 @@ { \twocolumn \def\prettytest{% - \pretty{1} - \pretty{1.0} - \pretty{-1.02311} - \pretty{-11241.02311} - \pretty{-11241} - \pretty{8124.99999} - \pretty{8124.849999} - \pretty{8124.843333} - \pretty{8.82} - \pretty{8.5} - \pretty{9.} - \pretty{5.9} - \pretty{-0.00001} - \pretty{-1.00001} - \pretty{-0.559} - \pretty{-0.554} - \pretty{-0.00000141} - \pretty{1.234e10} - \pretty{123456781} - \pretty{1234} - \pretty{8} - \pretty{-9.995} - \pretty{-0.015} - \pretty{-0.1} - \pretty{-0.15} - \pretty{0.15} - \pretty{-0} - \pretty{0} - \pretty{9.00} - \pretty{200.01} - \pretty{200.0000} - \pretty{1.5e-7} - \pretty{0.00035} - \pretty{0.00005} - \pretty{nan} - \pretty{inf} - \pretty{-inf} - \pretty{10} - \pretty{100} - \pretty{200} - \pretty{500} - \pretty{1000} - \pretty{30000} - \pretty{600000} - \pretty{1000000} - \pretty{30000000} - \pretty{600000000} - \pretty{1000000000} - \pretty{-10} - \pretty{-100} - \pretty{-200} - \pretty{-500} - \pretty{-1000} - \pretty{-30000} - \pretty{-600000} - \pretty{-1000000} - \pretty{-30000000} - \pretty{-600000000} - \pretty{-1000000000} + \pretty{1} + \pretty{1.0} + \pretty{-1.02311} + \pretty{-11241.02311} + \pretty{-11241} + \pretty{8124.99999} + \pretty{8124.849999} + \pretty{8124.843333} + \pretty{8.82} + \pretty{8.5} + \pretty{9.} + \pretty{5.9} + \pretty{-0.00001} + \pretty{-1.00001} + \pretty{-0.559} + \pretty{-0.554} + \pretty{-0.00000141} + \pretty{1.234e10} + \pretty{123456781} + \pretty{1234} + \pretty{8} + \pretty{-9.995} + \pretty{-0.015} + \pretty{-0.1} + \pretty{-0.15} + \pretty{0.15} + \pretty{-0} + \pretty{0} + \pretty{9.00} + \pretty{200.01} + \pretty{200.0000} + \pretty{1.5e-7} + \pretty{0.00035} + \pretty{0.00005} + \pretty{nan} + \pretty{inf} + \pretty{-inf} + \pretty{10} + \pretty{100} + \pretty{200} + \pretty{500} + \pretty{1000} + \pretty{30000} + \pretty{600000} + \pretty{1000000} + \pretty{30000000} + \pretty{600000000} + \pretty{1000000000} + \pretty{-10} + \pretty{-100} + \pretty{-200} + \pretty{-500} + \pretty{-1000} + \pretty{-30000} + \pretty{-600000} + \pretty{-1000000} + \pretty{-30000000} + \pretty{-600000000} + \pretty{-1000000000} } \testsubsection{STD format} @@ -491,61 +491,61 @@ \testsection{Pretty printing using the relative style} { -\long\def\TESTIT#1#2{% - \gdef\temptable{\begin{tabular}}% - \gdef\header{l}% - \def\n{\noexpand\n}% - \foreach \number in {#2} {% - \xdef\header{\header c}% - }% - \toks0=\expandafter{\temptable}% - \xdef\temptable{\the\toks0 {\header}\n}% - % - \toks0=\expandafter{\temptable}% - \toks1={}% - \xdef\temptable{\the\toks0 \the\toks1}% - \foreach \number in {#2} {% - \toks0=\expandafter{\temptable}% - \toks1=\expandafter{\number}% - \xdef\temptable{\the\toks0 & \noexpand\texttt{\the\toks1}}% - }% - \toks0=\expandafter{\temptable}% - \xdef\temptable{\the\toks0 \noexpand\\\n}% - % - \toks0=\expandafter{\temptable}% - \toks1={With actual config:}% - \xdef\temptable{\the\toks0 \the\toks1}% - \foreach \number in {#2} {% - \toks0=\expandafter{\temptable}% - \toks1=\expandafter{\number}% - \xdef\temptable{\the\toks0 & \noexpand\pgfmathprintnumber{\the\toks1}}% - }% - \toks0=\expandafter{\temptable}% - \xdef\temptable{\the\toks0 \noexpand\\\n}% - % - \foreach \relativeto in {#1} {% - \toks0=\expandafter{\temptable}% - \xdef\temptable{\the\toks0 Relative to $10^{\relativeto}$:}% - \foreach \number in {#2} {% - \toks0=\expandafter{\temptable}% - \toks1=\expandafter{\number}% - \xdef\temptable{\the\toks0 & \noexpand\pgfmathprintnumber[relative={\relativeto}]{\the\toks1}}% - }% - \toks0=\expandafter{\temptable}% - \xdef\temptable{\the\toks0 \noexpand\\\n}% - }% - % - % - \toks0=\expandafter{\temptable}% - \toks1={\end{tabular}\n}% - \xdef\temptable{\the\toks0 \the\toks1}% - % - \def\n{^^J}% +\long\def\TESTIT#1#2{% + \gdef\temptable{\begin{tabular}}% + \gdef\header{l}% + \def\n{\noexpand\n}% + \foreach \number in {#2} {% + \xdef\header{\header c}% + }% + \toks0=\expandafter{\temptable}% + \xdef\temptable{\the\toks0 {\header}\n}% + % + \toks0=\expandafter{\temptable}% + \toks1={}% + \xdef\temptable{\the\toks0 \the\toks1}% + \foreach \number in {#2} {% + \toks0=\expandafter{\temptable}% + \toks1=\expandafter{\number}% + \xdef\temptable{\the\toks0 & \noexpand\texttt{\the\toks1}}% + }% + \toks0=\expandafter{\temptable}% + \xdef\temptable{\the\toks0 \noexpand\\\n}% + % + \toks0=\expandafter{\temptable}% + \toks1={With actual config:}% + \xdef\temptable{\the\toks0 \the\toks1}% + \foreach \number in {#2} {% + \toks0=\expandafter{\temptable}% + \toks1=\expandafter{\number}% + \xdef\temptable{\the\toks0 & \noexpand\pgfmathprintnumber{\the\toks1}}% + }% + \toks0=\expandafter{\temptable}% + \xdef\temptable{\the\toks0 \noexpand\\\n}% + % + \foreach \relativeto in {#1} {% + \toks0=\expandafter{\temptable}% + \xdef\temptable{\the\toks0 Relative to $10^{\relativeto}$:}% + \foreach \number in {#2} {% + \toks0=\expandafter{\temptable}% + \toks1=\expandafter{\number}% + \xdef\temptable{\the\toks0 & \noexpand\pgfmathprintnumber[relative={\relativeto}]{\the\toks1}}% + }% + \toks0=\expandafter{\temptable}% + \xdef\temptable{\the\toks0 \noexpand\\\n}% + }% + % + % + \toks0=\expandafter{\temptable}% + \toks1={\end{tabular}\n}% + \xdef\temptable{\the\toks0 \the\toks1}% + % + \def\n{^^J}% %\message{TEMP-TABLE: \n\meaning\temptable\n}% - % - \let\n=\relax - \noindent - \temptable + % + \let\n=\relax + \noindent + \temptable }% %\tracingmacros=2 \tracingcommands=2 @@ -574,20 +574,20 @@ \begingroup \testsection{testing pgfmathfloatadd} \def\testfloataddnonsymmetric#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\first=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\second=\pgfmathresult - \message{computing #1 + #2; \first + \second}% - \pgfmathfloatadd\first\second - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \let\resultfixed=\pgfmathresult - \[ \text{pgfmathfloatadd: } \showlowlevelfloatmacro\first + \showlowlevelfloatmacro\second = \showlowlevelfloatmacro\result \; \bigl( #1 + #2 = \resultfixed \bigr). \] + \pgfmathfloatparsenumber{#1}% + \let\first=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\second=\pgfmathresult + \message{computing #1 + #2; \first + \second}% + \pgfmathfloatadd\first\second + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \let\resultfixed=\pgfmathresult + \[ \text{pgfmathfloatadd: } \showlowlevelfloatmacro\first + \showlowlevelfloatmacro\second = \showlowlevelfloatmacro\result \; \bigl( #1 + #2 = \resultfixed \bigr). \] }% \def\testfloatadd#1#2{% - \testfloataddnonsymmetric{#1}{#2}% - \testfloataddnonsymmetric{#2}{#1}% + \testfloataddnonsymmetric{#1}{#2}% + \testfloataddnonsymmetric{#2}{#1}% }% \testfloatadd{1}{100} @@ -623,17 +623,17 @@ \begingroup \testsection{testing pgfmathfloatmultiplyfixed} \def\testfloatmultiplyfixed#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\first=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \pgfmathfloattofixed\pgfmathresult - \let\second=\pgfmathresult - \message{computing #1 * #2; \first * \second}% - \pgfmathfloatmultiplyfixed\first\second - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \let\resultfixed=\pgfmathresult - \[ \text{pgfmathfloatmultiplyfixed: } \showlowlevelfloatmacro\first \cdot \second = \showlowlevelfloatmacro\result \; \bigl( #1 \cdot #2 = \resultfixed \bigr). \] + \pgfmathfloatparsenumber{#1}% + \let\first=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \pgfmathfloattofixed\pgfmathresult + \let\second=\pgfmathresult + \message{computing #1 * #2; \first * \second}% + \pgfmathfloatmultiplyfixed\first\second + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \let\resultfixed=\pgfmathresult + \[ \text{pgfmathfloatmultiplyfixed: } \showlowlevelfloatmacro\first \cdot \second = \showlowlevelfloatmacro\result \; \bigl( #1 \cdot #2 = \resultfixed \bigr). \] }% \testfloatmultiplyfixed{1}{100} @@ -670,18 +670,18 @@ \testsection{testing pgfmathfloatlessthan} \def\testfloatlessthan#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\first=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\second=\pgfmathresult - \message{checking #1 <= #2; \first <= \second}% - \pgfmathfloatlessthan\first\second - \ifpgfmathfloatcomparison - \def\result{<}% - \else - \def\result{\ge}% - \fi - \[ \text{pgfmathfloatlessthan: } \bigl( \showlowlevelfloatmacro\first \bigr)\; = #1 \result #2\; \bigl( = \showlowlevelfloatmacro\second \big). \] + \pgfmathfloatparsenumber{#1}% + \let\first=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\second=\pgfmathresult + \message{checking #1 <= #2; \first <= \second}% + \pgfmathfloatlessthan\first\second + \ifpgfmathfloatcomparison + \def\result{<}% + \else + \def\result{\ge}% + \fi + \[ \text{pgfmathfloatlessthan: } \bigl( \showlowlevelfloatmacro\first \bigr)\; = #1 \result #2\; \bigl( = \showlowlevelfloatmacro\second \big). \] }% \testfloatlessthan{4}{5} @@ -702,15 +702,15 @@ \testsection{float to fixed test} \def\testpgfmathfloattofixed#1{% - \pgfmathfloatparsenumber{#1}% + \pgfmathfloatparsenumber{#1}% %\tracingmacros=2\tracingcommands=2 - \let\argument=\pgfmathresult - \message{converting #1 = \argument\ to fixed point}% - \pgfmathfloattofixed\argument - \let\result=\pgfmathresult - \message{-> \result}% + \let\argument=\pgfmathresult + \message{converting #1 = \argument\ to fixed point}% + \pgfmathfloattofixed\argument + \let\result=\pgfmathresult + \message{-> \result}% %\tracingmacros=0\tracingcommands=0 - \[ \bigl( \showlowlevelfloatmacro\argument \bigr)\; = #1 \mapsto \result \] + \[ \bigl( \showlowlevelfloatmacro\argument \bigr)\; = #1 \mapsto \result \] }% \testpgfmathfloattofixed{0} \testpgfmathfloattofixed{5} @@ -733,21 +733,21 @@ \testsection{Testing pgfmathfloatmin and pgfmathfloatmax} \def\testfloatminmax#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\first=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\second=\pgfmathresult + \pgfmathfloatparsenumber{#1}% + \let\first=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\second=\pgfmathresult %\tracingmacros=2\tracingcommands=2 - \message{computing min/max #1 and #2}% - \pgfmathfloatmin\first\second - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \[ \min\{#1,#2\} = \min\{ \showlowlevelfloatmacro\first, \showlowlevelfloatmacro\second \} \; = \showlowlevelfloatmacro\result = \pgfmathresult \] - % - \pgfmathfloatmax\first\second - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \[ \max\{#1,#2\} = \max\{ \showlowlevelfloatmacro\first, \showlowlevelfloatmacro\second \} \; = \showlowlevelfloatmacro\result = \pgfmathresult \] + \message{computing min/max #1 and #2}% + \pgfmathfloatmin\first\second + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \[ \min\{#1,#2\} = \min\{ \showlowlevelfloatmacro\first, \showlowlevelfloatmacro\second \} \; = \showlowlevelfloatmacro\result = \pgfmathresult \] + % + \pgfmathfloatmax\first\second + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \[ \max\{#1,#2\} = \max\{ \showlowlevelfloatmacro\first, \showlowlevelfloatmacro\second \} \; = \showlowlevelfloatmacro\result = \pgfmathresult \] }% \testfloatminmax{42}{56} \testfloatminmax{-4122}{1256} @@ -756,13 +756,13 @@ \testsection{Testing pgfmathfloatshift} \def\pgfmathfloatshifttest#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\argument=\pgfmathresult - \message{computing mathshift #1 by #2}% - \pgfmathfloatshift\argument{#2}% - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \[ #1 \cdot 10^{#2} = \showlowlevelfloatmacro\argument \cdot 10^{#2} = \showlowlevelfloatmacro\result = \pgfmathresult \] + \pgfmathfloatparsenumber{#1}% + \let\argument=\pgfmathresult + \message{computing mathshift #1 by #2}% + \pgfmathfloatshift\argument{#2}% + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \[ #1 \cdot 10^{#2} = \showlowlevelfloatmacro\argument \cdot 10^{#2} = \showlowlevelfloatmacro\result = \pgfmathresult \] }% \pgfmathfloatshifttest{4}{1} \pgfmathfloatshifttest{4}{2} @@ -775,71 +775,71 @@ \testsection{Testing pgfmathfloatmultiply} \begingroup \def\pgfmathfloatmultiplytest#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\argumentb=\pgfmathresult - \message{computing mathmultiply #1 by #2}% - \pgfmathfloatmultiply\argumenta\argumentb% - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \[ #1 \cdot #2 = \showlowlevelfloatmacro\result = \pgfmathresult \] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\argumentb=\pgfmathresult + \message{computing mathmultiply #1 by #2}% + \pgfmathfloatmultiply\argumenta\argumentb% + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \[ #1 \cdot #2 = \showlowlevelfloatmacro\result = \pgfmathresult \] }% \def\tests{% - \pgfmathfloatmultiplytest{4}{1} - \pgfmathfloatmultiplytest{4}{2} - \pgfmathfloatmultiplytest{4}{-1} - \pgfmathfloatmultiplytest{4}{-2} - \pgfmathfloatmultiplytest{0}{-2} - \pgfmathfloatmultiplytest{1.1415130}{-2} - \pgfmathfloatmultiplytest{1.1415130}{5} - \pgfmathfloatmultiplytest{10}{10} - \pgfmathfloatmultiplytest{100}{100} - \pgfmathfloatmultiplytest{9999999}{9999999} - gnuplot for $\cdot$: $99999980000001.0$ - \pgfmathfloatmultiplytest{-10}{10} - \pgfmathfloatmultiplytest{-90}{3} - \pgfmathfloatmultiplytest{-90}{-3} - \pgfmathfloatmultiplytest{-inf}{nan} - \pgfmathfloatmultiplytest{-inf}{+inf} - \pgfmathfloatmultiplytest{1}{0} - \pgfmathfloatmultiplytest{1}{0} - \pgfmathfloatmultiplytest{1}{-0} - \pgfmathfloatmultiplytest{3.14159265358979}{2} + \pgfmathfloatmultiplytest{4}{1} + \pgfmathfloatmultiplytest{4}{2} + \pgfmathfloatmultiplytest{4}{-1} + \pgfmathfloatmultiplytest{4}{-2} + \pgfmathfloatmultiplytest{0}{-2} + \pgfmathfloatmultiplytest{1.1415130}{-2} + \pgfmathfloatmultiplytest{1.1415130}{5} + \pgfmathfloatmultiplytest{10}{10} + \pgfmathfloatmultiplytest{100}{100} + \pgfmathfloatmultiplytest{9999999}{9999999} + gnuplot for $\cdot$: $99999980000001.0$ + \pgfmathfloatmultiplytest{-10}{10} + \pgfmathfloatmultiplytest{-90}{3} + \pgfmathfloatmultiplytest{-90}{-3} + \pgfmathfloatmultiplytest{-inf}{nan} + \pgfmathfloatmultiplytest{-inf}{+inf} + \pgfmathfloatmultiplytest{1}{0} + \pgfmathfloatmultiplytest{1}{0} + \pgfmathfloatmultiplytest{1}{-0} + \pgfmathfloatmultiplytest{3.14159265358979}{2} }% \tests \testsection{Testing pgfmathfloatdivide} \def\pgfmathfloatmultiplytest#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\argumentb=\pgfmathresult - \message{computing mathdivide #1 by #2}% - \pgfmathfloatdivide\argumenta\argumentb% - \let\result=\pgfmathresult - \pgfmathfloattofixed\result - \[ #1 / #2 = \showlowlevelfloatmacro\result = \pgfmathresult \] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\argumentb=\pgfmathresult + \message{computing mathdivide #1 by #2}% + \pgfmathfloatdivide\argumenta\argumentb% + \let\result=\pgfmathresult + \pgfmathfloattofixed\result + \[ #1 / #2 = \showlowlevelfloatmacro\result = \pgfmathresult \] }% \tests % #1/#2 expected #3 \def\pgfmathfloattest#1#2#3{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\argumentb=\pgfmathresult - \pgfmathfloatparsenumber{#3}% - \let\reference=\pgfmathresult - \message{computing (#1/#2)}% - \pgfmathfloatdivide\argumenta\argumentb% - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \pgfmathfloattosci\pgfmathresult - \[ #1/#2 = \result\quad (\text{error/r to }#3 = \pgfmathprintnumber\pgfmathresult)\] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\argumentb=\pgfmathresult + \pgfmathfloatparsenumber{#3}% + \let\reference=\pgfmathresult + \message{computing (#1/#2)}% + \pgfmathfloatdivide\argumenta\argumentb% + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \pgfmathfloattosci\pgfmathresult + \[ #1/#2 = \result\quad (\text{error/r to }#3 = \pgfmathprintnumber\pgfmathresult)\] }% \pgfmathfloattest{83407811.0}{166815640.0}{0.499999946048224} \endgroup @@ -850,28 +850,28 @@ % #1 : number % #2 : the reference, sqrt (#1) \def\pgfmathfloatsqrttest#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\reference=\pgfmathresult - \message{computing sqrt(#1)}% - \pgfmathfloatsqrt\argumenta% - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \pgfmathfloattosci\pgfmathresult - \[ \sqrt{#1} = \result\quad (\text{rel. error } \pgfmathresult)\] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\reference=\pgfmathresult + \message{computing sqrt(#1)}% + \pgfmathfloatsqrt\argumenta% + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \pgfmathfloattosci\pgfmathresult + \[ \sqrt{#1} = \result\quad (\text{rel. error } \pgfmathresult)\] }% \def\tests{% - \pgfmathfloatsqrttest{0}{0} - \pgfmathfloatsqrttest{1}{1} - \pgfmathfloatsqrttest{2}{1.414213562373} - \pgfmathfloatsqrttest{4}{2} - \pgfmathfloatsqrttest{16}{4} - \pgfmathfloatsqrttest{10}{3.162277660168} - \pgfmathfloatsqrttest{1000000}{1000} - \pgfmathfloatsqrttest{123456789}{1.111111106055556e+04} + \pgfmathfloatsqrttest{0}{0} + \pgfmathfloatsqrttest{1}{1} + \pgfmathfloatsqrttest{2}{1.414213562373} + \pgfmathfloatsqrttest{4}{2} + \pgfmathfloatsqrttest{16}{4} + \pgfmathfloatsqrttest{10}{3.162277660168} + \pgfmathfloatsqrttest{1000000}{1000} + \pgfmathfloatsqrttest{123456789}{1.111111106055556e+04} }% \tests } @@ -880,32 +880,32 @@ \testsection{Testing pgfmathfloatint} % #1 : number \def\pgfmathfloatinttest#1{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \message{computing int(#1)}% - \pgfmathfloatint\argumenta% - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \[ int(#1) = \result \] - % - \pgfmathfloatparsenumber{-#1}% - \let\argumenta=\pgfmathresult - \message{computing int(-#1)}% - \pgfmathfloatint\argumenta% - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \[ int(-#1) = \result \] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \message{computing int(#1)}% + \pgfmathfloatint\argumenta% + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \[ int(#1) = \result \] + % + \pgfmathfloatparsenumber{-#1}% + \let\argumenta=\pgfmathresult + \message{computing int(-#1)}% + \pgfmathfloatint\argumenta% + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \[ int(-#1) = \result \] }% \def\tests{% - \pgfmathfloatinttest{1.23} - \pgfmathfloatinttest{12.34} - \pgfmathfloatinttest{123.4} - \pgfmathfloatinttest{1234.} - \pgfmathfloatinttest{1234.1} - \pgfmathfloatinttest{1e-2} - \pgfmathfloatinttest{0} - \pgfmathfloatinttest{3.456789e4} - \pgfmathfloatinttest{3.456789e10} + \pgfmathfloatinttest{1.23} + \pgfmathfloatinttest{12.34} + \pgfmathfloatinttest{123.4} + \pgfmathfloatinttest{1234.} + \pgfmathfloatinttest{1234.1} + \pgfmathfloatinttest{1e-2} + \pgfmathfloatinttest{0} + \pgfmathfloatinttest{3.456789e4} + \pgfmathfloatinttest{3.456789e10} }% \tests } @@ -915,72 +915,72 @@ % #1 : number % #2 : the reference, sqrt (#1) \def\pgfmathfloattest#1#2{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\reference=\pgfmathresult - \message{computing (#1)}% - \pgfmathfloatexp\argumenta% - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \pgfmathfloattosci\pgfmathresult - \[ \exp(#1) = \result\quad (\text{error/r to }#2 = \pgfmathresult)\] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\reference=\pgfmathresult + \message{computing (#1)}% + \pgfmathfloatexp\argumenta% + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \pgfmathfloattosci\pgfmathresult + \[ \exp(#1) = \result\quad (\text{error/r to }#2 = \pgfmathresult)\] }% %\tracingmacros=2\tracingcommands=2 - \pgfmathfloattest{-700}{9.85967654375977e-305} - \pgfmathfloattest{-1.0000000e+02}{3.7200760e-44} - \pgfmathfloattest{-9.5918367e+01}{2.2038516e-42} - \pgfmathfloattest{-9.1836735e+01}{1.3056083e-40} - \pgfmathfloattest{-8.7755102e+01}{7.7346991e-39} - \pgfmathfloattest{-8.3673469e+01}{4.5821992e-37} - \pgfmathfloattest{-7.9591837e+01}{2.7145916e-35} - \pgfmathfloattest{-7.5510204e+01}{1.6081814e-33} - \pgfmathfloattest{-7.1428571e+01}{9.5272065e-32} - \pgfmathfloattest{-6.7346939e+01}{5.6441184e-30} - \pgfmathfloattest{-6.3265306e+01}{3.3436950e-28} - \pgfmathfloattest{-5.9183673e+01}{1.9808756e-26} - \pgfmathfloattest{-5.5102041e+01}{1.1735125e-24} - \pgfmathfloattest{-5.1020408e+01}{6.9521362e-23} - \pgfmathfloattest{-4.6938776e+01}{4.1185924e-21} - \pgfmathfloattest{-4.2857143e+01}{2.4399411e-19} - \pgfmathfloattest{-3.8775510e+01}{1.4454727e-17} - \pgfmathfloattest{-3.4693878e+01}{8.5632855e-16} - \pgfmathfloattest{-3.0612245e+01}{5.0730713e-14} - \pgfmathfloattest{-2.6530612e+01}{3.0053946e-12} - \pgfmathfloattest{-2.2448980e+01}{1.7804593e-10} - \pgfmathfloattest{-1.8367347e+01}{1.0547817e-08} - \pgfmathfloattest{-1.4285714e+01}{6.2487495e-07} - \pgfmathfloattest{-1.0204082e+01}{3.7018912e-05} - \pgfmathfloattest{-6.1224490e+00}{2.1930786e-03} - \pgfmathfloattest{-2.0408163e+00}{1.2992261e-01} - \pgfmathfloattest{2.0408163e+00}{7.6968898e+00} - \pgfmathfloattest{6.1224490e+00}{4.5598001e+02} - \pgfmathfloattest{1.0204082e+01}{2.7013219e+04} - \pgfmathfloattest{1.4285714e+01}{1.6003202e+06} - \pgfmathfloattest{1.8367347e+01}{9.4806349e+07} - \pgfmathfloattest{2.2448980e+01}{5.6165284e+09} - \pgfmathfloattest{2.6530612e+01}{3.3273501e+11} - \pgfmathfloattest{3.0612245e+01}{1.9711925e+13} - \pgfmathfloattest{3.4693878e+01}{1.1677761e+15} - \pgfmathfloattest{3.8775510e+01}{6.9181522e+16} - \pgfmathfloattest{4.2857143e+01}{4.0984595e+18} - \pgfmathfloattest{4.6938776e+01}{2.4280140e+20} - \pgfmathfloattest{5.1020408e+01}{1.4384068e+22} - \pgfmathfloattest{5.5102041e+01}{8.5214258e+23} - \pgfmathfloattest{5.9183673e+01}{5.0482727e+25} - \pgfmathfloattest{6.3265306e+01}{2.9907034e+27} - \pgfmathfloattest{6.7346939e+01}{1.7717559e+29} - \pgfmathfloattest{7.1428571e+01}{1.0496256e+31} - \pgfmathfloattest{7.5510204e+01}{6.2182039e+32} - \pgfmathfloattest{7.9591837e+01}{3.6837954e+34} - \pgfmathfloattest{8.3673469e+01}{2.1823582e+36} - \pgfmathfloattest{8.7755102e+01}{1.2928751e+38} - \pgfmathfloattest{9.1836735e+01}{7.6592653e+39} - \pgfmathfloattest{9.5918367e+01}{4.5375106e+41} - \pgfmathfloattest{1.0000000e+02}{2.6881171e+43} - \pgfmathfloattest{700}{1.014232054735e+304} + \pgfmathfloattest{-700}{9.85967654375977e-305} + \pgfmathfloattest{-1.0000000e+02}{3.7200760e-44} + \pgfmathfloattest{-9.5918367e+01}{2.2038516e-42} + \pgfmathfloattest{-9.1836735e+01}{1.3056083e-40} + \pgfmathfloattest{-8.7755102e+01}{7.7346991e-39} + \pgfmathfloattest{-8.3673469e+01}{4.5821992e-37} + \pgfmathfloattest{-7.9591837e+01}{2.7145916e-35} + \pgfmathfloattest{-7.5510204e+01}{1.6081814e-33} + \pgfmathfloattest{-7.1428571e+01}{9.5272065e-32} + \pgfmathfloattest{-6.7346939e+01}{5.6441184e-30} + \pgfmathfloattest{-6.3265306e+01}{3.3436950e-28} + \pgfmathfloattest{-5.9183673e+01}{1.9808756e-26} + \pgfmathfloattest{-5.5102041e+01}{1.1735125e-24} + \pgfmathfloattest{-5.1020408e+01}{6.9521362e-23} + \pgfmathfloattest{-4.6938776e+01}{4.1185924e-21} + \pgfmathfloattest{-4.2857143e+01}{2.4399411e-19} + \pgfmathfloattest{-3.8775510e+01}{1.4454727e-17} + \pgfmathfloattest{-3.4693878e+01}{8.5632855e-16} + \pgfmathfloattest{-3.0612245e+01}{5.0730713e-14} + \pgfmathfloattest{-2.6530612e+01}{3.0053946e-12} + \pgfmathfloattest{-2.2448980e+01}{1.7804593e-10} + \pgfmathfloattest{-1.8367347e+01}{1.0547817e-08} + \pgfmathfloattest{-1.4285714e+01}{6.2487495e-07} + \pgfmathfloattest{-1.0204082e+01}{3.7018912e-05} + \pgfmathfloattest{-6.1224490e+00}{2.1930786e-03} + \pgfmathfloattest{-2.0408163e+00}{1.2992261e-01} + \pgfmathfloattest{2.0408163e+00}{7.6968898e+00} + \pgfmathfloattest{6.1224490e+00}{4.5598001e+02} + \pgfmathfloattest{1.0204082e+01}{2.7013219e+04} + \pgfmathfloattest{1.4285714e+01}{1.6003202e+06} + \pgfmathfloattest{1.8367347e+01}{9.4806349e+07} + \pgfmathfloattest{2.2448980e+01}{5.6165284e+09} + \pgfmathfloattest{2.6530612e+01}{3.3273501e+11} + \pgfmathfloattest{3.0612245e+01}{1.9711925e+13} + \pgfmathfloattest{3.4693878e+01}{1.1677761e+15} + \pgfmathfloattest{3.8775510e+01}{6.9181522e+16} + \pgfmathfloattest{4.2857143e+01}{4.0984595e+18} + \pgfmathfloattest{4.6938776e+01}{2.4280140e+20} + \pgfmathfloattest{5.1020408e+01}{1.4384068e+22} + \pgfmathfloattest{5.5102041e+01}{8.5214258e+23} + \pgfmathfloattest{5.9183673e+01}{5.0482727e+25} + \pgfmathfloattest{6.3265306e+01}{2.9907034e+27} + \pgfmathfloattest{6.7346939e+01}{1.7717559e+29} + \pgfmathfloattest{7.1428571e+01}{1.0496256e+31} + \pgfmathfloattest{7.5510204e+01}{6.2182039e+32} + \pgfmathfloattest{7.9591837e+01}{3.6837954e+34} + \pgfmathfloattest{8.3673469e+01}{2.1823582e+36} + \pgfmathfloattest{8.7755102e+01}{1.2928751e+38} + \pgfmathfloattest{9.1836735e+01}{7.6592653e+39} + \pgfmathfloattest{9.5918367e+01}{4.5375106e+41} + \pgfmathfloattest{1.0000000e+02}{2.6881171e+43} + \pgfmathfloattest{700}{1.014232054735e+304} } { @@ -989,29 +989,29 @@ % #2 : operand 2 % #3 : the reference, #1 mod #2 \def\pgfmathfloattest#1#2#3{% - \pgfmathfloatparsenumber{#1}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \let\argumentb=\pgfmathresult - \pgfmathfloatparsenumber{#3}% - \let\reference=\pgfmathresult - \message{computing #1 mod #2}% - \pgfmathfloatmod\argumenta\argumentb% - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \pgfmathfloattosci\pgfmathresult - \[ #1\text{ mod }#2 = \result\quad (\text{error/r to }#3 = \pgfmathresult)\] + \pgfmathfloatparsenumber{#1}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\argumentb=\pgfmathresult + \pgfmathfloatparsenumber{#3}% + \let\reference=\pgfmathresult + \message{computing #1 mod #2}% + \pgfmathfloatmod\argumenta\argumentb% + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \pgfmathfloattosci\pgfmathresult + \[ #1\text{ mod }#2 = \result\quad (\text{error/r to }#3 = \pgfmathresult)\] }% %\tracingmacros=2\tracingcommands=2 - \pgfmathfloattest{4}{3}{1} - \pgfmathfloattest{10}{10}{0} - \pgfmathfloattest{20}{6}{2} - \pgfmathfloattest{-100}{30}{-10} - \pgfmathfloattest{10.5}{5}{0.5} - \pgfmathfloattest{300.63}{360}{300.63} - \pgfmathfloattest{-20}{30}{-20} + \pgfmathfloattest{4}{3}{1} + \pgfmathfloattest{10}{10}{0} + \pgfmathfloattest{20}{6}{2} + \pgfmathfloattest{-100}{30}{-10} + \pgfmathfloattest{10.5}{5}{0.5} + \pgfmathfloattest{300.63}{360}{300.63} + \pgfmathfloattest{-20}{30}{-20} } { @@ -1020,245 +1020,245 @@ % #2 : operand % #3 : the reference, #2(#1) \def\pgfmathfloattest#1#2#3{% - \pgfmathfloatparsenumber{#2}% - \let\argumenta=\pgfmathresult - \pgfmathfloatparsenumber{#3}% - \let\reference=\pgfmathresult - \message{computing \string#1(#2)}% - #1\argumenta% - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \pgfmathfloattosci\pgfmathresult - \[ \string#1(#2) = \result\quad (\text{error/r to }#3 = \pgfmathresult)\] + \pgfmathfloatparsenumber{#2}% + \let\argumenta=\pgfmathresult + \pgfmathfloatparsenumber{#3}% + \let\reference=\pgfmathresult + \message{computing \string#1(#2)}% + #1\argumenta% + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \pgfmathfloattosci\pgfmathresult + \[ \string#1(#2) = \result\quad (\text{error/r to }#3 = \pgfmathresult)\] }% %\tracingmacros=2\tracingcommands=2 \testsubsection{SIN} - \pgfmathfloattest\pgfmathfloatsin{-7.2000000e+02}{4.8985872e-16} - \pgfmathfloattest\pgfmathfloatsin{-6.5454545e+02}{9.0963200e-01} - \pgfmathfloattest\pgfmathfloatsin{-5.8909091e+02}{7.5574957e-01} - \pgfmathfloattest\pgfmathfloatsin{-5.2363636e+02}{-2.8173256e-01} - \pgfmathfloattest\pgfmathfloatsin{-4.5818182e+02}{-9.8982144e-01} - \pgfmathfloattest\pgfmathfloatsin{-3.9272727e+02}{-5.4064082e-01} - \pgfmathfloattest\pgfmathfloatsin{-3.2727273e+02}{5.4064082e-01} - \pgfmathfloattest\pgfmathfloatsin{-2.6181818e+02}{9.8982144e-01} - \pgfmathfloattest\pgfmathfloatsin{-1.9636364e+02}{2.8173256e-01} - \pgfmathfloattest\pgfmathfloatsin{-1.3090909e+02}{-7.5574957e-01} - \pgfmathfloattest\pgfmathfloatsin{-6.5454545e+01}{-9.0963200e-01} - \pgfmathfloattest\pgfmathfloatsin{0.0000000e+00}{0.0000000e+00} - \pgfmathfloattest\pgfmathfloatsin{6.5454545e+01}{9.0963200e-01} - \pgfmathfloattest\pgfmathfloatsin{1.3090909e+02}{7.5574957e-01} - \pgfmathfloattest\pgfmathfloatsin{1.9636364e+02}{-2.8173256e-01} - \pgfmathfloattest\pgfmathfloatsin{2.6181818e+02}{-9.8982144e-01} - \pgfmathfloattest\pgfmathfloatsin{3.2727273e+02}{-5.4064082e-01} - \pgfmathfloattest\pgfmathfloatsin{3.9272727e+02}{5.4064082e-01} - \pgfmathfloattest\pgfmathfloatsin{4.5818182e+02}{9.8982144e-01} - \pgfmathfloattest\pgfmathfloatsin{5.2363636e+02}{2.8173256e-01} - \pgfmathfloattest\pgfmathfloatsin{5.8909091e+02}{-7.5574957e-01} - \pgfmathfloattest\pgfmathfloatsin{6.5454545e+02}{-9.0963200e-01} - \pgfmathfloattest\pgfmathfloatsin{7.2000000e+02}{-4.8985872e-16} + \pgfmathfloattest\pgfmathfloatsin{-7.2000000e+02}{4.8985872e-16} + \pgfmathfloattest\pgfmathfloatsin{-6.5454545e+02}{9.0963200e-01} + \pgfmathfloattest\pgfmathfloatsin{-5.8909091e+02}{7.5574957e-01} + \pgfmathfloattest\pgfmathfloatsin{-5.2363636e+02}{-2.8173256e-01} + \pgfmathfloattest\pgfmathfloatsin{-4.5818182e+02}{-9.8982144e-01} + \pgfmathfloattest\pgfmathfloatsin{-3.9272727e+02}{-5.4064082e-01} + \pgfmathfloattest\pgfmathfloatsin{-3.2727273e+02}{5.4064082e-01} + \pgfmathfloattest\pgfmathfloatsin{-2.6181818e+02}{9.8982144e-01} + \pgfmathfloattest\pgfmathfloatsin{-1.9636364e+02}{2.8173256e-01} + \pgfmathfloattest\pgfmathfloatsin{-1.3090909e+02}{-7.5574957e-01} + \pgfmathfloattest\pgfmathfloatsin{-6.5454545e+01}{-9.0963200e-01} + \pgfmathfloattest\pgfmathfloatsin{0.0000000e+00}{0.0000000e+00} + \pgfmathfloattest\pgfmathfloatsin{6.5454545e+01}{9.0963200e-01} + \pgfmathfloattest\pgfmathfloatsin{1.3090909e+02}{7.5574957e-01} + \pgfmathfloattest\pgfmathfloatsin{1.9636364e+02}{-2.8173256e-01} + \pgfmathfloattest\pgfmathfloatsin{2.6181818e+02}{-9.8982144e-01} + \pgfmathfloattest\pgfmathfloatsin{3.2727273e+02}{-5.4064082e-01} + \pgfmathfloattest\pgfmathfloatsin{3.9272727e+02}{5.4064082e-01} + \pgfmathfloattest\pgfmathfloatsin{4.5818182e+02}{9.8982144e-01} + \pgfmathfloattest\pgfmathfloatsin{5.2363636e+02}{2.8173256e-01} + \pgfmathfloattest\pgfmathfloatsin{5.8909091e+02}{-7.5574957e-01} + \pgfmathfloattest\pgfmathfloatsin{6.5454545e+02}{-9.0963200e-01} + \pgfmathfloattest\pgfmathfloatsin{7.2000000e+02}{-4.8985872e-16} \testsubsection{COS} - \pgfmathfloattest\pgfmathfloatcos{-7.2000000e+02}{1.0000000e+00} - \pgfmathfloattest\pgfmathfloatcos{-6.5454545e+02}{4.1541501e-01} - \pgfmathfloattest\pgfmathfloatcos{-5.8909091e+02}{-6.5486073e-01} - \pgfmathfloattest\pgfmathfloatcos{-5.2363636e+02}{-9.5949297e-01} - \pgfmathfloattest\pgfmathfloatcos{-4.5818182e+02}{-1.4231484e-01} - \pgfmathfloattest\pgfmathfloatcos{-3.9272727e+02}{8.4125353e-01} - \pgfmathfloattest\pgfmathfloatcos{-3.2727273e+02}{8.4125353e-01} - \pgfmathfloattest\pgfmathfloatcos{-2.6181818e+02}{-1.4231484e-01} - \pgfmathfloattest\pgfmathfloatcos{-1.9636364e+02}{-9.5949297e-01} - \pgfmathfloattest\pgfmathfloatcos{-1.3090909e+02}{-6.5486073e-01} - \pgfmathfloattest\pgfmathfloatcos{-6.5454545e+01}{4.1541501e-01} - \pgfmathfloattest\pgfmathfloatcos{0.0000000e+00}{1.0000000e+00} - \pgfmathfloattest\pgfmathfloatcos{6.5454545e+01}{4.1541501e-01} - \pgfmathfloattest\pgfmathfloatcos{1.3090909e+02}{-6.5486073e-01} - \pgfmathfloattest\pgfmathfloatcos{1.9636364e+02}{-9.5949297e-01} - \pgfmathfloattest\pgfmathfloatcos{2.6181818e+02}{-1.4231484e-01} - \pgfmathfloattest\pgfmathfloatcos{3.2727273e+02}{8.4125353e-01} - \pgfmathfloattest\pgfmathfloatcos{3.9272727e+02}{8.4125353e-01} - \pgfmathfloattest\pgfmathfloatcos{4.5818182e+02}{-1.4231484e-01} - \pgfmathfloattest\pgfmathfloatcos{5.2363636e+02}{-9.5949297e-01} - \pgfmathfloattest\pgfmathfloatcos{5.8909091e+02}{-6.5486073e-01} - \pgfmathfloattest\pgfmathfloatcos{6.5454545e+02}{4.1541501e-01} - \pgfmathfloattest\pgfmathfloatcos{7.2000000e+02}{1.0000000e+00} + \pgfmathfloattest\pgfmathfloatcos{-7.2000000e+02}{1.0000000e+00} + \pgfmathfloattest\pgfmathfloatcos{-6.5454545e+02}{4.1541501e-01} + \pgfmathfloattest\pgfmathfloatcos{-5.8909091e+02}{-6.5486073e-01} + \pgfmathfloattest\pgfmathfloatcos{-5.2363636e+02}{-9.5949297e-01} + \pgfmathfloattest\pgfmathfloatcos{-4.5818182e+02}{-1.4231484e-01} + \pgfmathfloattest\pgfmathfloatcos{-3.9272727e+02}{8.4125353e-01} + \pgfmathfloattest\pgfmathfloatcos{-3.2727273e+02}{8.4125353e-01} + \pgfmathfloattest\pgfmathfloatcos{-2.6181818e+02}{-1.4231484e-01} + \pgfmathfloattest\pgfmathfloatcos{-1.9636364e+02}{-9.5949297e-01} + \pgfmathfloattest\pgfmathfloatcos{-1.3090909e+02}{-6.5486073e-01} + \pgfmathfloattest\pgfmathfloatcos{-6.5454545e+01}{4.1541501e-01} + \pgfmathfloattest\pgfmathfloatcos{0.0000000e+00}{1.0000000e+00} + \pgfmathfloattest\pgfmathfloatcos{6.5454545e+01}{4.1541501e-01} + \pgfmathfloattest\pgfmathfloatcos{1.3090909e+02}{-6.5486073e-01} + \pgfmathfloattest\pgfmathfloatcos{1.9636364e+02}{-9.5949297e-01} + \pgfmathfloattest\pgfmathfloatcos{2.6181818e+02}{-1.4231484e-01} + \pgfmathfloattest\pgfmathfloatcos{3.2727273e+02}{8.4125353e-01} + \pgfmathfloattest\pgfmathfloatcos{3.9272727e+02}{8.4125353e-01} + \pgfmathfloattest\pgfmathfloatcos{4.5818182e+02}{-1.4231484e-01} + \pgfmathfloattest\pgfmathfloatcos{5.2363636e+02}{-9.5949297e-01} + \pgfmathfloattest\pgfmathfloatcos{5.8909091e+02}{-6.5486073e-01} + \pgfmathfloattest\pgfmathfloatcos{6.5454545e+02}{4.1541501e-01} + \pgfmathfloattest\pgfmathfloatcos{7.2000000e+02}{1.0000000e+00} \testsubsection{TAN} - \pgfmathfloattest\pgfmathfloattan{-7.2000000e+02}{4.8985872e-16} - \pgfmathfloattest\pgfmathfloattan{-6.5454545e+02}{2.1896946e+00} - \pgfmathfloattest\pgfmathfloattan{-5.8909091e+02}{-1.1540615e+00} - \pgfmathfloattest\pgfmathfloattan{-5.2363636e+02}{2.9362649e-01} - \pgfmathfloattest\pgfmathfloattan{-4.5818182e+02}{6.9551528e+00} - \pgfmathfloattest\pgfmathfloattan{-3.9272727e+02}{-6.4266098e-01} - \pgfmathfloattest\pgfmathfloattan{-3.2727273e+02}{6.4266098e-01} - \pgfmathfloattest\pgfmathfloattan{-2.6181818e+02}{-6.9551528e+00} - \pgfmathfloattest\pgfmathfloattan{-1.9636364e+02}{-2.9362649e-01} - \pgfmathfloattest\pgfmathfloattan{-1.3090909e+02}{1.1540615e+00} - \pgfmathfloattest\pgfmathfloattan{-6.5454545e+01}{-2.1896946e+00} - \pgfmathfloattest\pgfmathfloattan{0.0000000e+00}{0.0000000e+00} - \pgfmathfloattest\pgfmathfloattan{6.5454545e+01}{2.1896946e+00} - \pgfmathfloattest\pgfmathfloattan{1.3090909e+02}{-1.1540615e+00} - \pgfmathfloattest\pgfmathfloattan{1.9636364e+02}{2.9362649e-01} - \pgfmathfloattest\pgfmathfloattan{2.6181818e+02}{6.9551528e+00} - \pgfmathfloattest\pgfmathfloattan{3.2727273e+02}{-6.4266098e-01} - \pgfmathfloattest\pgfmathfloattan{3.9272727e+02}{6.4266098e-01} - \pgfmathfloattest\pgfmathfloattan{4.5818182e+02}{-6.9551528e+00} - \pgfmathfloattest\pgfmathfloattan{5.2363636e+02}{-2.9362649e-01} - \pgfmathfloattest\pgfmathfloattan{5.8909091e+02}{1.1540615e+00} - \pgfmathfloattest\pgfmathfloattan{6.5454545e+02}{-2.1896946e+00} - \pgfmathfloattest\pgfmathfloattan{7.2000000e+02}{-4.8985872e-16} + \pgfmathfloattest\pgfmathfloattan{-7.2000000e+02}{4.8985872e-16} + \pgfmathfloattest\pgfmathfloattan{-6.5454545e+02}{2.1896946e+00} + \pgfmathfloattest\pgfmathfloattan{-5.8909091e+02}{-1.1540615e+00} + \pgfmathfloattest\pgfmathfloattan{-5.2363636e+02}{2.9362649e-01} + \pgfmathfloattest\pgfmathfloattan{-4.5818182e+02}{6.9551528e+00} + \pgfmathfloattest\pgfmathfloattan{-3.9272727e+02}{-6.4266098e-01} + \pgfmathfloattest\pgfmathfloattan{-3.2727273e+02}{6.4266098e-01} + \pgfmathfloattest\pgfmathfloattan{-2.6181818e+02}{-6.9551528e+00} + \pgfmathfloattest\pgfmathfloattan{-1.9636364e+02}{-2.9362649e-01} + \pgfmathfloattest\pgfmathfloattan{-1.3090909e+02}{1.1540615e+00} + \pgfmathfloattest\pgfmathfloattan{-6.5454545e+01}{-2.1896946e+00} + \pgfmathfloattest\pgfmathfloattan{0.0000000e+00}{0.0000000e+00} + \pgfmathfloattest\pgfmathfloattan{6.5454545e+01}{2.1896946e+00} + \pgfmathfloattest\pgfmathfloattan{1.3090909e+02}{-1.1540615e+00} + \pgfmathfloattest\pgfmathfloattan{1.9636364e+02}{2.9362649e-01} + \pgfmathfloattest\pgfmathfloattan{2.6181818e+02}{6.9551528e+00} + \pgfmathfloattest\pgfmathfloattan{3.2727273e+02}{-6.4266098e-01} + \pgfmathfloattest\pgfmathfloattan{3.9272727e+02}{6.4266098e-01} + \pgfmathfloattest\pgfmathfloattan{4.5818182e+02}{-6.9551528e+00} + \pgfmathfloattest\pgfmathfloattan{5.2363636e+02}{-2.9362649e-01} + \pgfmathfloattest\pgfmathfloattan{5.8909091e+02}{1.1540615e+00} + \pgfmathfloattest\pgfmathfloattan{6.5454545e+02}{-2.1896946e+00} + \pgfmathfloattest\pgfmathfloattan{7.2000000e+02}{-4.8985872e-16} } { - % #1 : expression - % #2 : the reference - \def\assertEquals#1#2{% - \pgfmathfloatparsenumber{#2}% - \let\reference=\pgfmathresult - \message{parsing expression #1...}% - \pgfmathparse{#1}% - \pgfmathfloatparsenumber{\pgfmathresult}% - \let\argumenta=\pgfmathresult - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \let\actualerror=\pgfmathresult - \pgfmathfloatgreaterthan{\pgfmathresult}{\THRESH}% - \ifpgfmathfloatcomparison - \begingroup - \pgfkeys{/pgf/fpu=false}% - \pgfmathparse{#1}% - \global\let\actualBasic=\pgfmathresult - \endgroup - \PackageError{pgf-fpu}{Got error: expected #1=#2, but was \result\space (error \actualerror; basic level returns \actualBasic)}{}% - \fi - \pgfmathfloattosci\actualerror - \[ #1 = \result \quad[= \resultfloat] \quad (\text{error/r to }#2 = \pgfmathresult)\] - }% - \def\mathparserTestCases{% - \assertEquals{1+1}{2} - \assertEquals{1234567*4}{4938268} - \assertEquals{exp(200)}{7.22597376812575e+86} - \assertEquals{rad(360)}{6.28318530717959} - \assertEquals{rad(180)}{3.14159265358979} - \assertEquals{deg(2*pi)}{360} - \assertEquals{deg(pi)}{180} - \assertEquals{ln(1)}{0} - \assertEquals{round(1.5)}{2} - \assertEquals{round(-1.5)}{-2} - \assertEquals{- (1.5)}{-1.5} - \assertEquals{(1e4 - 1e3) * 1e5}{900000000.0} - \assertEquals{4^2}{16} - \assertEquals{4^3}{64} - \assertEquals{4^-3}{0.015625} - \assertEquals{4^-6}{0.000244140625} - \assertEquals{111^4}{151807041} - \assertEquals{8^10}{1073741824} - \assertEquals{3^1.5}{5.19615242270663} - \assertEquals{16^5.5}{4194304} - \assertEquals{15^-0.25}{0.508132748154615} - \assertEquals{sec(45)}{1.4142136e+00} - \assertEquals{cot(30)}{1.7320508e+00} - \assertEquals{asin(7.0710678e-01)}{45} - \assertEquals{acos(8.6602540e-01)}{30} - \assertEquals{atan(5.7735027e-01)}{30} - \assertEquals{atan(16000)}{89.9964} - \assertEquals{atan(1e6)}{8.9999943e+01} - \assertEquals{atan(-1e6)}{-8.9999943e+01} - \assertEquals{-12^2}{-144}% - \assertEquals{0-12^2}{-144}% - \assertEquals{-(12)^2}{-144}% - \assertEquals{exp(-12^2)}{2.8946e-63}% - \assertEquals{round(98.8)}{99}% - \assertEquals{-pi}{-3.14159265358979}% - \assertEquals{2*(-pi)}{-6.28318530717959}% - \assertEquals{2*(-3)}{-6}% - \assertEquals{veclen(1,1)}{1.414213562373095}% - \assertEquals{veclen(1e5,6e5)}{6.082762530298220e+05}% - \assertEquals{cosh(5)}{74.20994852478784}% - \assertEquals{sinh(0.6)}{0.636653582148241}% - \assertEquals{tanh(0.6)}{0.537049566998035}% - - {\pgfkeys{/pgf/trig format=rad} - \assertEquals{atan2(4,5)}{0.674740942223553}% - \assertEquals{atan2(-4,5)}{-0.674740942223553}% - \assertEquals{atan2(4,-5)}{2.46685171136624}% - \assertEquals{atan2(-4,-5)}{-2.46685171136624}% - % - \assertEquals{atan2(5,4)}{0.89605538457134}% - \assertEquals{atan2(-5,4)}{-0.89605538457134}% - \assertEquals{atan2(5,-4)}{2.24553726901845}% - \assertEquals{atan2(-5,-4)}{-2.24553726901845}% - % - \assertEquals{atan2(4e-5,5)}{0}% - \assertEquals{atan2(4e-5,-5)}{3.1415126535899}% - } - % \assertEquals{ceil(1.5)}{2} - } - - - { - \testsection{Testing the FPU library (and math parser)} - \pgfkeys{/pgf/fpu} - %\tracingmacros=2\tracingcommands=2 - \mathparserTestCases - } - - { - \def\mathparserTestCases{% - \assertEquals{sin(90)}{1.0}% - \assertEquals{cos(90)}{0.0}% - \assertEquals{tan(45)}{1.0}% - \assertEquals{sec(45)}{1.41429}% - \assertEquals{cosec(30)}{2.0}% - \assertEquals{cot(15)}{3.73215}% - \assertEquals{asin(0.7071)}{44.99945}% - \assertEquals{acos(0.5)}{60}% - \assertEquals{atan(1)}{45}% - \assertEquals{atan(16001)}{90}% - \assertEquals{atan(-16001)}{-90}% - %\assertEquals{atan2(-4,3)}{-53.13011}% - }% - \testsection{Testing trig format=deg, basic layer (selected examples)} - %\tracingmacros=2\tracingcommands=2 - \mathparserTestCases - - \testsection{Testing trig format=deg, FPU (selected examples)} - \pgfkeys{/pgf/fpu} - \mathparserTestCases - } - - { - \pgfkeys{/pgf/trig format=rad} - \def\mathparserTestCases{% - \assertEquals{sin(pi/2)}{1.0}% - \assertEquals{cos(pi/2)}{0.0}% - \assertEquals{tan(pi/4)}{1.0}% - \assertEquals{sec(pi/4)}{1.41429}% - \assertEquals{cosec(rad(30))}{2.0}% - \assertEquals{cot(rad(15))}{3.73215}% - \assertEquals{asin(0.7071)}{0.785388564086562}% 44.99945}% - \assertEquals{acos(0.5)}{1.0471975511966}% - \assertEquals{atan(1)}{0.785398163397448}%45}% - \assertEquals{atan(16001)}{1.570796326794}% - \assertEquals{atan(-16001)}{-1.570796326794}% - %\assertEquals{atan2(-4,3)}{-53.13011}% - }% - \testsection{Testing trig format=rad, basic layer (selected examples)} - %\tracingmacros=2\tracingcommands=2 - \mathparserTestCases - - \testsection{Testing trig format=rad, FPU (selected examples)} - \pgfkeys{/pgf/fpu} - \mathparserTestCases - } + % #1 : expression + % #2 : the reference + \def\assertEquals#1#2{% + \pgfmathfloatparsenumber{#2}% + \let\reference=\pgfmathresult + \message{parsing expression #1...}% + \pgfmathparse{#1}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\argumenta=\pgfmathresult + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \let\actualerror=\pgfmathresult + \pgfmathfloatgreaterthan{\pgfmathresult}{\THRESH}% + \ifpgfmathfloatcomparison + \begingroup + \pgfkeys{/pgf/fpu=false}% + \pgfmathparse{#1}% + \global\let\actualBasic=\pgfmathresult + \endgroup + \PackageError{pgf-fpu}{Got error: expected #1=#2, but was \result\space (error \actualerror; basic level returns \actualBasic)}{}% + \fi + \pgfmathfloattosci\actualerror + \[ #1 = \result \quad[= \resultfloat] \quad (\text{error/r to }#2 = \pgfmathresult)\] + }% + \def\mathparserTestCases{% + \assertEquals{1+1}{2} + \assertEquals{1234567*4}{4938268} + \assertEquals{exp(200)}{7.22597376812575e+86} + \assertEquals{rad(360)}{6.28318530717959} + \assertEquals{rad(180)}{3.14159265358979} + \assertEquals{deg(2*pi)}{360} + \assertEquals{deg(pi)}{180} + \assertEquals{ln(1)}{0} + \assertEquals{round(1.5)}{2} + \assertEquals{round(-1.5)}{-2} + \assertEquals{- (1.5)}{-1.5} + \assertEquals{(1e4 - 1e3) * 1e5}{900000000.0} + \assertEquals{4^2}{16} + \assertEquals{4^3}{64} + \assertEquals{4^-3}{0.015625} + \assertEquals{4^-6}{0.000244140625} + \assertEquals{111^4}{151807041} + \assertEquals{8^10}{1073741824} + \assertEquals{3^1.5}{5.19615242270663} + \assertEquals{16^5.5}{4194304} + \assertEquals{15^-0.25}{0.508132748154615} + \assertEquals{sec(45)}{1.4142136e+00} + \assertEquals{cot(30)}{1.7320508e+00} + \assertEquals{asin(7.0710678e-01)}{45} + \assertEquals{acos(8.6602540e-01)}{30} + \assertEquals{atan(5.7735027e-01)}{30} + \assertEquals{atan(16000)}{89.9964} + \assertEquals{atan(1e6)}{8.9999943e+01} + \assertEquals{atan(-1e6)}{-8.9999943e+01} + \assertEquals{-12^2}{-144}% + \assertEquals{0-12^2}{-144}% + \assertEquals{-(12)^2}{-144}% + \assertEquals{exp(-12^2)}{2.8946e-63}% + \assertEquals{round(98.8)}{99}% + \assertEquals{-pi}{-3.14159265358979}% + \assertEquals{2*(-pi)}{-6.28318530717959}% + \assertEquals{2*(-3)}{-6}% + \assertEquals{veclen(1,1)}{1.414213562373095}% + \assertEquals{veclen(1e5,6e5)}{6.082762530298220e+05}% + \assertEquals{cosh(5)}{74.20994852478784}% + \assertEquals{sinh(0.6)}{0.636653582148241}% + \assertEquals{tanh(0.6)}{0.537049566998035}% + + {\pgfkeys{/pgf/trig format=rad} + \assertEquals{atan2(4,5)}{0.674740942223553}% + \assertEquals{atan2(-4,5)}{-0.674740942223553}% + \assertEquals{atan2(4,-5)}{2.46685171136624}% + \assertEquals{atan2(-4,-5)}{-2.46685171136624}% + % + \assertEquals{atan2(5,4)}{0.89605538457134}% + \assertEquals{atan2(-5,4)}{-0.89605538457134}% + \assertEquals{atan2(5,-4)}{2.24553726901845}% + \assertEquals{atan2(-5,-4)}{-2.24553726901845}% + % + \assertEquals{atan2(4e-5,5)}{0}% + \assertEquals{atan2(4e-5,-5)}{3.1415126535899}% + } + % \assertEquals{ceil(1.5)}{2} + } + + + { + \testsection{Testing the FPU library (and math parser)} + \pgfkeys{/pgf/fpu} + %\tracingmacros=2\tracingcommands=2 + \mathparserTestCases + } + + { + \def\mathparserTestCases{% + \assertEquals{sin(90)}{1.0}% + \assertEquals{cos(90)}{0.0}% + \assertEquals{tan(45)}{1.0}% + \assertEquals{sec(45)}{1.41429}% + \assertEquals{cosec(30)}{2.0}% + \assertEquals{cot(15)}{3.73215}% + \assertEquals{asin(0.7071)}{44.99945}% + \assertEquals{acos(0.5)}{60}% + \assertEquals{atan(1)}{45}% + \assertEquals{atan(16001)}{90}% + \assertEquals{atan(-16001)}{-90}% + %\assertEquals{atan2(-4,3)}{-53.13011}% + }% + \testsection{Testing trig format=deg, basic layer (selected examples)} + %\tracingmacros=2\tracingcommands=2 + \mathparserTestCases + + \testsection{Testing trig format=deg, FPU (selected examples)} + \pgfkeys{/pgf/fpu} + \mathparserTestCases + } + + { + \pgfkeys{/pgf/trig format=rad} + \def\mathparserTestCases{% + \assertEquals{sin(pi/2)}{1.0}% + \assertEquals{cos(pi/2)}{0.0}% + \assertEquals{tan(pi/4)}{1.0}% + \assertEquals{sec(pi/4)}{1.41429}% + \assertEquals{cosec(rad(30))}{2.0}% + \assertEquals{cot(rad(15))}{3.73215}% + \assertEquals{asin(0.7071)}{0.785388564086562}% 44.99945}% + \assertEquals{acos(0.5)}{1.0471975511966}% + \assertEquals{atan(1)}{0.785398163397448}%45}% + \assertEquals{atan(16001)}{1.570796326794}% + \assertEquals{atan(-16001)}{-1.570796326794}% + %\assertEquals{atan2(-4,3)}{-53.13011}% + }% + \testsection{Testing trig format=rad, basic layer (selected examples)} + %\tracingmacros=2\tracingcommands=2 + \mathparserTestCases + + \testsection{Testing trig format=rad, FPU (selected examples)} + \pgfkeys{/pgf/fpu} + \mathparserTestCases + } } \end{document} diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex index ee144598943..225927eb411 100644 --- a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex +++ b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex @@ -9,8 +9,8 @@ X \def\SHOW#1{% - \dimen0=#1 % - #1 = \the\dimen0 + \dimen0=#1 % + #1 = \the\dimen0 } \SHOW{1pt} @@ -40,13 +40,13 @@ X \newif\ifcomparewithtex \newif\ifcomparewithfpu \pgfkeys{ - /ut/compare with TeX/.is if=comparewithtex, - /ut/compare with TeX=true, - /ut/compare with fpu/.is if=comparewithfpu, - /ut/compare with fpu=true, - /ut/.search also={/pgf/luamath}, - /pgf/luamath/show error message=true, - /pgf/luamath/enable TeX fallback=false, + /ut/compare with TeX/.is if=comparewithtex, + /ut/compare with TeX=true, + /ut/compare with fpu/.is if=comparewithfpu, + /ut/compare with fpu=true, + /ut/.search also={/pgf/luamath}, + /pgf/luamath/show error message=true, + /pgf/luamath/enable TeX fallback=false, } \newcount\numErrors @@ -57,113 +57,113 @@ X % #4: expected 'units declared' (1 or 0) \def\parsertest{\pgfutil@ifnextchar[\parsertest@{\parsertest@[]}}% \def\parsertest@[#1]#2#3#4{% - \begingroup - \pgfqkeys{/ut}{#1}% - \pgfluamathparse{#2}% - \let\actual=\pgfmathresult - \ifpgfmathunitsdeclared - \def\actualunitsdeclared{1}% - \else - \def\actualunitsdeclared{0}% - \fi - % - \ifcomparewithtex - \ifpgfluamathusedTeXfallback - \let\expectedTeX=\actual - \else - \pgfmathparse{#2}% - \let\expectedTeX=\pgfmathresult - \fi - \else - \def\expectedTeX{--}% - \fi - % - \edef\expected{#3}% - \def\success{1}% - \ifx\expected\empty - \ifx\actual\empty - \else - \def\success{0}% - \fi - \else - \ifx\actual\expected - \else - \def\success{0}% - \fi - \fi - % - \if1\success - \else - \message{FAILURE for #2 expected \expected\space but was \actual^^J}% - \global\advance\numErrors by1 - \fi - % - \if1\success - \def\expectedunitsdeclared{#4}% - \ifx\actualunitsdeclared\expectedunitsdeclared - \else - \def\success{0}% - \message{FAILURE for #2 expected units declared #4 but was \actualunitsdeclared^^J}% - \global\advance\numErrors by1 - \fi - \fi - % - \if1\success - \ifcomparewithtex - % check against PGF's basic layer as reference: - \dimen0=\actual pt % - \dimen1=\expectedTeX pt % - \advance\dimen0 by-\dimen1 - \ifdim\dimen0<0sp - \dimen0=-\dimen0 - \fi - \ifdim\dimen0 > 0.004pt % - \def\success{0}% - \message{FAILURE for #2 : matches expectations, but does NOT match TeX output (error \the\dimen0). expected \expectedTeX\space but was \actual^^J}% - \global\advance\numErrors by1 - \fi - % - % - \ifpgfmathunitsdeclared - \def\actualTeXunitsdeclared{1}% - \else - \def\actualTeXunitsdeclared{0}% - \fi - \ifx\actualTeXunitsdeclared\actualunitsdeclared - \else - \message{WARNING for #2 : matches ALL expectations, but TeX's output does NOT match TeX expected units declared (TeX returns \actualTeXunitsdeclared, expectation = LUA is \actualunitsdeclared)^^J}% - \fi - \fi - % - \ifcomparewithfpu - % check that FPU works as well. This - % * tests the FPU - % * tests that FPU values can be injected into the LUA backend: - \begingroup - \pgfkeys{/pgf/fpu,/pgf/fpu/output format=float}% - \pgfmathparse{#2}% - \xdef\actualfpu{\pgfmathresult}% - \ifpgfmathunitsdeclared - \xdef\actualfpuunitsdeclared{1}% - \else - \xdef\actualfpuunitsdeclared{0}% - \fi - \endgroup - % - \pgfkeys{/pgf/luamath/output format=fixed}% - \pgfluamathparse{abs(\actual - \actualfpu) > 0.004}% - \ifdim\pgfmathresult pt=1pt - \def\success{0}% - \pgfluamathparse{abs(\actual - \actualfpu)}% - \message{FAILURE for #2 : matches expectations, but does NOT match output of FPU (error \pgfmathresult). fpu=\actualfpu\space lua=\actual^^J}% - \global\advance\numErrors by1 - \fi - \fi - % - \fi - % - \message{#2 = \actual\space (pgf=\expectedTeX) \if1\success OK\else FAILURE\fi^^J}% - \endgroup + \begingroup + \pgfqkeys{/ut}{#1}% + \pgfluamathparse{#2}% + \let\actual=\pgfmathresult + \ifpgfmathunitsdeclared + \def\actualunitsdeclared{1}% + \else + \def\actualunitsdeclared{0}% + \fi + % + \ifcomparewithtex + \ifpgfluamathusedTeXfallback + \let\expectedTeX=\actual + \else + \pgfmathparse{#2}% + \let\expectedTeX=\pgfmathresult + \fi + \else + \def\expectedTeX{--}% + \fi + % + \edef\expected{#3}% + \def\success{1}% + \ifx\expected\empty + \ifx\actual\empty + \else + \def\success{0}% + \fi + \else + \ifx\actual\expected + \else + \def\success{0}% + \fi + \fi + % + \if1\success + \else + \message{FAILURE for #2 expected \expected\space but was \actual^^J}% + \global\advance\numErrors by1 + \fi + % + \if1\success + \def\expectedunitsdeclared{#4}% + \ifx\actualunitsdeclared\expectedunitsdeclared + \else + \def\success{0}% + \message{FAILURE for #2 expected units declared #4 but was \actualunitsdeclared^^J}% + \global\advance\numErrors by1 + \fi + \fi + % + \if1\success + \ifcomparewithtex + % check against PGF's basic layer as reference: + \dimen0=\actual pt % + \dimen1=\expectedTeX pt % + \advance\dimen0 by-\dimen1 + \ifdim\dimen0<0sp + \dimen0=-\dimen0 + \fi + \ifdim\dimen0 > 0.004pt % + \def\success{0}% + \message{FAILURE for #2 : matches expectations, but does NOT match TeX output (error \the\dimen0). expected \expectedTeX\space but was \actual^^J}% + \global\advance\numErrors by1 + \fi + % + % + \ifpgfmathunitsdeclared + \def\actualTeXunitsdeclared{1}% + \else + \def\actualTeXunitsdeclared{0}% + \fi + \ifx\actualTeXunitsdeclared\actualunitsdeclared + \else + \message{WARNING for #2 : matches ALL expectations, but TeX's output does NOT match TeX expected units declared (TeX returns \actualTeXunitsdeclared, expectation = LUA is \actualunitsdeclared)^^J}% + \fi + \fi + % + \ifcomparewithfpu + % check that FPU works as well. This + % * tests the FPU + % * tests that FPU values can be injected into the LUA backend: + \begingroup + \pgfkeys{/pgf/fpu,/pgf/fpu/output format=float}% + \pgfmathparse{#2}% + \xdef\actualfpu{\pgfmathresult}% + \ifpgfmathunitsdeclared + \xdef\actualfpuunitsdeclared{1}% + \else + \xdef\actualfpuunitsdeclared{0}% + \fi + \endgroup + % + \pgfkeys{/pgf/luamath/output format=fixed}% + \pgfluamathparse{abs(\actual - \actualfpu) > 0.004}% + \ifdim\pgfmathresult pt=1pt + \def\success{0}% + \pgfluamathparse{abs(\actual - \actualfpu)}% + \message{FAILURE for #2 : matches expectations, but does NOT match output of FPU (error \pgfmathresult). fpu=\actualfpu\space lua=\actual^^J}% + \global\advance\numErrors by1 + \fi + \fi + % + \fi + % + \message{#2 = \actual\space (pgf=\expectedTeX) \if1\success OK\else FAILURE\fi^^J}% + \endgroup }% \parsertest{1}{1.0}{0} @@ -225,10 +225,10 @@ X \pgfmathdeclarefunction{N1}{3}{\pgfmathparse{#1+#2+#3}}% \directlua{ function pgfluamathfunctions.x() - return 4 + return 4 end function pgfluamathfunctions.N1(x,m,n) - return x+m+n + return x+m+n end } \parsertest{2^x}{16.0}{0} @@ -371,8 +371,8 @@ end \parsertest{0 <0.1 || 4 <0.1}{1.0}{0} { \pgfkeys{/pgf/declare function={ - xx=4; - yy=4; + xx=4; + yy=4; }} \parsertest{abs(xx-yy)<0.1 ? -42 : 42}{-42.0}{0} \parsertest{abs(xx-yy)<0.1 || abs(xx-0.5)<0.1}{1.0}{0} @@ -425,11 +425,11 @@ end % -- strings with "<str>" % -- 'scalar' function % -- hex/octal/binary input -% -- tex registers +% -- tex registers % -- What happens for undefined functions!? --> return nil and let TeX invoke its parser (no warning!?) % -- width/height/depth % end -%-------------------------------------------------- +%-------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -510,15 +510,15 @@ end % should have been clean up: \parsertest[show error message=false,compare with TeX=false,compare with fpu=false]{mu1(-5,2)}{}{0} - + \def\pgfmathifexpressionTest#1{% - \pgfmathifexpression{1000>999}{% - % ok - \message{PASSED for mathifexpression(1000>999) #1: = '\pgfmathresult'^^J}% - }{% - \message{FAILURE for mathifexpression(1000>999) #1: = '\pgfmathresult'^^J}% - \global\advance\numErrors by1 - }% + \pgfmathifexpression{1000>999}{% + % ok + \message{PASSED for mathifexpression(1000>999) #1: = '\pgfmathresult'^^J}% + }{% + \message{FAILURE for mathifexpression(1000>999) #1: = '\pgfmathresult'^^J}% + \global\advance\numErrors by1 + }% } \pgfmathifexpressionTest{basicmath} @@ -533,7 +533,7 @@ end \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}% \pgfmathifexpressionTest{fpu output fixed} \endgroup - + \begingroup \pgfkeys{/pgf/fpu,/pgf/fpu/output format=sci}% \pgfmathifexpressionTest{fpu output sci} @@ -553,9 +553,9 @@ end % NO MORE TEST CASES HERE! \ifnum\numErrors>0 - \PackageError{pgf}{Has \the\numErrors\space FAILURES}{} + \PackageError{pgf}{Has \the\numErrors\space FAILURES}{} \else - \message{All cases PASSED^^J}% + \message{All cases PASSED^^J}% \fi |