1 /* 2 * Double-precision vector cexpi function. 3 * 4 * Copyright (c) 2023, Arm Limited. 5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception 6 */ 7 8 #include "sv_sincos_common.h" 9 #include "sv_math.h" 10 #include "pl_test.h" 11 12 static svfloat64x2_t NOINLINE 13 special_case (svfloat64_t x, svbool_t special, svfloat64x2_t y) 14 { 15 return svcreate2 (sv_call_f64 (sin, x, svget2 (y, 0), special), 16 sv_call_f64 (cos, x, svget2 (y, 1), special)); 17 } 18 19 /* Double-precision vector function allowing calculation of both sin and cos in 20 one function call, using shared argument reduction and separate polynomials. 21 Largest observed error is for sin, 3.22 ULP: 22 sv_cexpi_sin (0x1.d70eef40f39b1p+12) got -0x1.ffe9537d5dbb7p-3 23 want -0x1.ffe9537d5dbb4p-3. */ 24 svfloat64x2_t 25 _ZGVsMxv_cexpi (svfloat64_t x, svbool_t pg) 26 { 27 const struct sv_sincos_data *d = ptr_barrier (&sv_sincos_data); 28 svbool_t special = check_ge_rangeval (pg, x, d); 29 30 svfloat64x2_t sc = sv_sincos_inline (pg, x, d); 31 32 if (unlikely (svptest_any (pg, special))) 33 return special_case (x, special, sc); 34 return sc; 35 } 36 37 PL_TEST_ULP (_ZGVsMxv_cexpi_sin, 2.73) 38 PL_TEST_ULP (_ZGVsMxv_cexpi_cos, 2.73) 39 #define SV_CEXPI_INTERVAL(lo, hi, n) \ 40 PL_TEST_INTERVAL (_ZGVsMxv_cexpi_sin, lo, hi, n) \ 41 PL_TEST_INTERVAL (_ZGVsMxv_cexpi_cos, lo, hi, n) 42 SV_CEXPI_INTERVAL (0, 0x1p23, 500000) 43 SV_CEXPI_INTERVAL (-0, -0x1p23, 500000) 44 SV_CEXPI_INTERVAL (0x1p23, inf, 10000) 45 SV_CEXPI_INTERVAL (-0x1p23, -inf, 10000) 46