summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex')
-rw-r--r--Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex1384
1 files changed, 692 insertions, 692 deletions
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 6baf5ddba49..ecae8941fe1 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}