aboutsummaryrefslogtreecommitdiff
path: root/math/aarch64/sve/cexpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/aarch64/sve/cexpi.c')
-rw-r--r--math/aarch64/sve/cexpi.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/math/aarch64/sve/cexpi.c b/math/aarch64/sve/cexpi.c
new file mode 100644
index 000000000000..0ccd110484c8
--- /dev/null
+++ b/math/aarch64/sve/cexpi.c
@@ -0,0 +1,48 @@
+/*
+ * Double-precision vector cexpi function.
+ *
+ * Copyright (c) 2023-2024, Arm Limited.
+ * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
+ */
+
+#include "sv_math.h"
+#include "sv_sincos_common.h"
+#include "test_defs.h"
+
+static svfloat64x2_t NOINLINE
+special_case (svfloat64_t x, svbool_t special, svfloat64x2_t y)
+{
+ return svcreate2 (sv_call_f64 (sin, x, svget2 (y, 0), special),
+ sv_call_f64 (cos, x, svget2 (y, 1), special));
+}
+
+/* Double-precision vector function allowing calculation of both sin and cos in
+ one function call, using shared argument reduction and separate polynomials.
+ Largest observed error is for sin, 3.22 ULP:
+ sv_cexpi_sin (0x1.d70eef40f39b1p+12) got -0x1.ffe9537d5dbb7p-3
+ want -0x1.ffe9537d5dbb4p-3. */
+svfloat64x2_t
+_ZGVsMxv_cexpi (svfloat64_t x, svbool_t pg)
+{
+ const struct sv_sincos_data *d = ptr_barrier (&sv_sincos_data);
+ svbool_t special = check_ge_rangeval (pg, x, d);
+
+ svfloat64x2_t sc = sv_sincos_inline (pg, x, d);
+
+ if (unlikely (svptest_any (pg, special)))
+ return special_case (x, special, sc);
+ return sc;
+}
+
+TEST_DISABLE_FENV (_ZGVsMxv_cexpi_sin)
+TEST_DISABLE_FENV (_ZGVsMxv_cexpi_cos)
+TEST_ULP (_ZGVsMxv_cexpi_sin, 2.73)
+TEST_ULP (_ZGVsMxv_cexpi_cos, 2.73)
+#define SV_CEXPI_INTERVAL(lo, hi, n) \
+ TEST_INTERVAL (_ZGVsMxv_cexpi_sin, lo, hi, n) \
+ TEST_INTERVAL (_ZGVsMxv_cexpi_cos, lo, hi, n)
+SV_CEXPI_INTERVAL (0, 0x1p23, 500000)
+SV_CEXPI_INTERVAL (-0, -0x1p23, 500000)
+SV_CEXPI_INTERVAL (0x1p23, inf, 10000)
+SV_CEXPI_INTERVAL (-0x1p23, -inf, 10000)
+CLOSE_SVE_ATTR