| author | |
| committer | |
| log | 21d9e03758d40c690488abce12bb82e063ff15e9 |
| tree | f2e2ee1abad04dec2e3af3b12f07abb327055824 |
| parent | 0cbff2ff7ff175a40c452bb5ca4a32a282a77088 |
- sin
- sinf
- cos
- cosf
- sincos
- sincosf
- tan
- tanf10 files changed, 0 insertions(+), 645 deletions(-)
lib/libc/musl/src/math/cos.c deleted-77| ... | @@ -1,77 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */ | ||
| 2 | /* | ||
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | /* cos(x) | ||
| 13 | * Return cosine function of x. | ||
| 14 | * | ||
| 15 | * kernel function: | ||
| 16 | * __sin ... sine function on [-pi/4,pi/4] | ||
| 17 | * __cos ... cosine function on [-pi/4,pi/4] | ||
| 18 | * __rem_pio2 ... argument reduction routine | ||
| 19 | * | ||
| 20 | * Method. | ||
| 21 | * Let S,C and T denote the sin, cos and tan respectively on | ||
| 22 | * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 | ||
| 23 | * in [-pi/4 , +pi/4], and let n = k mod 4. | ||
| 24 | * We have | ||
| 25 | * | ||
| 26 | * n sin(x) cos(x) tan(x) | ||
| 27 | * ---------------------------------------------------------- | ||
| 28 | * 0 S C T | ||
| 29 | * 1 C -S -1/T | ||
| 30 | * 2 -S -C T | ||
| 31 | * 3 -C S -1/T | ||
| 32 | * ---------------------------------------------------------- | ||
| 33 | * | ||
| 34 | * Special cases: | ||
| 35 | * Let trig be any of sin, cos, or tan. | ||
| 36 | * trig(+-INF) is NaN, with signals; | ||
| 37 | * trig(NaN) is that NaN; | ||
| 38 | * | ||
| 39 | * Accuracy: | ||
| 40 | * TRIG(x) returns trig(x) nearly rounded | ||
| 41 | */ | ||
| 42 | |||
| 43 | #include "libm.h" | ||
| 44 | |||
| 45 | double cos(double x) | ||
| 46 | { | ||
| 47 | 	double y[2]; | ||
| 48 | 	uint32_t ix; | ||
| 49 | 	unsigned n; | ||
| 50 | |||
| 51 | 	GET_HIGH_WORD(ix, x); | ||
| 52 | 	ix &= 0x7fffffff; | ||
| 53 | |||
| 54 | 	/* |x| ~< pi/4 */ | ||
| 55 | 	if (ix <= 0x3fe921fb) { | ||
| 56 | 		if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */ | ||
| 57 | 			/* raise inexact if x!=0 */ | ||
| 58 | 			FORCE_EVAL(x + 0x1p120f); | ||
| 59 | 			return 1.0; | ||
| 60 | 		} | ||
| 61 | 		return __cos(x, 0); | ||
| 62 | 	} | ||
| 63 | |||
| 64 | 	/* cos(Inf or NaN) is NaN */ | ||
| 65 | 	if (ix >= 0x7ff00000) | ||
| 66 | 		return x-x; | ||
| 67 | |||
| 68 | 	/* argument reduction */ | ||
| 69 | 	n = __rem_pio2(x, y); | ||
| 70 | 	switch (n&3) { | ||
| 71 | 	case 0: return __cos(y[0], y[1]); | ||
| 72 | 	case 1: return -__sin(y[0], y[1], 1); | ||
| 73 | 	case 2: return -__cos(y[0], y[1]); | ||
| 74 | 	default: | ||
| 75 | 		return __sin(y[0], y[1], 1); | ||
| 76 | 	} | ||
| 77 | } | ||
lib/libc/musl/src/math/cosf.c deleted-78| ... | @@ -1,78 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_cosf.c */ | ||
| 2 | /* | ||
| 3 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. | ||
| 4 | * Optimized by Bruce D. Evans. | ||
| 5 | */ | ||
| 6 | /* | ||
| 7 | * ==================================================== | ||
| 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 9 | * | ||
| 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 11 | * Permission to use, copy, modify, and distribute this | ||
| 12 | * software is freely granted, provided that this notice | ||
| 13 | * is preserved. | ||
| 14 | * ==================================================== | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "libm.h" | ||
| 18 | |||
| 19 | /* Small multiples of pi/2 rounded to double precision. */ | ||
| 20 | static const double | ||
| 21 | c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */ | ||
| 22 | c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */ | ||
| 23 | c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */ | ||
| 24 | c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */ | ||
| 25 | |||
| 26 | float cosf(float x) | ||
| 27 | { | ||
| 28 | 	double y; | ||
| 29 | 	uint32_t ix; | ||
| 30 | 	unsigned n, sign; | ||
| 31 | |||
| 32 | 	GET_FLOAT_WORD(ix, x); | ||
| 33 | 	sign = ix >> 31; | ||
| 34 | 	ix &= 0x7fffffff; | ||
| 35 | |||
| 36 | 	if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */ | ||
| 37 | 		if (ix < 0x39800000) { /* |x| < 2**-12 */ | ||
| 38 | 			/* raise inexact if x != 0 */ | ||
| 39 | 			FORCE_EVAL(x + 0x1p120f); | ||
| 40 | 			return 1.0f; | ||
| 41 | 		} | ||
| 42 | 		return __cosdf(x); | ||
| 43 | 	} | ||
| 44 | 	if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */ | ||
| 45 | 		if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */ | ||
| 46 | 			return -__cosdf(sign ? x+c2pio2 : x-c2pio2); | ||
| 47 | 		else { | ||
| 48 | 			if (sign) | ||
| 49 | 				return __sindf(x + c1pio2); | ||
| 50 | 			else | ||
| 51 | 				return __sindf(c1pio2 - x); | ||
| 52 | 		} | ||
| 53 | 	} | ||
| 54 | 	if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */ | ||
| 55 | 		if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */ | ||
| 56 | 			return __cosdf(sign ? x+c4pio2 : x-c4pio2); | ||
| 57 | 		else { | ||
| 58 | 			if (sign) | ||
| 59 | 				return __sindf(-x - c3pio2); | ||
| 60 | 			else | ||
| 61 | 				return __sindf(x - c3pio2); | ||
| 62 | 		} | ||
| 63 | 	} | ||
| 64 | |||
| 65 | 	/* cos(Inf or NaN) is NaN */ | ||
| 66 | 	if (ix >= 0x7f800000) | ||
| 67 | 		return x-x; | ||
| 68 | |||
| 69 | 	/* general argument reduction needed */ | ||
| 70 | 	n = __rem_pio2f(x,&y); | ||
| 71 | 	switch (n&3) { | ||
| 72 | 	case 0: return __cosdf(y); | ||
| 73 | 	case 1: return __sindf(-y); | ||
| 74 | 	case 2: return -__cosdf(y); | ||
| 75 | 	default: | ||
| 76 | 		return __sindf(y); | ||
| 77 | 	} | ||
| 78 | } | ||
lib/libc/musl/src/math/sin.c deleted-78| ... | @@ -1,78 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */ | ||
| 2 | /* | ||
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | /* sin(x) | ||
| 13 | * Return sine function of x. | ||
| 14 | * | ||
| 15 | * kernel function: | ||
| 16 | * __sin ... sine function on [-pi/4,pi/4] | ||
| 17 | * __cos ... cose function on [-pi/4,pi/4] | ||
| 18 | * __rem_pio2 ... argument reduction routine | ||
| 19 | * | ||
| 20 | * Method. | ||
| 21 | * Let S,C and T denote the sin, cos and tan respectively on | ||
| 22 | * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 | ||
| 23 | * in [-pi/4 , +pi/4], and let n = k mod 4. | ||
| 24 | * We have | ||
| 25 | * | ||
| 26 | * n sin(x) cos(x) tan(x) | ||
| 27 | * ---------------------------------------------------------- | ||
| 28 | * 0 S C T | ||
| 29 | * 1 C -S -1/T | ||
| 30 | * 2 -S -C T | ||
| 31 | * 3 -C S -1/T | ||
| 32 | * ---------------------------------------------------------- | ||
| 33 | * | ||
| 34 | * Special cases: | ||
| 35 | * Let trig be any of sin, cos, or tan. | ||
| 36 | * trig(+-INF) is NaN, with signals; | ||
| 37 | * trig(NaN) is that NaN; | ||
| 38 | * | ||
| 39 | * Accuracy: | ||
| 40 | * TRIG(x) returns trig(x) nearly rounded | ||
| 41 | */ | ||
| 42 | |||
| 43 | #include "libm.h" | ||
| 44 | |||
| 45 | double sin(double x) | ||
| 46 | { | ||
| 47 | 	double y[2]; | ||
| 48 | 	uint32_t ix; | ||
| 49 | 	unsigned n; | ||
| 50 | |||
| 51 | 	/* High word of x. */ | ||
| 52 | 	GET_HIGH_WORD(ix, x); | ||
| 53 | 	ix &= 0x7fffffff; | ||
| 54 | |||
| 55 | 	/* |x| ~< pi/4 */ | ||
| 56 | 	if (ix <= 0x3fe921fb) { | ||
| 57 | 		if (ix < 0x3e500000) { /* |x| < 2**-26 */ | ||
| 58 | 			/* raise inexact if x != 0 and underflow if subnormal*/ | ||
| 59 | 			FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); | ||
| 60 | 			return x; | ||
| 61 | 		} | ||
| 62 | 		return __sin(x, 0.0, 0); | ||
| 63 | 	} | ||
| 64 | |||
| 65 | 	/* sin(Inf or NaN) is NaN */ | ||
| 66 | 	if (ix >= 0x7ff00000) | ||
| 67 | 		return x - x; | ||
| 68 | |||
| 69 | 	/* argument reduction needed */ | ||
| 70 | 	n = __rem_pio2(x, y); | ||
| 71 | 	switch (n&3) { | ||
| 72 | 	case 0: return __sin(y[0], y[1], 1); | ||
| 73 | 	case 1: return __cos(y[0], y[1]); | ||
| 74 | 	case 2: return -__sin(y[0], y[1], 1); | ||
| 75 | 	default: | ||
| 76 | 		return -__cos(y[0], y[1]); | ||
| 77 | 	} | ||
| 78 | } | ||
lib/libc/musl/src/math/sincos.c deleted-69| ... | @@ -1,69 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */ | ||
| 2 | /* | ||
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | |||
| 13 | #define _GNU_SOURCE | ||
| 14 | #include "libm.h" | ||
| 15 | |||
| 16 | void sincos(double x, double *sin, double *cos) | ||
| 17 | { | ||
| 18 | 	double y[2], s, c; | ||
| 19 | 	uint32_t ix; | ||
| 20 | 	unsigned n; | ||
| 21 | |||
| 22 | 	GET_HIGH_WORD(ix, x); | ||
| 23 | 	ix &= 0x7fffffff; | ||
| 24 | |||
| 25 | 	/* |x| ~< pi/4 */ | ||
| 26 | 	if (ix <= 0x3fe921fb) { | ||
| 27 | 		/* if |x| < 2**-27 * sqrt(2) */ | ||
| 28 | 		if (ix < 0x3e46a09e) { | ||
| 29 | 			/* raise inexact if x!=0 and underflow if subnormal */ | ||
| 30 | 			FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); | ||
| 31 | 			*sin = x; | ||
| 32 | 			*cos = 1.0; | ||
| 33 | 			return; | ||
| 34 | 		} | ||
| 35 | 		*sin = __sin(x, 0.0, 0); | ||
| 36 | 		*cos = __cos(x, 0.0); | ||
| 37 | 		return; | ||
| 38 | 	} | ||
| 39 | |||
| 40 | 	/* sincos(Inf or NaN) is NaN */ | ||
| 41 | 	if (ix >= 0x7ff00000) { | ||
| 42 | 		*sin = *cos = x - x; | ||
| 43 | 		return; | ||
| 44 | 	} | ||
| 45 | |||
| 46 | 	/* argument reduction needed */ | ||
| 47 | 	n = __rem_pio2(x, y); | ||
| 48 | 	s = __sin(y[0], y[1], 1); | ||
| 49 | 	c = __cos(y[0], y[1]); | ||
| 50 | 	switch (n&3) { | ||
| 51 | 	case 0: | ||
| 52 | 		*sin = s; | ||
| 53 | 		*cos = c; | ||
| 54 | 		break; | ||
| 55 | 	case 1: | ||
| 56 | 		*sin = c; | ||
| 57 | 		*cos = -s; | ||
| 58 | 		break; | ||
| 59 | 	case 2: | ||
| 60 | 		*sin = -s; | ||
| 61 | 		*cos = -c; | ||
| 62 | 		break; | ||
| 63 | 	case 3: | ||
| 64 | 	default: | ||
| 65 | 		*sin = -c; | ||
| 66 | 		*cos = s; | ||
| 67 | 		break; | ||
| 68 | 	} | ||
| 69 | } | ||
lib/libc/musl/src/math/sincosf.c deleted-117| ... | @@ -1,117 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */ | ||
| 2 | /* | ||
| 3 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. | ||
| 4 | * Optimized by Bruce D. Evans. | ||
| 5 | */ | ||
| 6 | /* | ||
| 7 | * ==================================================== | ||
| 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 9 | * | ||
| 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 11 | * Permission to use, copy, modify, and distribute this | ||
| 12 | * software is freely granted, provided that this notice | ||
| 13 | * is preserved. | ||
| 14 | * ==================================================== | ||
| 15 | */ | ||
| 16 | |||
| 17 | #define _GNU_SOURCE | ||
| 18 | #include "libm.h" | ||
| 19 | |||
| 20 | /* Small multiples of pi/2 rounded to double precision. */ | ||
| 21 | static const double | ||
| 22 | s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */ | ||
| 23 | s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */ | ||
| 24 | s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */ | ||
| 25 | s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */ | ||
| 26 | |||
| 27 | void sincosf(float x, float *sin, float *cos) | ||
| 28 | { | ||
| 29 | 	double y; | ||
| 30 | 	float_t s, c; | ||
| 31 | 	uint32_t ix; | ||
| 32 | 	unsigned n, sign; | ||
| 33 | |||
| 34 | 	GET_FLOAT_WORD(ix, x); | ||
| 35 | 	sign = ix >> 31; | ||
| 36 | 	ix &= 0x7fffffff; | ||
| 37 | |||
| 38 | 	/* |x| ~<= pi/4 */ | ||
| 39 | 	if (ix <= 0x3f490fda) { | ||
| 40 | 		/* |x| < 2**-12 */ | ||
| 41 | 		if (ix < 0x39800000) { | ||
| 42 | 			/* raise inexact if x!=0 and underflow if subnormal */ | ||
| 43 | 			FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); | ||
| 44 | 			*sin = x; | ||
| 45 | 			*cos = 1.0f; | ||
| 46 | 			return; | ||
| 47 | 		} | ||
| 48 | 		*sin = __sindf(x); | ||
| 49 | 		*cos = __cosdf(x); | ||
| 50 | 		return; | ||
| 51 | 	} | ||
| 52 | |||
| 53 | 	/* |x| ~<= 5*pi/4 */ | ||
| 54 | 	if (ix <= 0x407b53d1) { | ||
| 55 | 		if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */ | ||
| 56 | 			if (sign) { | ||
| 57 | 				*sin = -__cosdf(x + s1pio2); | ||
| 58 | 				*cos = __sindf(x + s1pio2); | ||
| 59 | 			} else { | ||
| 60 | 				*sin = __cosdf(s1pio2 - x); | ||
| 61 | 				*cos = __sindf(s1pio2 - x); | ||
| 62 | 			} | ||
| 63 | 			return; | ||
| 64 | 		} | ||
| 65 | 		/* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */ | ||
| 66 | 		*sin = -__sindf(sign ? x + s2pio2 : x - s2pio2); | ||
| 67 | 		*cos = -__cosdf(sign ? x + s2pio2 : x - s2pio2); | ||
| 68 | 		return; | ||
| 69 | 	} | ||
| 70 | |||
| 71 | 	/* |x| ~<= 9*pi/4 */ | ||
| 72 | 	if (ix <= 0x40e231d5) { | ||
| 73 | 		if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */ | ||
| 74 | 			if (sign) { | ||
| 75 | 				*sin = __cosdf(x + s3pio2); | ||
| 76 | 				*cos = -__sindf(x + s3pio2); | ||
| 77 | 			} else { | ||
| 78 | 				*sin = -__cosdf(x - s3pio2); | ||
| 79 | 				*cos = __sindf(x - s3pio2); | ||
| 80 | 			} | ||
| 81 | 			return; | ||
| 82 | 		} | ||
| 83 | 		*sin = __sindf(sign ? x + s4pio2 : x - s4pio2); | ||
| 84 | 		*cos = __cosdf(sign ? x + s4pio2 : x - s4pio2); | ||
| 85 | 		return; | ||
| 86 | 	} | ||
| 87 | |||
| 88 | 	/* sin(Inf or NaN) is NaN */ | ||
| 89 | 	if (ix >= 0x7f800000) { | ||
| 90 | 		*sin = *cos = x - x; | ||
| 91 | 		return; | ||
| 92 | 	} | ||
| 93 | |||
| 94 | 	/* general argument reduction needed */ | ||
| 95 | 	n = __rem_pio2f(x, &y); | ||
| 96 | 	s = __sindf(y); | ||
| 97 | 	c = __cosdf(y); | ||
| 98 | 	switch (n&3) { | ||
| 99 | 	case 0: | ||
| 100 | 		*sin = s; | ||
| 101 | 		*cos = c; | ||
| 102 | 		break; | ||
| 103 | 	case 1: | ||
| 104 | 		*sin = c; | ||
| 105 | 		*cos = -s; | ||
| 106 | 		break; | ||
| 107 | 	case 2: | ||
| 108 | 		*sin = -s; | ||
| 109 | 		*cos = -c; | ||
| 110 | 		break; | ||
| 111 | 	case 3: | ||
| 112 | 	default: | ||
| 113 | 		*sin = -c; | ||
| 114 | 		*cos = s; | ||
| 115 | 		break; | ||
| 116 | 	} | ||
| 117 | } | ||
lib/libc/musl/src/math/sinf.c deleted-76| ... | @@ -1,76 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */ | ||
| 2 | /* | ||
| 3 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. | ||
| 4 | * Optimized by Bruce D. Evans. | ||
| 5 | */ | ||
| 6 | /* | ||
| 7 | * ==================================================== | ||
| 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 9 | * | ||
| 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 11 | * Permission to use, copy, modify, and distribute this | ||
| 12 | * software is freely granted, provided that this notice | ||
| 13 | * is preserved. | ||
| 14 | * ==================================================== | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "libm.h" | ||
| 18 | |||
| 19 | /* Small multiples of pi/2 rounded to double precision. */ | ||
| 20 | static const double | ||
| 21 | s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */ | ||
| 22 | s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */ | ||
| 23 | s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */ | ||
| 24 | s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */ | ||
| 25 | |||
| 26 | float sinf(float x) | ||
| 27 | { | ||
| 28 | 	double y; | ||
| 29 | 	uint32_t ix; | ||
| 30 | 	int n, sign; | ||
| 31 | |||
| 32 | 	GET_FLOAT_WORD(ix, x); | ||
| 33 | 	sign = ix >> 31; | ||
| 34 | 	ix &= 0x7fffffff; | ||
| 35 | |||
| 36 | 	if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */ | ||
| 37 | 		if (ix < 0x39800000) { /* |x| < 2**-12 */ | ||
| 38 | 			/* raise inexact if x!=0 and underflow if subnormal */ | ||
| 39 | 			FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f); | ||
| 40 | 			return x; | ||
| 41 | 		} | ||
| 42 | 		return __sindf(x); | ||
| 43 | 	} | ||
| 44 | 	if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */ | ||
| 45 | 		if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */ | ||
| 46 | 			if (sign) | ||
| 47 | 				return -__cosdf(x + s1pio2); | ||
| 48 | 			else | ||
| 49 | 				return __cosdf(x - s1pio2); | ||
| 50 | 		} | ||
| 51 | 		return __sindf(sign ? -(x + s2pio2) : -(x - s2pio2)); | ||
| 52 | 	} | ||
| 53 | 	if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */ | ||
| 54 | 		if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */ | ||
| 55 | 			if (sign) | ||
| 56 | 				return __cosdf(x + s3pio2); | ||
| 57 | 			else | ||
| 58 | 				return -__cosdf(x - s3pio2); | ||
| 59 | 		} | ||
| 60 | 		return __sindf(sign ? x + s4pio2 : x - s4pio2); | ||
| 61 | 	} | ||
| 62 | |||
| 63 | 	/* sin(Inf or NaN) is NaN */ | ||
| 64 | 	if (ix >= 0x7f800000) | ||
| 65 | 		return x - x; | ||
| 66 | |||
| 67 | 	/* general argument reduction needed */ | ||
| 68 | 	n = __rem_pio2f(x, &y); | ||
| 69 | 	switch (n&3) { | ||
| 70 | 	case 0: return __sindf(y); | ||
| 71 | 	case 1: return __cosdf(y); | ||
| 72 | 	case 2: return __sindf(-y); | ||
| 73 | 	default: | ||
| 74 | 		return -__cosdf(y); | ||
| 75 | 	} | ||
| 76 | } | ||
lib/libc/musl/src/math/tan.c deleted-70| ... | @@ -1,70 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */ | ||
| 2 | /* | ||
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | /* tan(x) | ||
| 13 | * Return tangent function of x. | ||
| 14 | * | ||
| 15 | * kernel function: | ||
| 16 | * __tan ... tangent function on [-pi/4,pi/4] | ||
| 17 | * __rem_pio2 ... argument reduction routine | ||
| 18 | * | ||
| 19 | * Method. | ||
| 20 | * Let S,C and T denote the sin, cos and tan respectively on | ||
| 21 | * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 | ||
| 22 | * in [-pi/4 , +pi/4], and let n = k mod 4. | ||
| 23 | * We have | ||
| 24 | * | ||
| 25 | * n sin(x) cos(x) tan(x) | ||
| 26 | * ---------------------------------------------------------- | ||
| 27 | * 0 S C T | ||
| 28 | * 1 C -S -1/T | ||
| 29 | * 2 -S -C T | ||
| 30 | * 3 -C S -1/T | ||
| 31 | * ---------------------------------------------------------- | ||
| 32 | * | ||
| 33 | * Special cases: | ||
| 34 | * Let trig be any of sin, cos, or tan. | ||
| 35 | * trig(+-INF) is NaN, with signals; | ||
| 36 | * trig(NaN) is that NaN; | ||
| 37 | * | ||
| 38 | * Accuracy: | ||
| 39 | * TRIG(x) returns trig(x) nearly rounded | ||
| 40 | */ | ||
| 41 | |||
| 42 | #include "libm.h" | ||
| 43 | |||
| 44 | double tan(double x) | ||
| 45 | { | ||
| 46 | 	double y[2]; | ||
| 47 | 	uint32_t ix; | ||
| 48 | 	unsigned n; | ||
| 49 | |||
| 50 | 	GET_HIGH_WORD(ix, x); | ||
| 51 | 	ix &= 0x7fffffff; | ||
| 52 | |||
| 53 | 	/* |x| ~< pi/4 */ | ||
| 54 | 	if (ix <= 0x3fe921fb) { | ||
| 55 | 		if (ix < 0x3e400000) { /* |x| < 2**-27 */ | ||
| 56 | 			/* raise inexact if x!=0 and underflow if subnormal */ | ||
| 57 | 			FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); | ||
| 58 | 			return x; | ||
| 59 | 		} | ||
| 60 | 		return __tan(x, 0.0, 0); | ||
| 61 | 	} | ||
| 62 | |||
| 63 | 	/* tan(Inf or NaN) is NaN */ | ||
| 64 | 	if (ix >= 0x7ff00000) | ||
| 65 | 		return x - x; | ||
| 66 | |||
| 67 | 	/* argument reduction */ | ||
| 68 | 	n = __rem_pio2(x, y); | ||
| 69 | 	return __tan(y[0], y[1], n&1); | ||
| 70 | } | ||
lib/libc/musl/src/math/tanf.c deleted-64| ... | @@ -1,64 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/s_tanf.c */ | ||
| 2 | /* | ||
| 3 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. | ||
| 4 | * Optimized by Bruce D. Evans. | ||
| 5 | */ | ||
| 6 | /* | ||
| 7 | * ==================================================== | ||
| 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 9 | * | ||
| 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 11 | * Permission to use, copy, modify, and distribute this | ||
| 12 | * software is freely granted, provided that this notice | ||
| 13 | * is preserved. | ||
| 14 | * ==================================================== | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "libm.h" | ||
| 18 | |||
| 19 | /* Small multiples of pi/2 rounded to double precision. */ | ||
| 20 | static const double | ||
| 21 | t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */ | ||
| 22 | t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */ | ||
| 23 | t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */ | ||
| 24 | t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */ | ||
| 25 | |||
| 26 | float tanf(float x) | ||
| 27 | { | ||
| 28 | 	double y; | ||
| 29 | 	uint32_t ix; | ||
| 30 | 	unsigned n, sign; | ||
| 31 | |||
| 32 | 	GET_FLOAT_WORD(ix, x); | ||
| 33 | 	sign = ix >> 31; | ||
| 34 | 	ix &= 0x7fffffff; | ||
| 35 | |||
| 36 | 	if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */ | ||
| 37 | 		if (ix < 0x39800000) { /* |x| < 2**-12 */ | ||
| 38 | 			/* raise inexact if x!=0 and underflow if subnormal */ | ||
| 39 | 			FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f); | ||
| 40 | 			return x; | ||
| 41 | 		} | ||
| 42 | 		return __tandf(x, 0); | ||
| 43 | 	} | ||
| 44 | 	if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */ | ||
| 45 | 		if (ix <= 0x4016cbe3) /* |x| ~<= 3pi/4 */ | ||
| 46 | 			return __tandf((sign ? x+t1pio2 : x-t1pio2), 1); | ||
| 47 | 		else | ||
| 48 | 			return __tandf((sign ? x+t2pio2 : x-t2pio2), 0); | ||
| 49 | 	} | ||
| 50 | 	if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */ | ||
| 51 | 		if (ix <= 0x40afeddf) /* |x| ~<= 7*pi/4 */ | ||
| 52 | 			return __tandf((sign ? x+t3pio2 : x-t3pio2), 1); | ||
| 53 | 		else | ||
| 54 | 			return __tandf((sign ? x+t4pio2 : x-t4pio2), 0); | ||
| 55 | 	} | ||
| 56 | |||
| 57 | 	/* tan(Inf or NaN) is NaN */ | ||
| 58 | 	if (ix >= 0x7f800000) | ||
| 59 | 		return x - x; | ||
| 60 | |||
| 61 | 	/* argument reduction */ | ||
| 62 | 	n = __rem_pio2f(x, &y); | ||
| 63 | 	return __tandf(y, n&1); | ||
| 64 | } | ||
src/libs/musl.zig-8| ... | @@ -886,9 +886,7 @@ const src_files = [_][]const u8{ | ... | @@ -886,9 +886,7 @@ const src_files = [_][]const u8{ |
| 886 | "musl/src/math/copysignf.c", | 886 | "musl/src/math/copysignf.c", |
| 887 | "musl/src/math/copysignl.c", | 887 | "musl/src/math/copysignl.c", |
| 888 | "musl/src/math/__cos.c", | 888 | "musl/src/math/__cos.c", |
| 889 | "musl/src/math/cos.c", | ||
| 890 | "musl/src/math/__cosdf.c", | 889 | "musl/src/math/__cosdf.c", |
| 891 | "musl/src/math/cosf.c", | ||
| 892 | "musl/src/math/cosh.c", | 890 | "musl/src/math/cosh.c", |
| 893 | "musl/src/math/coshf.c", | 891 | "musl/src/math/coshf.c", |
| 894 | "musl/src/math/coshl.c", | 892 | "musl/src/math/coshl.c", |
| ... | @@ -1194,12 +1192,8 @@ const src_files = [_][]const u8{ | ... | @@ -1194,12 +1192,8 @@ const src_files = [_][]const u8{ |
| 1194 | "musl/src/math/significand.c", | 1192 | "musl/src/math/significand.c", |
| 1195 | "musl/src/math/significandf.c", | 1193 | "musl/src/math/significandf.c", |
| 1196 | "musl/src/math/__sin.c", | 1194 | "musl/src/math/__sin.c", |
| 1197 | "musl/src/math/sin.c", | ||
| 1198 | "musl/src/math/sincos.c", | ||
| 1199 | "musl/src/math/sincosf.c", | ||
| 1200 | "musl/src/math/sincosl.c", | 1195 | "musl/src/math/sincosl.c", |
| 1201 | "musl/src/math/__sindf.c", | 1196 | "musl/src/math/__sindf.c", |
| 1202 | "musl/src/math/sinf.c", | ||
| 1203 | "musl/src/math/sinh.c", | 1197 | "musl/src/math/sinh.c", |
| 1204 | "musl/src/math/sinhf.c", | 1198 | "musl/src/math/sinhf.c", |
| 1205 | "musl/src/math/sinhl.c", | 1199 | "musl/src/math/sinhl.c", |
| ... | @@ -1210,9 +1204,7 @@ const src_files = [_][]const u8{ | ... | @@ -1210,9 +1204,7 @@ const src_files = [_][]const u8{ |
| 1210 | "musl/src/math/sqrtf.c", | 1204 | "musl/src/math/sqrtf.c", |
| 1211 | "musl/src/math/sqrtl.c", | 1205 | "musl/src/math/sqrtl.c", |
| 1212 | "musl/src/math/__tan.c", | 1206 | "musl/src/math/__tan.c", |
| 1213 | "musl/src/math/tan.c", | ||
| 1214 | "musl/src/math/__tandf.c", | 1207 | "musl/src/math/__tandf.c", |
| 1215 | "musl/src/math/tanf.c", | ||
| 1216 | "musl/src/math/tanh.c", | 1208 | "musl/src/math/tanh.c", |
| 1217 | "musl/src/math/tanhf.c", | 1209 | "musl/src/math/tanhf.c", |
| 1218 | "musl/src/math/tanhl.c", | 1210 | "musl/src/math/tanhl.c", |
src/libs/wasi_libc.zig-8| ... | @@ -728,9 +728,7 @@ const libc_top_half_src_files = [_][]const u8{ | ... | @@ -728,9 +728,7 @@ const libc_top_half_src_files = [_][]const u8{ |
| 728 | "musl/src/math/ceill.c", | 728 | "musl/src/math/ceill.c", |
| 729 | "musl/src/math/copysignl.c", | 729 | "musl/src/math/copysignl.c", |
| 730 | "musl/src/math/__cos.c", | 730 | "musl/src/math/__cos.c", |
| 731 | "musl/src/math/cos.c", | ||
| 732 | "musl/src/math/__cosdf.c", | 731 | "musl/src/math/__cosdf.c", |
| 733 | "musl/src/math/cosf.c", | ||
| 734 | "musl/src/math/coshl.c", | 732 | "musl/src/math/coshl.c", |
| 735 | "musl/src/math/__cosl.c", | 733 | "musl/src/math/__cosl.c", |
| 736 | "musl/src/math/cosl.c", | 734 | "musl/src/math/cosl.c", |
| ... | @@ -871,21 +869,15 @@ const libc_top_half_src_files = [_][]const u8{ | ... | @@ -871,21 +869,15 @@ const libc_top_half_src_files = [_][]const u8{ |
| 871 | "musl/src/math/significand.c", | 869 | "musl/src/math/significand.c", |
| 872 | "musl/src/math/significandf.c", | 870 | "musl/src/math/significandf.c", |
| 873 | "musl/src/math/__sin.c", | 871 | "musl/src/math/__sin.c", |
| 874 | "musl/src/math/sin.c", | ||
| 875 | "musl/src/math/sincos.c", | ||
| 876 | "musl/src/math/sincosf.c", | ||
| 877 | "musl/src/math/sincosl.c", | 872 | "musl/src/math/sincosl.c", |
| 878 | "musl/src/math/__sindf.c", | 873 | "musl/src/math/__sindf.c", |
| 879 | "musl/src/math/sinf.c", | ||
| 880 | "musl/src/math/sinhl.c", | 874 | "musl/src/math/sinhl.c", |
| 881 | "musl/src/math/__sinl.c", | 875 | "musl/src/math/__sinl.c", |
| 882 | "musl/src/math/sinl.c", | 876 | "musl/src/math/sinl.c", |
| 883 | "musl/src/math/sqrt_data.c", | 877 | "musl/src/math/sqrt_data.c", |
| 884 | "musl/src/math/sqrtl.c", | 878 | "musl/src/math/sqrtl.c", |
| 885 | "musl/src/math/__tan.c", | 879 | "musl/src/math/__tan.c", |
| 886 | "musl/src/math/tan.c", | ||
| 887 | "musl/src/math/__tandf.c", | 880 | "musl/src/math/__tandf.c", |
| 888 | "musl/src/math/tanf.c", | ||
| 889 | "musl/src/math/tanh.c", | 881 | "musl/src/math/tanh.c", |
| 890 | "musl/src/math/tanhf.c", | 882 | "musl/src/math/tanhf.c", |
| 891 | "musl/src/math/tanhl.c", | 883 | "musl/src/math/tanhl.c", |