aboutsummaryrefslogtreecommitdiff
path: root/math/aarch64/experimental/atan_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'math/aarch64/experimental/atan_common.h')
-rw-r--r--math/aarch64/experimental/atan_common.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/math/aarch64/experimental/atan_common.h b/math/aarch64/experimental/atan_common.h
new file mode 100644
index 000000000000..1fd83860219b
--- /dev/null
+++ b/math/aarch64/experimental/atan_common.h
@@ -0,0 +1,33 @@
+/*
+ * Double-precision polynomial evaluation function for scalar
+ * atan(x) and atan2(y,x).
+ *
+ * Copyright (c) 2021-2024, Arm Limited.
+ * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
+ */
+
+#include "math_config.h"
+#include "poly_scalar_f64.h"
+
+/* Polynomial used in fast atan(x) and atan2(y,x) implementations
+ The order 19 polynomial P approximates (atan(sqrt(x))-sqrt(x))/x^(3/2). */
+static inline double
+eval_poly (double z, double az, double shift)
+{
+ /* Use split Estrin scheme for P(z^2) with deg(P)=19. Use split instead of
+ full scheme to avoid underflow in x^16. */
+ double z2 = z * z;
+ double x2 = z2 * z2;
+ double x4 = x2 * x2;
+ double x8 = x4 * x4;
+ double y = fma (estrin_11_f64 (z2, x2, x4, x8, __atan_poly_data.poly + 8),
+ x8, estrin_7_f64 (z2, x2, x4, __atan_poly_data.poly));
+
+ /* Finalize. y = shift + z + z^3 * P(z^2). */
+ y = fma (y, z2 * az, az);
+ y = y + shift;
+
+ return y;
+}
+
+#undef P