| 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) \ |
| 22 | mal_export str CMDscience_bat_dbl_##X1(bat *ret, const bat *bid); \ |
| 23 | mal_export str CMDscience_bat_flt_##X1(bat *ret, const bat *bid); \ |
| 24 | mal_export str CMDscience_bat_dbl_##X1##_cand(bat *ret, const bat *bid, const bat *sid); \ |
| 25 | mal_export str CMDscience_bat_flt_##X1##_cand(bat *ret, const bat *bid, const bat *sid); |
| 26 | |
| 27 | scienceDef(asin) |
| 28 | scienceDef(acos) |
| 29 | scienceDef(atan) |
| 30 | scienceDef(cos) |
| 31 | scienceDef(sin) |
| 32 | scienceDef(tan) |
| 33 | scienceDef(cosh) |
| 34 | scienceDef(sinh) |
| 35 | scienceDef(tanh) |
| 36 | scienceDef(radians) |
| 37 | scienceDef(degrees) |
| 38 | scienceDef(exp) |
| 39 | scienceDef(log) |
| 40 | scienceDef(log10) |
| 41 | scienceDef(log2) |
| 42 | scienceDef(sqrt) |
| 43 | scienceDef(cbrt) |
| 44 | scienceDef(ceil) |
| 45 | scienceDef(fabs) |
| 46 | scienceDef(floor) |
| 47 | |
| 48 | #define scienceBinaryDef(F) \ |
| 49 | mal_export str CMDscience_bat_cst_##F##_dbl(bat *ret, const bat *bid, const dbl *d); \ |
| 50 | mal_export str CMDscience_bat_cst_##F##_dbl_cand(bat *ret, const bat *bid, const dbl *d, const bat *sid); \ |
| 51 | mal_export str CMDscience_bat_cst_##F##_flt(bat *ret, const bat *bid, const flt *d); \ |
| 52 | mal_export str CMDscience_bat_cst_##F##_flt_cand(bat *ret, const bat *bid, const flt *d, const bat *sid); \ |
| 53 | mal_export str CMDscience_cst_bat_##F##_dbl(bat *ret, const dbl *d, const bat *bid); \ |
| 54 | mal_export str CMDscience_cst_bat_##F##_dbl_cand(bat *ret, const dbl *d, const bat *bid, const bat *sid); \ |
| 55 | mal_export str CMDscience_cst_bat_##F##_flt(bat *ret, const flt *d, const bat *bid); \ |
| 56 | mal_export str CMDscience_cst_bat_##F##_flt_cand(bat *ret, const flt *d, const bat *bid, const bat *sid); |
| 57 | |
| 58 | scienceBinaryDef(atan2) |
| 59 | scienceBinaryDef(pow) |
| 60 | scienceBinaryDef(log) |
| 61 | |
| 62 | #endif /* _BATMATH_H */ |
| 63 | |