1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
7 */
8
9#ifndef _BATMATH_H
10#define _BATMATH_H
11#include "gdk.h"
12#include <math.h>
13#include "mal_exception.h"
14
15#define radians(x) ((x) * 3.14159265358979323846 / 180.0)
16#define degrees(x) ((x) * 180.0 / 3.14159265358979323846)
17#define radiansf(x) ((flt) radians(x))
18#define degreesf(x) ((flt) degrees(x))
19
20
21#define scienceDef(X1) \
22mal_export str CMDscience_bat_dbl_##X1(bat *ret, const bat *bid); \
23mal_export str CMDscience_bat_flt_##X1(bat *ret, const bat *bid); \
24mal_export str CMDscience_bat_dbl_##X1##_cand(bat *ret, const bat *bid, const bat *sid); \
25mal_export str CMDscience_bat_flt_##X1##_cand(bat *ret, const bat *bid, const bat *sid);
26
27scienceDef(asin)
28scienceDef(acos)
29scienceDef(atan)
30scienceDef(cos)
31scienceDef(sin)
32scienceDef(tan)
33scienceDef(cosh)
34scienceDef(sinh)
35scienceDef(tanh)
36scienceDef(radians)
37scienceDef(degrees)
38scienceDef(exp)
39scienceDef(log)
40scienceDef(log10)
41scienceDef(log2)
42scienceDef(sqrt)
43scienceDef(cbrt)
44scienceDef(ceil)
45scienceDef(fabs)
46scienceDef(floor)
47
48#define scienceBinaryDef(F) \
49mal_export str CMDscience_bat_cst_##F##_dbl(bat *ret, const bat *bid, const dbl *d); \
50mal_export str CMDscience_bat_cst_##F##_dbl_cand(bat *ret, const bat *bid, const dbl *d, const bat *sid); \
51mal_export str CMDscience_bat_cst_##F##_flt(bat *ret, const bat *bid, const flt *d); \
52mal_export str CMDscience_bat_cst_##F##_flt_cand(bat *ret, const bat *bid, const flt *d, const bat *sid); \
53mal_export str CMDscience_cst_bat_##F##_dbl(bat *ret, const dbl *d, const bat *bid); \
54mal_export str CMDscience_cst_bat_##F##_dbl_cand(bat *ret, const dbl *d, const bat *bid, const bat *sid); \
55mal_export str CMDscience_cst_bat_##F##_flt(bat *ret, const flt *d, const bat *bid); \
56mal_export str CMDscience_cst_bat_##F##_flt_cand(bat *ret, const flt *d, const bat *bid, const bat *sid);
57
58scienceBinaryDef(atan2)
59scienceBinaryDef(pow)
60scienceBinaryDef(log)
61
62#endif /* _BATMATH_H */
63