Line data Source code
1 : /*
2 : * SPDX-License-Identifier: MPL-2.0
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * Copyright 2024 MonetDB Foundation;
9 : * Copyright August 2008 - 2023 MonetDB B.V.;
10 : * Copyright 1997 - July 2008 CWI.
11 : */
12 :
13 : #include "monetdb_config.h"
14 : #include <fenv.h>
15 : #include "mmath_private.h"
16 : #include "mal_exception.h"
17 : #include "mal_interpreter.h"
18 :
19 : static str
20 118 : CMDscienceUNARY(MalStkPtr stk, InstrPtr pci,
21 : float (*ffunc)(float), double(*dfunc)(double),
22 : const char *malfunc)
23 : {
24 118 : bat bid;
25 118 : BAT *bn, *b, *s = NULL;
26 118 : struct canditer ci;
27 118 : oid x, off;
28 118 : BUN i;
29 118 : BUN nils = 0;
30 118 : int e = 0, ex = 0;
31 118 : BATiter bi;
32 :
33 118 : bid = *getArgReference_bat(stk, pci, 1);
34 118 : if ((b = BATdescriptor(bid)) == NULL)
35 0 : throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
36 :
37 118 : if (pci->argc == 3) {
38 13 : bid = *getArgReference_bat(stk, pci, 2);
39 13 : if (!is_bat_nil(bid)) {
40 0 : if ((s = BATdescriptor(bid)) == NULL) {
41 0 : BBPunfix(b->batCacheid);
42 0 : throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
43 : }
44 : }
45 : }
46 :
47 118 : canditer_init(&ci, b, s);
48 118 : off = b->hseqbase;
49 118 : bn = COLnew(ci.hseq, b->ttype, ci.ncand, TRANSIENT);
50 118 : if (bn == NULL || ci.ncand == 0) {
51 21 : BBPunfix(b->batCacheid);
52 21 : BBPreclaim(s);
53 21 : if (bn == NULL)
54 0 : throw(MAL, malfunc, GDK_EXCEPTION);
55 21 : goto doreturn;
56 : }
57 :
58 97 : errno = 0;
59 97 : feclearexcept(FE_ALL_EXCEPT);
60 97 : bi = bat_iterator(b);
61 97 : switch (b->ttype) {
62 17 : case TYPE_flt:{
63 17 : const flt *restrict fsrc = (const flt *) bi.base;
64 17 : flt *restrict fdst = (flt *) Tloc(bn, 0);
65 73 : for (i = 0; i < ci.ncand; i++) {
66 56 : x = canditer_next(&ci) - off;
67 56 : if (is_flt_nil(fsrc[x])) {
68 2 : fdst[i] = flt_nil;
69 2 : nils++;
70 : } else {
71 54 : fdst[i] = ffunc(fsrc[x]);
72 : }
73 : }
74 : break;
75 : }
76 80 : case TYPE_dbl:{
77 80 : const dbl *restrict dsrc = (const dbl *) bi.base;
78 80 : dbl *restrict ddst = (dbl *) Tloc(bn, 0);
79 2076 : for (i = 0; i < ci.ncand; i++) {
80 1997 : x = canditer_next(&ci) - off;
81 1996 : if (is_dbl_nil(dsrc[x])) {
82 433 : ddst[i] = dbl_nil;
83 433 : nils++;
84 : } else {
85 1563 : ddst[i] = dfunc(dsrc[x]);
86 : }
87 : }
88 : break;
89 : }
90 : default:
91 0 : assert(0);
92 : }
93 96 : bat_iterator_end(&bi);
94 97 : e = errno;
95 97 : ex = fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
96 97 : BBPunfix(b->batCacheid);
97 97 : BBPreclaim(s);
98 97 : if (e != 0 || ex != 0) {
99 0 : const char *err;
100 0 : char buf[128];
101 0 : BBPunfix(bn->batCacheid);
102 0 : if (e)
103 0 : err = GDKstrerror(e, buf, 128);
104 0 : else if (ex & FE_DIVBYZERO)
105 : err = "Divide by zero";
106 0 : else if (ex & FE_OVERFLOW)
107 : err = "Overflow";
108 : else
109 0 : err = "Invalid result";
110 0 : throw(MAL, malfunc, "Math exception: %s", err);
111 : }
112 :
113 97 : BATsetcount(bn, ci.ncand);
114 97 : bn->tsorted = false;
115 97 : bn->trevsorted = false;
116 97 : bn->tnil = nils != 0;
117 97 : bn->tnonil = nils == 0;
118 97 : BATkey(bn, false);
119 118 : doreturn:
120 118 : *getArgReference_bat(stk, pci, 0) = bn->batCacheid;
121 118 : BBPkeepref(bn);
122 118 : return MAL_SUCCEED;
123 : }
124 :
125 : static str
126 4 : CMDscienceBINARY(MalStkPtr stk, InstrPtr pci,
127 : float (*ffunc)(float, float), double(*dfunc)(double, double),
128 : const char *malfunc)
129 : {
130 4 : bat bid;
131 4 : BAT *bn, *b1 = NULL, *b2 = NULL, *s1 = NULL, *s2 = NULL;
132 4 : int tp1, tp2;
133 4 : struct canditer ci1 = (struct canditer) { 0 },
134 4 : ci2 = (struct canditer) { 0 };
135 4 : oid x1, x2, off1, off2;
136 4 : BUN i, ncand, nils = 0;
137 4 : int e = 0, ex = 0;
138 4 : BATiter b1i, b2i;
139 :
140 4 : tp1 = stk->stk[getArg(pci, 1)].vtype;
141 4 : tp2 = stk->stk[getArg(pci, 2)].vtype;
142 :
143 4 : if (stk->stk[getArg(pci, 1)].bat) {
144 4 : bid = *getArgReference_bat(stk, pci, 1);
145 4 : b1 = BATdescriptor(bid);
146 4 : if (b1 == NULL)
147 0 : goto bailout;
148 4 : tp1 = b1->ttype;
149 : }
150 :
151 4 : if (stk->stk[getArg(pci, 2)].bat) {
152 1 : bid = *getArgReference_bat(stk, pci, 2);
153 1 : b2 = BATdescriptor(bid);
154 1 : if (b2 == NULL)
155 0 : goto bailout;
156 1 : tp2 = b2->ttype;
157 : }
158 4 : tp1 = ATOMbasetype(tp1);
159 4 : tp2 = ATOMbasetype(tp2);
160 4 : assert(tp1 == tp2);
161 4 : assert(b1 != NULL || b2 != NULL);
162 :
163 4 : if (pci->argc > 4) {
164 0 : assert(pci->argc == 5);
165 0 : bid = *getArgReference_bat(stk, pci, 4);
166 0 : if (!is_bat_nil(bid)) {
167 0 : s2 = BATdescriptor(bid);
168 0 : if (s2 == NULL)
169 0 : goto bailout;
170 : }
171 : }
172 4 : if (pci->argc > 3) {
173 0 : bid = *getArgReference_bat(stk, pci, 3);
174 0 : if (!is_bat_nil(bid)) {
175 0 : s1 = BATdescriptor(bid);
176 0 : if (s1 == NULL)
177 0 : goto bailout;
178 0 : if (b1 == NULL) {
179 0 : s2 = s1;
180 0 : s1 = NULL;
181 : }
182 : }
183 : }
184 :
185 4 : if (b1)
186 4 : canditer_init(&ci1, b1, s1);
187 4 : if (b2)
188 1 : canditer_init(&ci2, b2, s2);
189 4 : ncand = b1 ? ci1.ncand : ci2.ncand;
190 4 : off1 = b1 ? b1->hseqbase : 0;
191 4 : off2 = b2 ? b2->hseqbase : 0;
192 :
193 4 : if (b1 == NULL &&
194 : (tp1 == TYPE_flt ?
195 0 : is_flt_nil(stk->stk[getArg(pci, 1)].val.fval) :
196 0 : is_dbl_nil(stk->stk[getArg(pci, 1)].val.dval))) {
197 0 : bn = BATconstant(ci2.hseq, tp1, ATOMnilptr(tp1), ncand, TRANSIENT);
198 0 : goto doreturn;
199 : }
200 7 : if (b2 == NULL &&
201 : (tp1 == TYPE_flt ?
202 0 : is_flt_nil(stk->stk[getArg(pci, 2)].val.fval) :
203 3 : is_dbl_nil(stk->stk[getArg(pci, 2)].val.dval))) {
204 0 : bn = BATconstant(ci1.hseq, tp1, ATOMnilptr(tp1), ncand, TRANSIENT);
205 0 : goto doreturn;
206 : }
207 4 : if (b1)
208 4 : bn = COLnew(ci1.hseq, tp1, ncand, TRANSIENT);
209 : else
210 0 : bn = COLnew(ci2.hseq, tp1, ncand, TRANSIENT);
211 4 : if (bn == NULL || ncand == 0)
212 3 : goto doreturn;
213 :
214 1 : b1i = bat_iterator(b1);
215 1 : b2i = bat_iterator(b2);
216 1 : errno = 0;
217 1 : feclearexcept(FE_ALL_EXCEPT);
218 1 : switch (tp1) {
219 0 : case TYPE_flt:
220 0 : if (b1 && b2) {
221 0 : const flt *fsrc1 = (const flt *) b1i.base;
222 0 : const flt *fsrc2 = (const flt *) b2i.base;
223 0 : flt *restrict fdst = (flt *) Tloc(bn, 0);
224 0 : for (i = 0; i < ncand; i++) {
225 0 : x1 = canditer_next(&ci1) - off1;
226 0 : x2 = canditer_next(&ci2) - off2;
227 0 : if (is_flt_nil(fsrc1[x1]) || is_flt_nil(fsrc2[x2])) {
228 0 : fdst[i] = flt_nil;
229 0 : nils++;
230 : } else {
231 0 : fdst[i] = ffunc(fsrc1[x1], fsrc2[x2]);
232 : }
233 : }
234 0 : } else if (b1) {
235 0 : const flt *restrict fsrc1 = (const flt *) b1i.base;
236 0 : flt fval2 = stk->stk[getArg(pci, 2)].val.fval;
237 0 : flt *restrict fdst = (flt *) Tloc(bn, 0);
238 0 : for (i = 0; i < ncand; i++) {
239 0 : x1 = canditer_next(&ci1) - off1;
240 0 : if (is_flt_nil(fsrc1[x1])) {
241 0 : fdst[i] = flt_nil;
242 0 : nils++;
243 : } else {
244 0 : fdst[i] = ffunc(fsrc1[x1], fval2);
245 : }
246 : }
247 : } else { /* b2 == NULL */
248 0 : flt fval1 = stk->stk[getArg(pci, 1)].val.fval;
249 0 : const flt *restrict fsrc2 = (const flt *) b2i.base;
250 0 : flt *restrict fdst = (flt *) Tloc(bn, 0);
251 0 : for (i = 0; i < ncand; i++) {
252 0 : x2 = canditer_next(&ci2) - off2;
253 0 : if (is_flt_nil(fsrc2[x2])) {
254 0 : fdst[i] = flt_nil;
255 0 : nils++;
256 : } else {
257 0 : fdst[i] = ffunc(fval1, fsrc2[x2]);
258 : }
259 : }
260 : }
261 : break;
262 1 : case TYPE_dbl:
263 1 : if (b1 && b2) {
264 1 : const dbl *dsrc1 = (const dbl *) b1i.base;
265 1 : const dbl *dsrc2 = (const dbl *) b2i.base;
266 1 : dbl *restrict ddst = (dbl *) Tloc(bn, 0);
267 9 : for (i = 0; i < ncand; i++) {
268 8 : x1 = canditer_next(&ci1) - off1;
269 8 : x2 = canditer_next(&ci2) - off2;
270 8 : if (is_dbl_nil(dsrc1[x1]) || is_dbl_nil(dsrc2[x2])) {
271 0 : ddst[i] = dbl_nil;
272 0 : nils++;
273 : } else {
274 8 : ddst[i] = dfunc(dsrc1[x1], dsrc2[x2]);
275 : }
276 : }
277 0 : } else if (b1) {
278 0 : const dbl *restrict dsrc1 = (const dbl *) b1i.base;
279 0 : dbl dval2 = stk->stk[getArg(pci, 2)].val.dval;
280 0 : dbl *restrict ddst = (dbl *) Tloc(bn, 0);
281 0 : for (i = 0; i < ncand; i++) {
282 0 : x1 = canditer_next(&ci1) - off1;
283 0 : if (is_dbl_nil(dsrc1[x1])) {
284 0 : ddst[i] = dbl_nil;
285 0 : nils++;
286 : } else {
287 0 : ddst[i] = dfunc(dsrc1[x1], dval2);
288 : }
289 : }
290 : } else { /* b2 == NULL */
291 0 : dbl dval1 = stk->stk[getArg(pci, 1)].val.dval;
292 0 : const dbl *restrict dsrc2 = (const dbl *) b2i.base;
293 0 : dbl *restrict ddst = (dbl *) Tloc(bn, 0);
294 0 : for (i = 0; i < ncand; i++) {
295 0 : x2 = canditer_next(&ci2) - off2;
296 0 : if (is_dbl_nil(dsrc2[x2])) {
297 0 : ddst[i] = dbl_nil;
298 0 : nils++;
299 : } else {
300 0 : ddst[i] = dfunc(dval1, dsrc2[x2]);
301 : }
302 : }
303 : }
304 : break;
305 : default:
306 0 : assert(0);
307 : }
308 1 : e = errno;
309 1 : ex = fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
310 1 : bat_iterator_end(&b1i);
311 1 : bat_iterator_end(&b2i);
312 :
313 1 : BATsetcount(bn, ncand);
314 1 : bn->tsorted = false;
315 1 : bn->trevsorted = false;
316 1 : bn->tnil = nils != 0;
317 1 : bn->tnonil = nils == 0;
318 1 : BATkey(bn, false);
319 :
320 4 : doreturn:
321 4 : BBPreclaim(b1);
322 4 : BBPreclaim(b2);
323 4 : BBPreclaim(s1);
324 4 : BBPreclaim(s2);
325 4 : if (bn == NULL)
326 0 : throw(MAL, malfunc, GDK_EXCEPTION);
327 4 : if (e != 0 || ex != 0) {
328 0 : const char *err;
329 0 : char buf[128];
330 0 : BBPunfix(bn->batCacheid);
331 0 : if (e)
332 0 : err = GDKstrerror(e, buf, 128);
333 0 : else if (ex & FE_DIVBYZERO)
334 : err = "Divide by zero";
335 0 : else if (ex & FE_OVERFLOW)
336 : err = "Overflow";
337 : else
338 0 : err = "Invalid result";
339 0 : throw(MAL, malfunc, "Math exception: %s", err);
340 : }
341 4 : *getArgReference_bat(stk, pci, 0) = bn->batCacheid;
342 4 : BBPkeepref(bn);
343 4 : return MAL_SUCCEED;
344 :
345 0 : bailout:
346 0 : BBPreclaim(b1);
347 0 : BBPreclaim(b2);
348 : /* cannot happen
349 : BBPreclaim(s1);
350 : */
351 0 : BBPreclaim(s2);
352 0 : throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
353 : }
354 :
355 : #define scienceImpl(FUNC) \
356 : static str \
357 : CMDscience_bat_##FUNC(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) \
358 : { \
359 : (void) cntxt; \
360 : (void) mb; \
361 : \
362 : return CMDscienceUNARY(stk, pci, FUNC##f, FUNC, "batmmath." #FUNC); \
363 : }
364 :
365 : #define scienceBinaryImpl(FUNC) \
366 : static str \
367 : CMDscience_bat_##FUNC(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) \
368 : { \
369 : (void) cntxt; \
370 : (void) mb; \
371 : \
372 : return CMDscienceBINARY(stk, pci, FUNC##f, FUNC, "batmmath." #FUNC); \
373 : }
374 :
375 : static str
376 14 : CMDscience_bat_randintarg(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
377 : InstrPtr pci)
378 : {
379 14 : BAT *bn = NULL, *b = NULL, *bs = NULL;
380 14 : BUN q = 0;
381 14 : int *restrict vals;
382 14 : struct canditer ci = { 0 };
383 14 : bat *res = getArgReference_bat(stk, pci, 0);
384 :
385 14 : (void) cntxt;
386 14 : if (isaBatType(getArgType(mb, pci, 1))) {
387 0 : bat *bid = getArgReference_bat(stk, pci, 1),
388 0 : *sid = pci->argc == 3 ? getArgReference_bat(stk, pci, 2) : NULL;
389 0 : if (!(b = BBPquickdesc(*bid))) {
390 0 : throw(MAL, "batmmath.rand", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
391 : }
392 0 : if (sid && !is_bat_nil(*sid) && !(bs = BATdescriptor(*sid))) {
393 0 : throw(MAL, "batmmath.rand", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
394 : }
395 0 : canditer_init(&ci, b, bs);
396 0 : q = ci.ncand;
397 0 : BBPreclaim(bs);
398 : } else {
399 14 : q = (BUN) *getArgReference_lng(stk, pci, 1);
400 : }
401 :
402 14 : if (!(bn = COLnew(ci.hseq, TYPE_int, q, TRANSIENT))) {
403 0 : throw(MAL, "batmmath.rand", SQLSTATE(HY013) MAL_MALLOC_FAIL);
404 : }
405 :
406 14 : vals = Tloc(bn, 0);
407 : #ifdef __COVERITY__
408 : for (BUN i = 0; i < q; i++)
409 : vals[i] = 0;
410 : #else
411 14 : MT_lock_set(&mmath_rse_lock);
412 505059 : for (BUN i = 0; i < q; i++)
413 505045 : vals[i] = (int) (next(mmath_rse) >> 33);
414 14 : MT_lock_unset(&mmath_rse_lock);
415 : #endif
416 :
417 14 : BATsetcount(bn, q);
418 14 : bn->tnil = false;
419 14 : bn->tnonil = true;
420 14 : bn->tkey = BATcount(bn) <= 1;
421 14 : bn->tsorted = BATcount(bn) <= 1;
422 14 : bn->trevsorted = BATcount(bn) <= 1;
423 14 : *res = bn->batCacheid;
424 14 : BBPkeepref(bn);
425 14 : return MAL_SUCCEED;
426 : }
427 :
428 4 : scienceImpl(acos)
429 1 : scienceImpl(asin)
430 0 : scienceImpl(atan)
431 4 : scienceImpl(cos)
432 2 : scienceImpl(sin)
433 0 : scienceImpl(tan)
434 4 : scienceImpl(cot)
435 0 : scienceImpl(cosh)
436 5 : scienceImpl(sinh)
437 0 : scienceImpl(tanh)
438 5 : scienceImpl(radians)
439 5 : scienceImpl(degrees)
440 12 : scienceImpl(exp)
441 17 : scienceImpl(log)
442 2 : scienceImpl(log10)
443 0 : scienceImpl(log2)
444 17 : scienceImpl(sqrt)
445 3 : scienceImpl(cbrt)
446 5 : scienceImpl(ceil)
447 0 : scienceImpl(fabs)
448 32 : scienceImpl(floor)
449 0 : scienceBinaryImpl(atan2)
450 4 : scienceBinaryImpl(pow)
451 0 : scienceBinaryImpl(logbs)
452 :
453 : #include "mel.h"
454 : mel_func batmmath_init_funcs[] = {
455 : pattern("batmmath", "asin", CMDscience_bat_asin, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
456 : pattern("batmmath", "asin", CMDscience_bat_asin, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
457 : pattern("batmmath", "asin", CMDscience_bat_asin, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
458 : pattern("batmmath", "asin", CMDscience_bat_asin, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
459 : pattern("batmmath", "acos", CMDscience_bat_acos, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
460 : pattern("batmmath", "acos", CMDscience_bat_acos, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
461 : pattern("batmmath", "acos", CMDscience_bat_acos, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
462 : pattern("batmmath", "acos", CMDscience_bat_acos, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
463 : pattern("batmmath", "atan", CMDscience_bat_atan, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
464 : pattern("batmmath", "atan", CMDscience_bat_atan, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
465 : pattern("batmmath", "atan", CMDscience_bat_atan, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
466 : pattern("batmmath", "atan", CMDscience_bat_atan, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
467 : pattern("batmmath", "cos", CMDscience_bat_cos, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
468 : pattern("batmmath", "cos", CMDscience_bat_cos, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
469 : pattern("batmmath", "cos", CMDscience_bat_cos, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
470 : pattern("batmmath", "cos", CMDscience_bat_cos, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
471 : pattern("batmmath", "sin", CMDscience_bat_sin, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
472 : pattern("batmmath", "sin", CMDscience_bat_sin, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
473 : pattern("batmmath", "sin", CMDscience_bat_sin, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
474 : pattern("batmmath", "sin", CMDscience_bat_sin, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
475 : pattern("batmmath", "tan", CMDscience_bat_tan, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
476 : pattern("batmmath", "tan", CMDscience_bat_tan, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
477 : pattern("batmmath", "tan", CMDscience_bat_tan, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
478 : pattern("batmmath", "tan", CMDscience_bat_tan, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
479 : pattern("batmmath", "cot", CMDscience_bat_cot, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
480 : pattern("batmmath", "cot", CMDscience_bat_cot, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
481 : pattern("batmmath", "cot", CMDscience_bat_cot, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
482 : pattern("batmmath", "cot", CMDscience_bat_cot, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
483 : pattern("batmmath", "cosh", CMDscience_bat_cosh, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
484 : pattern("batmmath", "cosh", CMDscience_bat_cosh, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
485 : pattern("batmmath", "cosh", CMDscience_bat_cosh, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
486 : pattern("batmmath", "cosh", CMDscience_bat_cosh, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
487 : pattern("batmmath", "sinh", CMDscience_bat_sinh, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
488 : pattern("batmmath", "sinh", CMDscience_bat_sinh, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
489 : pattern("batmmath", "sinh", CMDscience_bat_sinh, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
490 : pattern("batmmath", "sinh", CMDscience_bat_sinh, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
491 : pattern("batmmath", "tanh", CMDscience_bat_tanh, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
492 : pattern("batmmath", "tanh", CMDscience_bat_tanh, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
493 : pattern("batmmath", "tanh", CMDscience_bat_tanh, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
494 : pattern("batmmath", "tanh", CMDscience_bat_tanh, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
495 : pattern("batmmath", "radians", CMDscience_bat_radians, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
496 : pattern("batmmath", "radians", CMDscience_bat_radians, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
497 : pattern("batmmath", "radians", CMDscience_bat_radians, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
498 : pattern("batmmath", "radians", CMDscience_bat_radians, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
499 : pattern("batmmath", "degrees", CMDscience_bat_degrees, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
500 : pattern("batmmath", "degrees", CMDscience_bat_degrees, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
501 : pattern("batmmath", "degrees", CMDscience_bat_degrees, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
502 : pattern("batmmath", "degrees", CMDscience_bat_degrees, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
503 : pattern("batmmath", "exp", CMDscience_bat_exp, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
504 : pattern("batmmath", "exp", CMDscience_bat_exp, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
505 : pattern("batmmath", "exp", CMDscience_bat_exp, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
506 : pattern("batmmath", "exp", CMDscience_bat_exp, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
507 : pattern("batmmath", "log", CMDscience_bat_log, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
508 : pattern("batmmath", "log", CMDscience_bat_log, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
509 : pattern("batmmath", "log", CMDscience_bat_log, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
510 : pattern("batmmath", "log", CMDscience_bat_log, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
511 : pattern("batmmath", "log10", CMDscience_bat_log10, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
512 : pattern("batmmath", "log10", CMDscience_bat_log10, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
513 : pattern("batmmath", "log10", CMDscience_bat_log10, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
514 : pattern("batmmath", "log10", CMDscience_bat_log10, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
515 : pattern("batmmath", "log2", CMDscience_bat_log2, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
516 : pattern("batmmath", "log2", CMDscience_bat_log2, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
517 : pattern("batmmath", "log2", CMDscience_bat_log2, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
518 : pattern("batmmath", "log2", CMDscience_bat_log2, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
519 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),arg("y",dbl))),
520 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,4, batarg("",dbl),batarg("x",dbl),arg("y",dbl),batarg("s",oid))),
521 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("y",dbl))),
522 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,5, batarg("",dbl),batarg("x",dbl),batarg("y",dbl),batarg("s1",oid),batarg("s2",oid))),
523 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,3, batarg("",flt),batarg("x",flt),arg("y",flt))),
524 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,4, batarg("",flt),batarg("x",flt),arg("y",flt),batarg("s",oid))),
525 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("y",flt))),
526 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,5, batarg("",flt),batarg("x",flt),batarg("y",flt),batarg("s1",oid),batarg("s2",oid))),
527 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,3, batarg("",dbl),arg("x",dbl),batarg("y",dbl))),
528 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,4, batarg("",dbl),arg("x",dbl),batarg("y",dbl),batarg("s",oid))),
529 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,3, batarg("",flt),arg("x",flt),batarg("y",flt))),
530 : pattern("batmmath", "log2arg", CMDscience_bat_logbs, false, "", args(1,4, batarg("",flt),arg("x",flt),batarg("y",flt),batarg("s",oid))),
531 : pattern("batmmath", "sqrt", CMDscience_bat_sqrt, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
532 : pattern("batmmath", "sqrt", CMDscience_bat_sqrt, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
533 : pattern("batmmath", "sqrt", CMDscience_bat_sqrt, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
534 : pattern("batmmath", "sqrt", CMDscience_bat_sqrt, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
535 : pattern("batmmath", "cbrt", CMDscience_bat_cbrt, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
536 : pattern("batmmath", "cbrt", CMDscience_bat_cbrt, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
537 : pattern("batmmath", "cbrt", CMDscience_bat_cbrt, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
538 : pattern("batmmath", "cbrt", CMDscience_bat_cbrt, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
539 : pattern("batmmath", "ceil", CMDscience_bat_ceil, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
540 : pattern("batmmath", "ceil", CMDscience_bat_ceil, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
541 : pattern("batmmath", "ceil", CMDscience_bat_ceil, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
542 : pattern("batmmath", "ceil", CMDscience_bat_ceil, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
543 : pattern("batmmath", "fabs", CMDscience_bat_fabs, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
544 : pattern("batmmath", "fabs", CMDscience_bat_fabs, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
545 : pattern("batmmath", "fabs", CMDscience_bat_fabs, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
546 : pattern("batmmath", "fabs", CMDscience_bat_fabs, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
547 : pattern("batmmath", "floor", CMDscience_bat_floor, false, "", args(1,2, batarg("",dbl),batarg("x",dbl))),
548 : pattern("batmmath", "floor", CMDscience_bat_floor, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("s",oid))),
549 : pattern("batmmath", "floor", CMDscience_bat_floor, false, "", args(1,2, batarg("",flt),batarg("x",flt))),
550 : pattern("batmmath", "floor", CMDscience_bat_floor, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("s",oid))),
551 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),arg("y",dbl))),
552 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,4, batarg("",dbl),batarg("x",dbl),arg("y",dbl),batarg("s",oid))),
553 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("y",dbl))),
554 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,5, batarg("",dbl),batarg("x",dbl),batarg("y",dbl),batarg("s1",oid),batarg("s2",oid))),
555 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,3, batarg("",flt),batarg("x",flt),arg("y",flt))),
556 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,4, batarg("",flt),batarg("x",flt),arg("y",flt),batarg("s",oid))),
557 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("y",flt))),
558 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,5, batarg("",flt),batarg("x",flt),batarg("y",flt),batarg("s1",oid),batarg("s2",oid))),
559 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,3, batarg("",dbl),arg("x",dbl),batarg("y",dbl))),
560 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,4, batarg("",dbl),arg("x",dbl),batarg("y",dbl),batarg("s",oid))),
561 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,3, batarg("",flt),arg("x",flt),batarg("y",flt))),
562 : pattern("batmmath", "atan2", CMDscience_bat_atan2, false, "", args(1,4, batarg("",flt),arg("x",flt),batarg("y",flt),batarg("s",oid))),
563 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),arg("y",dbl))),
564 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4, batarg("",dbl),batarg("x",dbl),arg("y",dbl),batarg("s",oid))),
565 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,3, batarg("",dbl),batarg("x",dbl),batarg("y",dbl))),
566 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,5, batarg("",dbl),batarg("x",dbl),batarg("y",dbl),batarg("s1",oid),batarg("s2",oid))),
567 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,3, batarg("",flt),batarg("x",flt),arg("y",flt))),
568 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4, batarg("",flt),batarg("x",flt),arg("y",flt),batarg("s",oid))),
569 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,3, batarg("",flt),batarg("x",flt),batarg("y",flt))),
570 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,5, batarg("",flt),batarg("x",flt),batarg("y",flt),batarg("s1",oid),batarg("s2",oid))),
571 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,3, batarg("",dbl),arg("x",dbl),batarg("y",dbl))),
572 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4, batarg("",dbl),arg("x",dbl),batarg("y",dbl),batarg("s",oid))),
573 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,3, batarg("",flt),arg("x",flt),batarg("y",flt))),
574 : pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4, batarg("",flt),arg("x",flt),batarg("y",flt),batarg("s",oid))),
575 : pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,2, batarg("",int),batarg("v",int))),
576 : pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,3, batarg("",int),batarg("v",int),batarg("s",oid))),
577 : pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,2, batarg("",int),arg("card",lng))), /* version with cardinality input */
578 : { .imp=NULL }
579 : };
580 : #include "mal_import.h"
581 : #ifdef _MSC_VER
582 : #undef read
583 : #pragma section(".CRT$XCU",read)
584 : #endif
585 320 : LIB_STARTUP_FUNC(init_batmmath_mal)
586 320 : { mal_module("batmmath", NULL, batmmath_init_funcs); }
|