From 13f808b5520d5f16f5fb22f36f66b2df888d01cf Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 8 May 2023 10:50:05 +0200 Subject: [PATCH] Added acos/asin(h) and atanh --- lib/std/math/math.c3 | 74 ++++++++++++++++++++++++++++++++++++++++++-- src/version.h | 2 +- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/lib/std/math/math.c3 b/lib/std/math/math.c3 index fab48e14f..c93b1e893 100644 --- a/lib/std/math/math.c3 +++ b/lib/std/math/math.c3 @@ -146,7 +146,7 @@ macro atan2(x, y) * @checked (*y)[0] = x, y.len * @require y.len == 2 **/ -macro @sincos(x, y) +macro sincos(x, y) { $if $typeof(y[0]).typeid == float.typeid: return _sincosf(x, y); @@ -168,6 +168,66 @@ macro atan(x) $endif } +/** + * @require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value" + **/ +macro atanh(x) +{ + $if $typeof(x).typeid == float.typeid: + return _atanhf(x); + $else + return _atanh(x); + $endif +} + +/** + * @require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value" + **/ +macro acos(x) +{ + $if $typeof(x).typeid == float.typeid: + return _acosf(x); + $else + return _acos(x); + $endif +} + +/** + * @require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value" + **/ +macro acosh(x) +{ + $if $typeof(x).typeid == float.typeid: + return _acoshf(x); + $else + return _acosh(x); + $endif +} + +/** + * @require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value" + **/ +macro asin(x) +{ + $if $typeof(x).typeid == float.typeid: + return _asinf(x); + $else + return _asin(x); + $endif +} + +/** + * @require values::@is_int(x) || values::@is_float(x) "Expected an integer or floating point value" + **/ +macro asinh(x) +{ + $if $typeof(x).typeid == float.typeid: + return _asinhf(x); + $else + return _asinh(x); + $endif +} + /** * @require values::@is_floatlike(x) `The input must be a floating point value or float vector` **/ @@ -813,7 +873,6 @@ macro uint float.word(float d) => bitcast(d, uint); macro double scalbn(double x, int n) => _scalbn(x, n); - extern fn double _atan(double x) @extern("atan"); extern fn float _atanf(float x) @extern("atanf"); extern fn double _atan2(double, double) @extern("atan2"); @@ -823,6 +882,17 @@ extern fn void _sincosf(float, float*) @extern("sincosf"); extern fn double _tan(double x) @extern("tan"); extern fn float _tanf(float x) @extern("tanf"); extern fn double _scalbn(double x, int n) @extern("scalbn"); +extern fn double _acos(double x) @extern("acos"); +extern fn double _asin(double x) @extern("asin"); +extern fn double _acosh(double x) @extern("acosh"); +extern fn double _asinh(double x) @extern("asinh"); +extern fn double _atanh(double x) @extern("atanh"); +extern fn float _acosf(float x) @extern("acosf"); +extern fn float _asinf(float x) @extern("asinf"); +extern fn float _acoshf(float x) @extern("acoshf"); +extern fn float _asinhf(float x) @extern("asinhf"); +extern fn float _atanhf(float x) @extern("atanhf"); + fn double _frexp(double x, int* e) { diff --git a/src/version.h b/src/version.h index 94cbd866e..862dcafe1 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.505" \ No newline at end of file +#define COMPILER_VERSION "0.4.506" \ No newline at end of file