Path: blob/main/contrib/arm-optimized-routines/math/aarch64/experimental/atanf_common.h
48375 views
/*1* Single-precision polynomial evaluation function for scalar2* atan(x) and atan2(y,x).3*4* Copyright (c) 2021-2024, Arm Limited.5* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception6*/78#ifndef PL_MATH_ATANF_COMMON_H9#define PL_MATH_ATANF_COMMON_H1011#include "math_config.h"12#include "poly_scalar_f32.h"1314/* Polynomial used in fast atanf(x) and atan2f(y,x) implementations15The order 7 polynomial P approximates (atan(sqrt(x))-sqrt(x))/x^(3/2). */16static inline float17eval_poly (float z, float az, float shift)18{19/* Use 2-level Estrin scheme for P(z^2) with deg(P)=7. However,20a standard implementation using z8 creates spurious underflow21in the very last fma (when z^8 is small enough).22Therefore, we split the last fma into a mul and and an fma.23Horner and single-level Estrin have higher errors that exceed24threshold. */25float z2 = z * z;26float z4 = z2 * z2;2728/* Then assemble polynomial. */29float y = fmaf (30z4, z4 * pairwise_poly_3_f32 (z2, z4, __atanf_poly_data.poly + 4),31pairwise_poly_3_f32 (z2, z4, __atanf_poly_data.poly));32/* Finalize:33y = shift + z * P(z^2). */34return fmaf (y, z2 * az, az) + shift;35}3637#endif // PL_MATH_ATANF_COMMON_H383940