xref: /freebsd/contrib/arm-optimized-routines/math/aarch64/advsimd/sincospi.c (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1 /*
2  * Double-precision vector sincospi function.
3  *
4  * Copyright (c) 2024, Arm Limited.
5  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6  */
7 #include "v_sincospi_common.h"
8 #include "v_math.h"
9 #include "test_defs.h"
10 
11 /* Double-precision vector function allowing calculation of both sin and cos in
12    one function call, using separate argument reduction and shared low-order
13    polynomials.
14    Approximation for vector double-precision sincospi(x).
15    Maximum Error 3.09 ULP:
16   _ZGVnN2v_sincospi_sin(0x1.7a41deb4b21e1p+14) got 0x1.fd54d0b327cf1p-1
17 					      want 0x1.fd54d0b327cf4p-1
18    Maximum Error 3.16 ULP:
19   _ZGVnN2v_sincospi_cos(-0x1.11e3c7e284adep-5) got 0x1.fd2da484ff3ffp-1
20 					      want 0x1.fd2da484ff402p-1.  */
21 VPCS_ATTR void
22 _ZGVnN2vl8l8_sincospi (float64x2_t x, double *out_sin, double *out_cos)
23 {
24   const struct v_sincospi_data *d = ptr_barrier (&v_sincospi_data);
25 
26   float64x2x2_t sc = v_sincospi_inline (x, d);
27 
28   vst1q_f64 (out_sin, sc.val[0]);
29   vst1q_f64 (out_cos, sc.val[1]);
30 }
31 
32 #if WANT_TRIGPI_TESTS
33 TEST_DISABLE_FENV (_ZGVnN2v_sincospi_cos)
34 TEST_DISABLE_FENV (_ZGVnN2v_sincospi_sin)
35 TEST_ULP (_ZGVnN2v_sincospi_sin, 2.59)
36 TEST_ULP (_ZGVnN2v_sincospi_cos, 2.66)
37 #  define V_SINCOSPI_INTERVAL(lo, hi, n)                                      \
38     TEST_SYM_INTERVAL (_ZGVnN2v_sincospi_sin, lo, hi, n)                      \
39     TEST_SYM_INTERVAL (_ZGVnN2v_sincospi_cos, lo, hi, n)
40 V_SINCOSPI_INTERVAL (0, 0x1p-63, 10000)
41 V_SINCOSPI_INTERVAL (0x1p-63, 0.5, 50000)
42 V_SINCOSPI_INTERVAL (0.5, 0x1p63, 50000)
43 V_SINCOSPI_INTERVAL (0x1p63, inf, 10000)
44 #endif
45