-
Notifications
You must be signed in to change notification settings - Fork 4
/
lpeval_wrappers_math.inc
224 lines (179 loc) · 7.63 KB
/
lpeval_wrappers_math.inc
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
{
Author: Niels A.D
Project: Lape (http://code.google.com/p/la-pe/)
License: GNU Lesser GPL (http://www.gnu.org/licenses/lgpl.html)
This include constains all the wrappers for math related functions.
}
{%MainUnit lpeval.pas}
procedure _LapeMin(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Min(PInt64(Params^[0])^, PInt64(Params^[1])^);
end;
procedure _LapeMinF(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Min(PExtended(Params^[0])^, PExtended(Params^[1])^);
end;
procedure _LapeMax(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Max(PInt64(Params^[0])^, PInt64(Params^[1])^);
end;
procedure _LapeMaxF(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Max(PExtended(Params^[0])^, PExtended(Params^[1])^);
end;
procedure _LapeAbs(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Abs(PExtended(Params^[0])^);
end;
procedure _LapeAbsI(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Abs(PInt64(Params^[0])^);
end;
procedure _LapeSign(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt8(Result)^ := Sign(PInt64(Params^[0])^);
end;
procedure _LapeSignF(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt8(Result)^ := Sign(PExtended(Params^[0])^);
end;
procedure _LapePower(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Power(PExtended(Params^[0])^, PExtended(Params^[1])^);
end;
procedure _LapeSqr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Sqr(PExtended(Params^[0])^);
end;
procedure _LapeSqrI(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := PInt64(Params^[0])^*PInt64(Params^[0])^;
end;
procedure _LapeSqrt(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Sqrt(PExtended(Params^[0])^);
end;
procedure _LapeArcTan(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcTan(PExtended(Params^[0])^);
end;
procedure _LapeLn(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Ln(PExtended(Params^[0])^);
end;
procedure _LapeSin(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Sin(PExtended(Params^[0])^);
end;
procedure _LapeCos(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Cos(PExtended(Params^[0])^);
end;
procedure _LapeExp(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Exp(PExtended(Params^[0])^);
end;
procedure _LapeHypot(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Hypot(PExtended(Params^[0])^, PExtended(Params^[1])^);
end;
procedure _LapeArcTan2(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcTan2(PExtended(Params^[0])^, PExtended(Params^[1])^);
end;
procedure _LapeTan(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Tan(PExtended(Params^[0])^);
end;
procedure _LapeArcSin(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcSin(PExtended(Params^[0])^);
end;
procedure _LapeArcCos(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcCos(PExtended(Params^[0])^);
end;
procedure _LapeCotan(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Cotan(PExtended(Params^[0])^);
end;
procedure _LapeSecant(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Secant(PExtended(Params^[0])^);
end;
procedure _LapeCosecant(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Cosecant(PExtended(Params^[0])^);
end;
procedure _LapeRound(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Round(PExtended(Params^[0])^);
end;
procedure _LapeRoundTo(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := RoundTo(PExtended(Params^[0])^, -PInt8(Params^[1])^);
end;
procedure _LapeFrac(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Frac(PExtended(Params^[0])^);
end;
procedure _LapeInt(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Int(PExtended(Params^[0])^);
end;
procedure _LapeTrunc(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Trunc(PExtended(Params^[0])^);
end;
procedure _LapeCeil(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Ceil(PExtended(Params^[0])^);
end;
procedure _LapeFloor(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PInt64(Result)^ := Floor(PExtended(Params^[0])^);
end;
procedure _LapeCosH(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := CosH(PExtended(Params^[0])^);
end;
procedure _LapeSinH(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := SinH(PExtended(Params^[0])^);
end;
procedure _LapeTanH(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := TanH(PExtended(Params^[0])^);
end;
procedure _LapeArcCosH(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcCosH(PExtended(Params^[0])^);
end;
procedure _LapeArcSinH(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcSinH(PExtended(Params^[0])^);
end;
procedure _LapeArcTanH(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := ArcTanH(PExtended(Params^[0])^);
end;
procedure _LapeRandomRange(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
Pint64(Result)^ := PInt64(Params^[0])^ + Random(PInt64(Params^[1])^ - PInt64(Params^[0])^ + 1);
end;
procedure _LapeRandomRangeF(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := PExtended(Params^[0])^ + Random()*(PExtended(Params^[1])^ - PExtended(Params^[0])^);
end;
procedure _LapeRandom(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
Pint64(Result)^ := Random(PInt64(Params^[0])^);
end;
procedure _LapeRandomF(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PExtended(Result)^ := Random();
end;
procedure _LapeRandomize(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
Randomize();
end;