| 1 |
% Copyright 2019 by Mark Wibrow |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
% This file defines the mathematical functions and operators. |
| 11 |
% |
| 12 |
% Version 1.4142135 11/8/2008 |
| 13 |
|
| 14 |
\pgfmathdeclarefunction{greater}{2}{% |
| 15 |
\begingroup% |
| 16 |
\ifdim#1pt>#2pt\relax% |
| 17 |
\def\pgfmathresult{1}% |
| 18 |
\else% |
| 19 |
\def\pgfmathresult{0}% |
| 20 |
\fi% |
| 21 |
\pgfmath@smuggleone\pgfmathresult% |
| 22 |
\endgroup% |
| 23 |
} |
| 24 |
\let\pgfmathgreaterthan=\pgfmathgreater |
| 25 |
|
| 26 |
\pgfmathdeclarefunction{less}{2}{% |
| 27 |
\begingroup% |
| 28 |
\ifdim#1pt<#2pt\relax% |
| 29 |
\def\pgfmathresult{1}% |
| 30 |
\else% |
| 31 |
\def\pgfmathresult{0}% |
| 32 |
\fi% |
| 33 |
\pgfmath@smuggleone\pgfmathresult% |
| 34 |
\endgroup% |
| 35 |
} |
| 36 |
\let\pgfmathlessthan=\pgfmathless |
| 37 |
|
| 38 |
\pgfmathdeclarefunction{equal}{2}{% |
| 39 |
\begingroup% |
| 40 |
\ifdim#1pt=#2pt\relax% |
| 41 |
\def\pgfmathresult{1}% |
| 42 |
\else% |
| 43 |
\def\pgfmathresult{0}% |
| 44 |
\fi% |
| 45 |
\pgfmath@smuggleone\pgfmathresult% |
| 46 |
\endgroup% |
| 47 |
} |
| 48 |
\let\pgfmathequalto=\pgfmathequal |
| 49 |
|
| 50 |
|
| 51 |
% approxequalto function from Christian Feuersaenger. |
| 52 |
% |
| 53 |
\newif\ifpgfmathcomparison |
| 54 |
\pgfmathdeclarefunction{approxequalto}{2}{% |
| 55 |
\begingroup% |
| 56 |
\pgfmath@x=#1pt\relax% |
| 57 |
\pgfmath@y=#2pt\relax% |
| 58 |
\advance\pgfmath@x by-\pgfmath@y% |
| 59 |
\ifdim\pgfmath@x<0pt\relax% |
| 60 |
\multiply\pgfmath@x by-1\relax% |
| 61 |
\fi |
| 62 |
\ifdim\pgfmath@x<0.0001pt\relax% |
| 63 |
\def\pgfmathresult{1.0}% |
| 64 |
\global\pgfmathcomparisontrue% |
| 65 |
\else% |
| 66 |
\def\pgfmathresult{0.0}% |
| 67 |
\global\pgfmathcomparisonfalse% |
| 68 |
\fi% |
| 69 |
\pgfmath@smuggleone\pgfmathresult% |
| 70 |
\endgroup% |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
% ifthenelse function. |
| 76 |
% |
| 77 |
\pgfmathdeclarefunction{ifthenelse}{3}{% |
| 78 |
\begingroup% |
| 79 |
\ifdim#1pt=0.0pt\relax% |
| 80 |
\expandafter\def\expandafter\pgfmathresult\expandafter{#3}% |
| 81 |
\else% |
| 82 |
\expandafter\def\expandafter\pgfmathresult\expandafter{#2}% |
| 83 |
\fi% |
| 84 |
\pgfmath@smuggleone\pgfmathresult% |
| 85 |
\endgroup% |
| 86 |
} |
| 87 |
|
| 88 |
% notequal function. |
| 89 |
% |
| 90 |
\pgfmathdeclarefunction{notequal}{2}{% |
| 91 |
\begingroup% |
| 92 |
\ifdim#1pt=#2pt\relax% |
| 93 |
\def\pgfmathresult{0}% |
| 94 |
\else% |
| 95 |
\def\pgfmathresult{1}% |
| 96 |
\fi% |
| 97 |
\pgfmath@smuggleone\pgfmathresult% |
| 98 |
\endgroup% |
| 99 |
} |
| 100 |
|
| 101 |
% notless function. |
| 102 |
% |
| 103 |
\pgfmathdeclarefunction{notless}{2}{% |
| 104 |
\begingroup% |
| 105 |
\ifdim#1pt<#2pt\relax% |
| 106 |
\def\pgfmathresult{0}% |
| 107 |
\else% |
| 108 |
\def\pgfmathresult{1}% |
| 109 |
\fi% |
| 110 |
\pgfmath@smuggleone\pgfmathresult% |
| 111 |
\endgroup% |
| 112 |
} |
| 113 |
|
| 114 |
% notgreater function. |
| 115 |
% |
| 116 |
\pgfmathdeclarefunction{notgreater}{2}{% |
| 117 |
\begingroup% |
| 118 |
\ifdim#1pt>#2pt\relax% |
| 119 |
\def\pgfmathresult{0}% |
| 120 |
\else% |
| 121 |
\def\pgfmathresult{1}% |
| 122 |
\fi% |
| 123 |
\pgfmath@smuggleone\pgfmathresult% |
| 124 |
\endgroup% |
| 125 |
} |
| 126 |
|
| 127 |
% and function. |
| 128 |
% |
| 129 |
\pgfmathdeclarefunction{and}{2}{% |
| 130 |
\begingroup% |
| 131 |
\def\pgfmathresult{1}% |
| 132 |
\ifdim#1pt=0pt\relax% |
| 133 |
\def\pgfmathresult{0}% |
| 134 |
\else% |
| 135 |
\ifdim#2pt=0pt\relax% |
| 136 |
\def\pgfmathresult{0}% |
| 137 |
\fi% |
| 138 |
\fi% |
| 139 |
\pgfmath@smuggleone\pgfmathresult% |
| 140 |
\endgroup% |
| 141 |
} |
| 142 |
|
| 143 |
% or function. |
| 144 |
% |
| 145 |
\pgfmathdeclarefunction{or}{2}{% |
| 146 |
\begingroup% |
| 147 |
\def\pgfmathresult{0}% |
| 148 |
\ifdim#1pt=0pt\relax% |
| 149 |
\ifdim#2pt=0pt\relax% |
| 150 |
\else% |
| 151 |
\def\pgfmathresult{1}% |
| 152 |
\fi% |
| 153 |
\else% |
| 154 |
\def\pgfmathresult{1}% |
| 155 |
\fi% |
| 156 |
\pgfmath@smuggleone\pgfmathresult% |
| 157 |
\endgroup% |
| 158 |
} |
| 159 |
|
| 160 |
% not function. |
| 161 |
% |
| 162 |
\pgfmathdeclarefunction{not}{1}{% |
| 163 |
\begingroup% |
| 164 |
\ifdim#1pt=0pt\relax% |
| 165 |
\def\pgfmathresult{1}% |
| 166 |
\else% |
| 167 |
\def\pgfmathresult{0}% |
| 168 |
\fi% |
| 169 |
\pgfmath@smuggleone\pgfmathresult% |
| 170 |
\endgroup% |
| 171 |
} |
| 172 |
|
| 173 |
% true function. |
| 174 |
% |
| 175 |
\pgfmathdeclarefunction{true}{0}{\def\pgfmathresult{1}} |
| 176 |
|
| 177 |
% false function. |
| 178 |
% |
| 179 |
\pgfmathdeclarefunction{false}{0}{\def\pgfmathresult{0}} |