1
1
#include < cmath>
2
+ #include < memory>
3
+
4
+ #include " ../dispatchkit/dispatchkit.hpp"
5
+ #include " ../chaiscript.hpp"
2
6
3
7
namespace chaiscript {
4
8
namespace extras {
@@ -8,7 +12,154 @@ namespace chaiscript {
8
12
{
9
13
// using the overloads provided by C++11
10
14
// http://www.cplusplus.com/reference/cmath/floor/
11
- m->add (chaiscript::fun (static_cast <Ret (Param)>(&std::floor)), " floor" );
15
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::floor)), " floor" );
16
+ return m;
17
+ }
18
+
19
+ template <typename Ret, typename Param>
20
+ ModulePtr cos (ModulePtr m = std::make_shared<Module>())
21
+ {
22
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::cos)), " cos" );
23
+ return m;
24
+ }
25
+
26
+ template <typename Ret, typename Param>
27
+ ModulePtr sin (ModulePtr m = std::make_shared<Module>())
28
+ {
29
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::sin)), " sin" );
30
+ return m;
31
+ }
32
+
33
+ template <typename Ret, typename Param>
34
+ ModulePtr tan (ModulePtr m = std::make_shared<Module>())
35
+ {
36
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::tan)), " tan" );
37
+ return m;
38
+ }
39
+
40
+ template <typename Ret, typename Param>
41
+ ModulePtr acos (ModulePtr m = std::make_shared<Module>())
42
+ {
43
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::acos)), " acos" );
44
+ return m;
45
+ }
46
+
47
+ template <typename Ret, typename Param>
48
+ ModulePtr asin (ModulePtr m = std::make_shared<Module>())
49
+ {
50
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::asin)), " asin" );
51
+ return m;
52
+ }
53
+
54
+ template <typename Ret, typename Param>
55
+ ModulePtr atan (ModulePtr m = std::make_shared<Module>())
56
+ {
57
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::atan)), " atan" );
58
+ return m;
59
+ }
60
+
61
+ template <typename Ret, typename Param1, typename Param2>
62
+ ModulePtr atan2 (ModulePtr m = std::make_shared<Module>())
63
+ {
64
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param1, Param2)>(&std::atan2)), " atan2" );
65
+ return m;
66
+ }
67
+
68
+ template <typename Ret, typename Param>
69
+ ModulePtr cosh (ModulePtr m = std::make_shared<Module>())
70
+ {
71
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::cosh)), " cosh" );
72
+ return m;
73
+ }
74
+
75
+ template <typename Ret, typename Param>
76
+ ModulePtr sinh (ModulePtr m = std::make_shared<Module>())
77
+ {
78
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::sinh)), " sinh" );
79
+ return m;
80
+ }
81
+
82
+ template <typename Ret, typename Param>
83
+ ModulePtr tanh (ModulePtr m = std::make_shared<Module>())
84
+ {
85
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::tanh)), " tanh" );
86
+ return m;
87
+ }
88
+
89
+ template <typename Ret, typename Param>
90
+ ModulePtr acosh (ModulePtr m = std::make_shared<Module>())
91
+ {
92
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::acosh)), " acosh" );
93
+ return m;
94
+ }
95
+
96
+ template <typename Ret, typename Param>
97
+ ModulePtr asinh (ModulePtr m = std::make_shared<Module>())
98
+ {
99
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::asinh)), " asinh" );
100
+ return m;
101
+ }
102
+
103
+ template <typename Ret, typename Param>
104
+ ModulePtr atanh (ModulePtr m = std::make_shared<Module>())
105
+ {
106
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::atanh)), " atanh" );
107
+ return m;
108
+ }
109
+
110
+ template <typename Ret, typename Param1, typename Param2>
111
+ ModulePtr pow (ModulePtr m = std::make_shared<Module>())
112
+ {
113
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param1, Param2)>(&std::pow)), " pow" );
114
+ return m;
115
+ }
116
+
117
+ template <typename Ret, typename Param>
118
+ ModulePtr sqrt (ModulePtr m = std::make_shared<Module>())
119
+ {
120
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::sqrt)), " sqrt" );
121
+ return m;
122
+ }
123
+
124
+ template <typename Ret, typename Param>
125
+ ModulePtr cbrt (ModulePtr m = std::make_shared<Module>())
126
+ {
127
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::cbrt)), " cbrt" );
128
+ return m;
129
+ }
130
+
131
+ template <typename Ret, typename Param1, typename Param2>
132
+ ModulePtr hypot (ModulePtr m = std::make_shared<Module>())
133
+ {
134
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param1, Param2)>(&std::hypot)), " hypot" );
135
+ return m;
136
+ }
137
+
138
+ template <typename Ret, typename Param>
139
+ ModulePtr erf (ModulePtr m = std::make_shared<Module>())
140
+ {
141
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::erf)), " erf" );
142
+ return m;
143
+ }
144
+
145
+ template <typename Ret, typename Param>
146
+ ModulePtr erfc (ModulePtr m = std::make_shared<Module>())
147
+ {
148
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::erfc)), " erfc" );
149
+ return m;
150
+ }
151
+
152
+ template <typename Ret, typename Param>
153
+ ModulePtr tgamma (ModulePtr m = std::make_shared<Module>())
154
+ {
155
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::tgamma)), " tgamma" );
156
+ return m;
157
+ }
158
+
159
+ template <typename Ret, typename Param>
160
+ ModulePtr lgamma (ModulePtr m = std::make_shared<Module>())
161
+ {
162
+ m->add (chaiscript::fun (static_cast <Ret (*)(Param)>(&std::lgamma)), " lgamma" );
12
163
return m;
13
164
}
14
165
@@ -18,6 +169,90 @@ namespace chaiscript {
18
169
floor<long double , long double >(m);
19
170
floor<float , float >(m);
20
171
172
+ cos<double , double >(m);
173
+ cos<float , float >(m);
174
+ cos<long double , long double >(m);
175
+
176
+ sin<double , double >(m);
177
+ sin<float , float >(m);
178
+ sin<long double , long double >(m);
179
+
180
+ tan<double , double >(m);
181
+ tan<float , float >(m);
182
+ tan<long double , long double >(m);
183
+
184
+ acos<double , double >(m);
185
+ acos<float , float >(m);
186
+ acos<long double , long double >(m);
187
+
188
+ asin<double , double >(m);
189
+ asin<float , float >(m);
190
+ asin<long double , long double >(m);
191
+
192
+ atan<double , double >(m);
193
+ atan<float , float >(m);
194
+ atan<long double , long double >(m);
195
+
196
+ atan2<double , double , double >(m);
197
+ atan2<float , float , float >(m);
198
+ atan2<long double , long double , long double >(m);
199
+
200
+ cosh<double , double >(m);
201
+ cosh<float , float >(m);
202
+ cosh<long double , long double >(m);
203
+
204
+ sinh<double , double >(m);
205
+ sinh<float , float >(m);
206
+ sinh<long double , long double >(m);
207
+
208
+ tanh<double , double >(m);
209
+ tanh<float , float >(m);
210
+ tanh<long double , long double >(m);
211
+
212
+ acosh<double , double >(m);
213
+ acosh<float , float >(m);
214
+ acosh<long double , long double >(m);
215
+
216
+ asinh<double , double >(m);
217
+ asinh<float , float >(m);
218
+ asinh<long double , long double >(m);
219
+
220
+ atanh<double , double >(m);
221
+ atanh<float , float >(m);
222
+ atanh<long double , long double >(m);
223
+
224
+ pow<double , double , double >(m);
225
+ pow<float , float , float >(m);
226
+ pow<long double , long double , long double >(m);
227
+
228
+ sqrt<double , double >(m);
229
+ sqrt<float , float >(m);
230
+ sqrt<long double , long double >(m);
231
+
232
+ cbrt<double , double >(m);
233
+ cbrt<float , float >(m);
234
+ cbrt<long double , long double >(m);
235
+
236
+ hypot<double , double , double >(m);
237
+ hypot<float , float , float >(m);
238
+ hypot<long double , long double , long double >(m);
239
+
240
+ erf<double , double >(m);
241
+ erf<float , float >(m);
242
+ erf<long double , long double >(m);
243
+
244
+ erfc<double , double >(m);
245
+ erfc<float , float >(m);
246
+ erfc<long double , long double >(m);
247
+
248
+ tgamma<double , double >(m);
249
+ tgamma<float , float >(m);
250
+ tgamma<long double , long double >(m);
251
+
252
+ lgamma<double , double >(m);
253
+ lgamma<float , float >(m);
254
+ lgamma<long double , long double >(m);
255
+
21
256
return m;
22
257
}
23
258
}
0 commit comments