summaryrefslogtreecommitdiff
path: root/graphics/pgf/base/source/pgfmathtestsuite.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/base/source/pgfmathtestsuite.tex')
-rw-r--r--graphics/pgf/base/source/pgfmathtestsuite.tex1264
1 files changed, 0 insertions, 1264 deletions
diff --git a/graphics/pgf/base/source/pgfmathtestsuite.tex b/graphics/pgf/base/source/pgfmathtestsuite.tex
deleted file mode 100644
index 6baf5ddba4..0000000000
--- a/graphics/pgf/base/source/pgfmathtestsuite.tex
+++ /dev/null
@@ -1,1264 +0,0 @@
-% FIXME: this class is MESSY.
-%
-% rewrite with proper assertions ... it goes back to a time where I
-% merely wanted to inspect the results!
-%
-% --> see 'assertEquals' in this file
-%
-\documentclass[a4paper]{article}
-
-\usepackage[intlimits]{amsmath}
-\usepackage{amssymb}
-\usepackage{amsfonts}
-\usepackage{ifpdf}
-
-\ifpdf
- \usepackage{hyperref}
-\else
- \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}
-}{
- \usepgflibrary{fpu}
-}
-\makeatother
-
-\pgfmathfloatcreate{1}{5.0}{-4}
-\let\THRESH=\pgfmathresult
-
-
-\parindent=0pt
-
-
-\author{Christian Feuers\"anger}
-\title{Test cases for pgffloatmath.code.tex}
-
-\def\testsection#1{\message{---------- STARTING TEST SECTION '#1'}\section{#1}}
-\def\testsubsection#1{\message{-------STARTING TEST SUBSECTION '#1'}\subsection{#1}}
-\def\testsubsubsection#1{\message{------STARTING TEST SUBSUBSECTION '#1'}\subsubsection{#1}}
-
-
-\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
-}%
-%--------------------------------------------------
-% \def\showlowlevelfloat#1#2e#3\relax{%
-% \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
-}%
-
-\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
-%\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}%
-}
-
-\begin{document}
-\maketitle
-
-
-%--------------------------------------------------
-% \showit{2.8128}
-% log(12)=\pgfmathlog{1.2}\pgfmathadd{\pgfmathresult}{2.30258}\pgfmathresult\par
-% \showit{1.2}
-% \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}%
-\showsinglenumberparsing{1023.52}
-\showsinglenumberparsing{123412.51}%
-\showsinglenumberparsing{12341251.0}%
-\showsinglenumberparsing{-12341251.0}%
-\showsinglenumberparsing{1.2341251}%
-\showsinglenumberparsing{8.02410024}
-\showsinglenumberparsing{8.024100}
-\showsinglenumberparsing{0001234.3100}
-\showsinglenumberparsing{0001234.00001}
-\showsinglenumberparsing{0001000.00001}
-\showsinglenumberparsing{0001000.00001000}
-\showsinglenumberparsing{0.12341251}%
-\showsinglenumberparsing{0.0012341251}%
-\showsinglenumberparsing{0.00000012341251}%
-\showsinglenumberparsing{-0.00000012341251}%
-\showsinglenumberparsing{10}
-\showsinglenumberparsing{100.351}
-\showsinglenumberparsing{100.35100}
-\showsinglenumberparsing{100.35100234}
-\showsinglenumberparsing{100.0035100234}
-\showsinglenumberparsing{100}
-\showsinglenumberparsing{99999}
-\showsinglenumberparsing{999.000}
-
-%\tracingmacros=2 \tracingcommands=2
-\showsinglenumberparsing{8.31160034e-02}%
-\showsinglenumberparsing{2.54685628e-02}%
-\showsinglenumberparsing{7.40715288e-03}%
-\showsinglenumberparsing{2.10192154e-03}%
-\showsinglenumberparsing{5.87352989e-04}%
-\showsinglenumberparsing{-1.62269942e-04}%
-\showsinglenumberparsing{4.44248889e-05}%
-\showsinglenumberparsing{1.20714122e-05}%
-\showsinglenumberparsing{3.26101452e-06}%
-\showsinglenumberparsing{3261.01452e-06}%
-\showsinglenumberparsing{0.000326101452e-06}%
-\showsinglenumberparsing{1.2345e-12}%
-\showsinglenumberparsing{1.2345e+12}%
-
-\message{SPECIAL CASE 0}%
-\showsinglenumberparsing{0}
-\showsinglenumberparsing{-0}
-\showsinglenumberparsing{-0.000}
-\showsinglenumberparsing{+0.000}
-\showsinglenumberparsing{+0}
-\showsinglenumberparsing{-1}
-\showsinglenumberparsing{1.0e1}
-\showsinglenumberparsing{1e1}
-\showsinglenumberparsing{1141}
-\showsinglenumberparsing{-53e-5}
-
-\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}
-}
-
-\testsection{logarithms, compared with PGF arithmetics}
-
-\compare{0.1}{-2.30259}
-\compare{0.12}{-2.12026}
-\compare{0.2}{-1.60944}
-\compare{0.3}{-1.20397}
-\compare{0.4}{-0.916291}
-\compare{0.5}{-0.693147}
-\compare{0.6}{-0.510826}
-\compare{0.7}{-0.356675}
-\compare{0.75}{-0.287682}
-\compare{0.8}{-0.223144}
-\compare{0.823}{-0.194799}
-\compare{0.9}{-0.105361}
-\compare{0.96}{-0.040822}
-\compare{1.2}{0.182322}
-\compare{1.5}{0.405465}
-\compare{1.6}{0.470004}
-\compare{9.0}{2.1972245773}
-\compare{9.2}{2.2192034}
-\compare{9.3}{2.23001440}
-\compare{9.7}{2.27212588}
-\compare{10.0}{2.302585092}
-\compare{100.0}{4.605170185}
-\compare{1351.0}{7.208600337}
-\compare{9752.0}{9.185227671}
-\compare{9600.0}{9.169518377}
-
-\vskip1cm
-\compare{0.000142}{-8.8596835}
-\compare{0.0054124}{-5.219062661}
-\compare{0.000912697124}{-6.9991064}
-
-\vskip1cm
-\compare{8.31160034e-02}{-2.48751801563782}%
-\compare{2.54685628e-02}{-3.67031041875206}%
-\compare{7.40715288e-03}{-4.90530914022879}%
-\compare{2.10192154e-03}{-6.16490333357987}%
-\compare{5.87352989e-04}{-7.43988457474844}%
-\compare{1.62269942e-04}{-8.72624930084187}%
-\compare{4.44248889e-05}{-10.0217106847708}%
-\compare{1.20714122e-05}{-11.3246705288704}%
-\compare{3.26101452e-06}{-12.6334722085451}%
-
-\vskip1cm
-\compare{5}{1.6094379124341}%
-\compare{17}{2.83321334405622}%
-\compare{39}{3.66356164612965}%
-\compare{49}{3.89182029811063}%
-\compare{129}{4.85981240436167}%
-\compare{321}{5.77144112313002}%
-\compare{769}{6.64509096950564}%
-\compare{1793}{7.49164547360513}%
-\compare{4097}{8.31801027754687}%
-\compare{9217}{9.12880488399366}%
-
-
-\testsection{Test for prettyprinter}
-%\tracingmacros=2\tracingcommands=2
-\message{PRETTY PRINTING}
-{
-\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}
-}
-
-\testsubsection{STD format}
-\pgfqkeys{/pgf/number format}{std}
-\prettytest
-
-{
-\testsubsubsection{precision 0}
-\pgfqkeys{/pgf/number format}{precision=0}
-\prettytest
-}
-
-{
-\testsubsection{FIXED format}
-\testsubsubsection{with period}
-\pgfqkeys{/pgf/number format}{fixed,use period}
-\prettytest
-
-{
-\testsubsubsection{precision 0}
-\pgfqkeys{/pgf/number format}{precision=0}
-\prettytest
-}
-{
-\testsubsubsection{skip 0.=true}
-\pgfqkeys{/pgf/number format}{skip 0.=true}
-\prettytest
-}
-
-{
-\testsubsubsection{1000 sep; min exponent for 1000 sep=4}
-\pgfqkeys{/pgf/number format}{1000 sep=',min exponent for 1000 sep=4}
-\prettytest
-}
-
-\testsubsubsection{with comma}
-\pgfqkeys{/pgf/number format}{fixed,use comma}
-\prettytest
-}
-
-
-{
-\testsubsection{FIXED ZEROFILL format}
-\testsubsubsection{with period}
-\pgfqkeys{/pgf/number format}{fixed,fixed zerofill,use period}
-\prettytest
-
-{
-\testsubsubsection{precision 0}
-\pgfqkeys{/pgf/number format}{precision=0}
-\prettytest
-}
-
-\testsubsubsection{with comma}
-\pgfqkeys{/pgf/number format}{fixed,fixed zerofill,use comma}
-%\tracingmacros=2\tracingcommands=2
-\prettytest
-%\tracingmacros=0\tracingcommands=0
-}
-
-{
-\testsubsection{sci format}
-\testsubsubsection{with period}
-\pgfqkeys{/pgf/number format}{sci,use period}
-\prettytest
-
-{
-\testsubsubsection{precision 0}
-\pgfqkeys{/pgf/number format}{precision=0}
-\prettytest
-}
-
-\testsubsubsection{with comma}
-\pgfqkeys{/pgf/number format}{sci,use comma}
-\prettytest
-
-%\testsubsection{may skip mantisse}
-%\pgfqkeys{/pgf/number format}{sci may skip mantisse=true}
-%\prettytest
-
-}{
-\testsubsection{sci format zerofill}
-\testsubsubsection{with period}
-\pgfqkeys{/pgf/number format}{sci,sci zerofill,use period}
-\prettytest
-
-\testsubsubsection{with comma}
-\pgfqkeys{/pgf/number format}{sci,sci zerofill,use comma}
-\prettytest
-
-\testsubsubsection{e-style}
-\pgfqkeys{/pgf/number format}{sci e}
-\prettytest
-
-\testsubsubsection{subscript-style}
-\pgfqkeys{/pgf/number format}{sci subscript}
-\prettytest
-
-\testsubsubsection{subscript-style + period + no zero fill}
-\pgfqkeys{/pgf/number format}{sci subscript,use period,sci}
-\prettytest
-
-\testsubsubsection{subscript-style precision 4}
-\pgfqkeys{/pgf/number format}{sci subscript,precision=4}
-\prettytest
-}
-
-\testsubsection{int trunc format}
-\pgfqkeys{/pgf/number format}{int trunc}
-\prettytest
-
-\testsubsection{int detect format}
-\pgfqkeys{/pgf/number format}{int detect}
-\prettytest
-
-\testsubsection{frac}
-\pgfqkeys{/pgf/number format}{frac}
-\pretty{0.333333333333333}
-\pretty{0.5}
-\pretty{2.133333333333325e-01}%
-\pretty{0.12}
-\pretty{2.666666666666646e-02}%
-\pretty{-1.333333333333334e-02}%
-\pretty{7.200000000000000e-01}%
-\pretty{6.666666666666667e-02}%
-\pretty{1.333333333333333e-01}%
-\pretty{-1.333333333333333e-02}%
-\pretty{8.533333333333298e-01}
-\pretty{8.533333e-01}
-}
-\onecolumn
-
-\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}%
-%\message{TEMP-TABLE: \n\meaning\temptable\n}%
- %
- \let\n=\relax
- \noindent
- \temptable
-}%
-%\tracingmacros=2 \tracingcommands=2
-
-\TESTIT{1,3}{1e-16,0,15,17,20}
-
-\TESTIT{0,1,3,4,5,6,7,8,9}{-100.123456,1e-16,1431,2000.1234,123456789.1234}
-
-
-
-\TESTIT{-4,-3,-2,-1,0,1,2,3}{0.0001,0.00012678,0.00013678,0.00016678,1.23,2.345,123.4,1234.5}
-
-{
-\subsection*{every relative/.style={sci}}
-\pgfkeys{/pgf/number format/every relative/.style={sci}}
-\TESTIT{-4,-3,-2,-1,0,1,2,3}{0.0001,0.00012678,0.00013678,0.00016678,1.23,2.345,123.4,1234.5}
-}
-
-\TESTIT{-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9}{-123.123456,123.1234565}
-{
-\subsection*{precision=4}
-\pgfkeys{/pgf/number format/precision=4}
-\TESTIT{-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9}{-123.123456,123.1234565}
-}
-}
-
-\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). \]
-}%
-\def\testfloatadd#1#2{%
- \testfloataddnonsymmetric{#1}{#2}%
- \testfloataddnonsymmetric{#2}{#1}%
-}%
-
-\testfloatadd{1}{100}
-\testfloatadd{100}{100}
-\testfloatadd{1}{2}
-\testfloatadd{1}{0}
-\testfloatadd{9.999999}{0}
-\testfloatadd{9.9999}{0.0001}
-\testfloatadd{9.9999e-5}{0.0001e-5}
-\testfloatadd{1e6}{1e5}
-\testfloatadd{1e6}{1e3}
-\testfloatadd{1e6}{1}
-\testfloatadd{1e6}{0.1}
-
-\testfloatadd{1}{-100}
-\testfloatadd{100}{-100}
-\testfloatadd{1}{-2}
-\testfloatadd{1e6}{-1e5}
-\testfloatadd{1e6}{-1e3}
-\testfloatadd{1e6}{-1}
-\testfloatadd{1e6}{-0.1}
-
-\testfloatadd{1e-3}{0}
-
-\testfloatadd{inf}{0}
-\testfloatadd{inf}{5}
-\testfloatadd{nan}{5}
-\testfloatadd{0}{0}
-\testfloatadd{-inf}{inf}
-\testfloatadd{-inf}{40}
-\endgroup
-
-\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). \]
-}%
-
-\testfloatmultiplyfixed{1}{100}
-\testfloatmultiplyfixed{100}{100}
-\testfloatmultiplyfixed{1}{2}
-\testfloatmultiplyfixed{5}{2}
-\testfloatmultiplyfixed{5e4}{10}
-\testfloatmultiplyfixed{1}{0}
-\testfloatmultiplyfixed{9.999999}{0}
-\testfloatmultiplyfixed{9.9999}{0.0001}
-\testfloatmultiplyfixed{9.9999e-5}{0.001}
-\testfloatmultiplyfixed{1e6}{4}
-\testfloatmultiplyfixed{1e6}{100}
-\testfloatmultiplyfixed{1e6}{1}
-\testfloatmultiplyfixed{1e6}{0.1}
-
-\testfloatmultiplyfixed{1}{-100}
-\testfloatmultiplyfixed{100}{-100}
-\testfloatmultiplyfixed{1}{-2}
-\testfloatmultiplyfixed{1e6}{-9}
-\testfloatmultiplyfixed{1e6}{-100}
-\testfloatmultiplyfixed{1e6}{-1}
-\testfloatmultiplyfixed{1e6}{-0.1}
-
-\testfloatmultiplyfixed{1e-3}{0}
-
-\testfloatmultiplyfixed{inf}{0}
-\testfloatmultiplyfixed{inf}{5}
-\testfloatmultiplyfixed{nan}{5}
-\testfloatmultiplyfixed{0}{0}
-\testfloatmultiplyfixed{-inf}{40}
-\endgroup
-
-
-\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). \]
-}%
-
-\testfloatlessthan{4}{5}
-\testfloatlessthan{0}{2}
-\testfloatlessthan{91751123}{241924}
-\testfloatlessthan{-1}{-1}
-\testfloatlessthan{-1231}{0}
-\testfloatlessthan{10}{-5}
-\testfloatlessthan{0}{0}
-\testfloatlessthan{-0}{-0}
-\testfloatlessthan{0}{14}
-\testfloatlessthan{114812}{-123124123}
-\testfloatlessthan{114812}{1241231451}
-\testfloatlessthan{-141285}{29}
-\testfloatlessthan{-141285}{0}
-\testfloatlessthan{-141285}{-50}
-\testfloatlessthan{-141285}{-12498149012}
-
-\testsection{float to fixed test}
-\def\testpgfmathfloattofixed#1{%
- \pgfmathfloatparsenumber{#1}%
-%\tracingmacros=2\tracingcommands=2
- \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 \]
-}%
-\testpgfmathfloattofixed{0}
-\testpgfmathfloattofixed{5}
-\testpgfmathfloattofixed{5.520241}
-\testpgfmathfloattofixed{124.10241}
-\testpgfmathfloattofixed{-121.248}
-\testpgfmathfloattofixed{-12e-5}
-\testpgfmathfloattofixed{412e3}
-\testpgfmathfloattofixed{0.0001}
-\testpgfmathfloattofixed{0.0}
-\testpgfmathfloattofixed{-0.012125}
-\testpgfmathfloattofixed{1.2e-1}
-\testpgfmathfloattofixed{1.2e-2}
-\testpgfmathfloattofixed{1.2e4}
-\testpgfmathfloattofixed{1.2345e4}
-\testpgfmathfloattofixed{1.234567e4}
-\testpgfmathfloattofixed{1.51234e0}
-\testpgfmathfloattofixed{15}
-\testpgfmathfloattofixed{-20}
-
-\testsection{Testing pgfmathfloatmin and pgfmathfloatmax}
-\def\testfloatminmax#1#2{%
- \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 \]
-}%
-\testfloatminmax{42}{56}
-\testfloatminmax{-4122}{1256}
-\testfloatminmax{1e12}{5.235412e24}
-\testfloatminmax{-12}{-145}
-
-\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 \]
-}%
-\pgfmathfloatshifttest{4}{1}
-\pgfmathfloatshifttest{4}{2}
-\pgfmathfloatshifttest{4}{-1}
-\pgfmathfloatshifttest{4}{-2}
-\pgfmathfloatshifttest{0}{-2}
-\pgfmathfloatshifttest{1.1415130}{-2}
-\pgfmathfloatshifttest{1.1415130}{5}
-
-\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 \]
-}%
-\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}
-}%
-\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 \]
-}%
-\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)\]
-}%
-\pgfmathfloattest{83407811.0}{166815640.0}{0.499999946048224}
-\endgroup
-
-
-{
-\testsection{Testing pgfmathfloatsqrt}
-% #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)\]
-}%
-\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}
-}%
-\tests
-}
-
-{
-\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 \]
-}%
-\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}
-}%
-\tests
-}
-
-{
-\testsection{Testing pgfmathfloatexp}
-% #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)\]
-}%
-%\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}
-}
-
-{
-\testsection{Testing pgfmathfloatmod}
-% #1 : operand 1
-% #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)\]
-}%
-%\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}
-}
-
-{
-\testsection{Testing Trigonometric functions}
-% #1 : operator
-% #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)\]
-}%
-%\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}
-
-
-
-\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}
-
-
-\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}
-
-
-
-}
-
-{
- % #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}