2 * Single-precision sin function.
4 * Copyright (c) 2018-2019, Arm Limited.
5 * SPDX-License-Identifier: MIT
9 #include "math_config.h"
12 /* Fast sinf implementation. Worst-case ULP is 0.5607, maximum relative
13 error is 0.5303 * 2^-23. A single-step range reduction is used for
14 small values. Large inputs have their range reduced using fast integer
22 const sincos_t *p = &__sincosf_table[0];
24 if (abstop12 (y) < abstop12 (pio4f))
28 if (unlikely (abstop12 (y) < abstop12 (0x1p-12f)))
30 if (unlikely (abstop12 (y) < abstop12 (0x1p-126f)))
31 /* Force underflow for tiny y. */
36 return sinf_poly (x, s, p, 0);
38 else if (likely (abstop12 (y) < abstop12 (120.0f)))
40 x = reduce_fast (x, p, &n);
42 /* Setup the signs for sin and cos. */
46 p = &__sincosf_table[1];
48 return sinf_poly (x * s, x * x, p, n);
50 else if (abstop12 (y) < abstop12 (INFINITY))
52 uint32_t xi = asuint (y);
55 x = reduce_large (xi, &n);
57 /* Setup signs for sin and cos - include original sign. */
58 s = p->sign[(n + sign) & 3];
61 p = &__sincosf_table[1];
63 return sinf_poly (x * s, x * x, p, n);
66 return __math_invalidf (y);