1 /*
2 * Double-precision SVE sincospi(x, *y, *z) function.
3 *
4 * Copyright (c) 2024, Arm Limited.
5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6 */
7
8 #include "sv_math.h"
9 #include "test_defs.h"
10 #include "mathlib.h"
11 #include "sv_sincospi_common.h"
12
13 /* Double-precision vector function allowing calculation of both sinpi and
14 cospi in one function call, using shared argument reduction and polynomials.
15 Worst-case error for sin is 3.09 ULP:
16 _ZGVsMxvl8l8_sincospi_sin(0x1.7a41deb4b21e1p+14) got 0x1.fd54d0b327cf1p-1
17 want 0x1.fd54d0b327cf4p-1.
18 Worst-case error for sin is 3.16 ULP:
19 _ZGVsMxvl8l8_sincospi_cos(-0x1.11e3c7e284adep-5) got 0x1.fd2da484ff3ffp-1
20 want 0x1.fd2da484ff402p-1.
21 */
22 void
_ZGVsMxvl8l8_sincospi(svfloat64_t x,double * out_sin,double * out_cos,svbool_t pg)23 _ZGVsMxvl8l8_sincospi (svfloat64_t x, double *out_sin, double *out_cos,
24 svbool_t pg)
25 {
26 const struct sv_sincospi_data *d = ptr_barrier (&sv_sincospi_data);
27
28 svfloat64x2_t sc = sv_sincospi_inline (pg, x, d);
29
30 svst1 (pg, out_sin, svget2 (sc, 0));
31 svst1 (pg, out_cos, svget2 (sc, 1));
32 }
33
34 #if WANT_TRIGPI_TESTS
35 TEST_DISABLE_FENV (_ZGVsMxvl8l8_sincospi_sin)
36 TEST_DISABLE_FENV (_ZGVsMxvl8l8_sincospi_cos)
37 TEST_ULP (_ZGVsMxvl8l8_sincospi_sin, 2.59)
38 TEST_ULP (_ZGVsMxvl8l8_sincospi_cos, 2.66)
39 # define SV_SINCOSPI_INTERVAL(lo, hi, n) \
40 TEST_SYM_INTERVAL (_ZGVsMxvl8l8_sincospi_sin, lo, hi, n) \
41 TEST_SYM_INTERVAL (_ZGVsMxvl8l8_sincospi_cos, lo, hi, n)
42 SV_SINCOSPI_INTERVAL (0, 0x1p-63, 10000)
43 SV_SINCOSPI_INTERVAL (0x1p-63, 0.5, 50000)
44 SV_SINCOSPI_INTERVAL (0.5, 0x1p53, 50000)
45 SV_SINCOSPI_INTERVAL (0x1p53, inf, 10000)
46 #endif
47 CLOSE_SVE_ATTR
48