summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison.code.tex
blob: 54a8d64220ebba49a62a69e9376f64d43af54340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
% Copyright 2007 by Mark Wibrow
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

% This file defines the mathematical functions and operators.
%
% Version 1.4142135 11/8/2008

\pgfmathdeclarefunction{greater}{2}{%
  \begingroup%
    \ifdim#1pt>#2pt\relax%
    	\def\pgfmathresult{1}%
    \else%
      \def\pgfmathresult{0}%
    \fi%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}
\let\pgfmathgreaterthan=\pgfmathgreater

\pgfmathdeclarefunction{less}{2}{%
  \begingroup%
    \ifdim#1pt<#2pt\relax%
    	\def\pgfmathresult{1}%
    \else%
      \def\pgfmathresult{0}%
    \fi%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}
\let\pgfmathlessthan=\pgfmathless

\pgfmathdeclarefunction{equal}{2}{%
  \begingroup%
    \ifdim#1pt=#2pt\relax%
    	\def\pgfmathresult{1}%
    \else%
      \def\pgfmathresult{0}%
    \fi%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}
\let\pgfmathequalto=\pgfmathequal


% approxequalto function from Christian Feuersanger.
%
\newif\ifpgfmathcomparison
\pgfmathdeclarefunction{approxequalto}{2}{%
	\begingroup%
		\pgfmath@x=#1pt\relax%
		\pgfmath@y=#2pt\relax%
		\advance\pgfmath@x by-\pgfmath@y%
		\ifdim\pgfmath@x<0pt\relax%
			\multiply\pgfmath@x by-1\relax%
		\fi
		\ifdim\pgfmath@x<0.0001pt\relax%
			\def\pgfmathresult{1.0}%
			\global\pgfmathcomparisontrue%
		\else%
			\def\pgfmathresult{0.0}%
			\global\pgfmathcomparisonfalse%
		\fi%
	\pgfmath@smuggleone\pgfmathresult%
	\endgroup%
}



% ifthenelse function.
%
\pgfmathdeclarefunction{ifthenelse}{3}{%
	\begingroup%
		\ifdim#1pt=0.0pt\relax%
			\expandafter\def\expandafter\pgfmathresult\expandafter{#3}%
		\else%
			\expandafter\def\expandafter\pgfmathresult\expandafter{#2}%
		\fi%
		\pgfmath@smuggleone\pgfmathresult%
	\endgroup%
}

% notequal function.
%
\pgfmathdeclarefunction{notequal}{2}{%
  \begingroup%
    \ifdim#1pt=#2pt\relax%
 			\def\pgfmathresult{0}%
    \else%
      \def\pgfmathresult{1}%
    \fi%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}

% notless function.
%
\pgfmathdeclarefunction{notless}{2}{%
  \begingroup%
    \ifdim#1pt<#2pt\relax%
 			\def\pgfmathresult{0}%
    \else%
      \def\pgfmathresult{1}%
    \fi%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}

% notgreater function.
%
\pgfmathdeclarefunction{notgreater}{2}{%
  \begingroup%
    \ifdim#1pt>#2pt\relax%
 			\def\pgfmathresult{0}%
    \else%
      \def\pgfmathresult{1}%
    \fi%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}

% and function.
%
\pgfmathdeclarefunction{and}{2}{%
  \begingroup%
  	\def\pgfmathresult{1}%
    \ifdim#1pt=0pt\relax%
 			\def\pgfmathresult{0}%
 		\else%
 			\ifdim#2pt=0pt\relax%
				\def\pgfmathresult{0}%
			\fi%
		\fi%
	 \pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}

% or function.
%
\pgfmathdeclarefunction{or}{2}{%
  \begingroup%
  	\def\pgfmathresult{0}%
    \ifdim#1pt=0pt\relax%	
 			\ifdim#2pt=0pt\relax%
 			\else%
				\def\pgfmathresult{1}%
			\fi%
		\else%
			\def\pgfmathresult{1}%
		\fi%
	\pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}

% not function.
%
\pgfmathdeclarefunction{not}{1}{%
  \begingroup%
  	\ifdim#1pt=0pt\relax%	
 			\def\pgfmathresult{1}%
		\else%
			\def\pgfmathresult{0}%
		\fi%
	\pgfmath@smuggleone\pgfmathresult%
  \endgroup%
}

% true function.
%
\pgfmathdeclarefunction{true}{0}{\def\pgfmathresult{1}}

% false function.
%
\pgfmathdeclarefunction{false}{0}{\def\pgfmathresult{0}}