Lines Matching +full:range +full:- +full:double
4 * Copyright (c) 2018-2024, Arm Limited.
5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
12 /* 2PI * 2^-64. */
13 static const double pi63 = 0x1.921FB54442D18p-62;
15 static const float pio4f = 0x1.921FB6p-1f;
20 double sign[4]; /* Sign of sine in quadrants 0..3. */
21 double hpi_inv; /* 2 / PI ( * 2^24 if !TOINT_INTRINSICS). */
22 double hpi; /* PI / 2. */
23 double c0, c1, c2, c3, c4; /* Cosine polynomial. */
24 double s1, s2, s3; /* Sine polynomial. */
41 sincosf_poly (double x, double x2, const sincos_t *p, int n, float *sinp,
44 double x3, x4, x5, x6, s, c, c1, c2, s1;
48 c2 = p->c3 + x2 * p->c4;
49 s1 = p->s2 + x2 * p->s3;
56 c1 = p->c0 + x2 * p->c1;
60 s = x + x3 * p->s1;
61 c = c1 + x4 * p->c2;
70 sinf_poly (double x, double x2, const sincos_t *p, int n)
72 double x3, x4, x6, x7, s, c, c1, c2, s1;
77 s1 = p->s2 + x2 * p->s3;
80 s = x + x3 * p->s1;
87 c2 = p->c3 + x2 * p->c4;
88 c1 = p->c0 + x2 * p->c1;
91 c = c1 + x4 * p->c2;
97 /* Fast range reduction using single multiply-subtract. Return the modulo of
98 X as a value between -PI/4 and PI/4 and store the quadrant in NP.
99 The values for PI/2 and 2/PI are accessed via P. Since PI/2 as a double
100 is accurate to 55 bits and the worst-case cancellation happens at 6 * PI/4,
102 static inline double
103 reduce_fast (double x, const sincos_t *p, int *np)
105 double r;
108 r = x * p->hpi_inv;
110 return x - roundtoint (r) * p->hpi;
115 r = x * p->hpi_inv;
118 return x - n * p->hpi;
122 /* Reduce the range of XI to a multiple of PI/2 using fast integer arithmetic.
124 Return the modulo between -PI/4 and PI/4 and store the quadrant in NP.
125 Reduction uses a table of 4/PI with 192 bits of precision. A 32x96->128 bit
126 multiply computes the exact 2.62-bit fixed-point modulo. Since the result
127 can have at most 29 leading zeros after the binary point, the double
129 static inline double
146 res0 -= n << 62;
147 double x = (int64_t)res0;