42 * [-pi/2 , +pi/2], and let n = k mod 4.
43 * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have
44 *
45 * n sin(x) cos(x) tan(x)
46 * ----------------------------------------------------------
47 * 0 S C S/C
48 * 1 C -S -C/S
49 * 2 -S -C S/C
50 * 3 -C S -C/S
51 * ----------------------------------------------------------
52 *
53 * Special cases:
54 * Let trig be any of sin, cos, or tan.
55 * trig(+-INF) is NaN, with signals;
56 * trig(NaN) is that NaN;
57 *
58 * Accuracy:
59 * computer TRIG(x) returns trig(x) nearly rounded.
60 */
61
62 #pragma weak cosl = __cosl
63
64 #include "libm.h"
65 #include "longdouble.h"
66
67 long double
68 cosl(long double x) {
69 long double y[2], z = 0.0L;
70 int n, ix;
71
72 ix = *(int *) &x; /* High word of x */
73
74 ix &= 0x7fffffff;
75 if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */
76 return (__k_cosl(x, z));
77 else if (ix >= 0x7fff0000) /* trig(Inf or NaN) is NaN */
78 return (x - x);
79 else { /* argument reduction needed */
80 n = __rem_pio2l(x, y);
81 switch (n & 3) {
82 case 0:
|
42 * [-pi/2 , +pi/2], and let n = k mod 4.
43 * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have
44 *
45 * n sin(x) cos(x) tan(x)
46 * ----------------------------------------------------------
47 * 0 S C S/C
48 * 1 C -S -C/S
49 * 2 -S -C S/C
50 * 3 -C S -C/S
51 * ----------------------------------------------------------
52 *
53 * Special cases:
54 * Let trig be any of sin, cos, or tan.
55 * trig(+-INF) is NaN, with signals;
56 * trig(NaN) is that NaN;
57 *
58 * Accuracy:
59 * computer TRIG(x) returns trig(x) nearly rounded.
60 */
61
62 #pragma weak __cosl = cosl
63
64 #include "libm.h"
65 #include "longdouble.h"
66
67 long double
68 cosl(long double x) {
69 long double y[2], z = 0.0L;
70 int n, ix;
71
72 ix = *(int *) &x; /* High word of x */
73
74 ix &= 0x7fffffff;
75 if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */
76 return (__k_cosl(x, z));
77 else if (ix >= 0x7fff0000) /* trig(Inf or NaN) is NaN */
78 return (x - x);
79 else { /* argument reduction needed */
80 n = __rem_pio2l(x, y);
81 switch (n & 3) {
82 case 0:
|