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