s_ccoshf.c (226599) | s_ccoshf.c (275819) |
---|---|
1/*- 2 * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27/* 28 * Hyperbolic cosine of a complex argument. See s_ccosh.c for details. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27/* 28 * Hyperbolic cosine of a complex argument. See s_ccosh.c for details. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/lib/msun/src/s_ccoshf.c 226599 2011-10-21 06:29:32Z das $"); | 32__FBSDID("$FreeBSD: head/lib/msun/src/s_ccoshf.c 275819 2014-12-16 09:21:56Z ed $"); |
33 34#include <complex.h> 35#include <math.h> 36 37#include "math_private.h" 38 39static const float huge = 0x1p127; 40 --- 9 unchanged lines hidden (view full) --- 50 GET_FLOAT_WORD(hx, x); 51 GET_FLOAT_WORD(hy, y); 52 53 ix = 0x7fffffff & hx; 54 iy = 0x7fffffff & hy; 55 56 if (ix < 0x7f800000 && iy < 0x7f800000) { 57 if (iy == 0) | 33 34#include <complex.h> 35#include <math.h> 36 37#include "math_private.h" 38 39static const float huge = 0x1p127; 40 --- 9 unchanged lines hidden (view full) --- 50 GET_FLOAT_WORD(hx, x); 51 GET_FLOAT_WORD(hy, y); 52 53 ix = 0x7fffffff & hx; 54 iy = 0x7fffffff & hy; 55 56 if (ix < 0x7f800000 && iy < 0x7f800000) { 57 if (iy == 0) |
58 return (cpackf(coshf(x), x * y)); | 58 return (CMPLXF(coshf(x), x * y)); |
59 if (ix < 0x41100000) /* small x: normal case */ | 59 if (ix < 0x41100000) /* small x: normal case */ |
60 return (cpackf(coshf(x) * cosf(y), sinhf(x) * sinf(y))); | 60 return (CMPLXF(coshf(x) * cosf(y), sinhf(x) * sinf(y))); |
61 62 /* |x| >= 9, so cosh(x) ~= exp(|x|) */ 63 if (ix < 0x42b17218) { 64 /* x < 88.7: expf(|x|) won't overflow */ 65 h = expf(fabsf(x)) * 0.5f; | 61 62 /* |x| >= 9, so cosh(x) ~= exp(|x|) */ 63 if (ix < 0x42b17218) { 64 /* x < 88.7: expf(|x|) won't overflow */ 65 h = expf(fabsf(x)) * 0.5f; |
66 return (cpackf(h * cosf(y), copysignf(h, x) * sinf(y))); | 66 return (CMPLXF(h * cosf(y), copysignf(h, x) * sinf(y))); |
67 } else if (ix < 0x4340b1e7) { 68 /* x < 192.7: scale to avoid overflow */ | 67 } else if (ix < 0x4340b1e7) { 68 /* x < 192.7: scale to avoid overflow */ |
69 z = __ldexp_cexpf(cpackf(fabsf(x), y), -1); 70 return (cpackf(crealf(z), cimagf(z) * copysignf(1, x))); | 69 z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); 70 return (CMPLXF(crealf(z), cimagf(z) * copysignf(1, x))); |
71 } else { 72 /* x >= 192.7: the result always overflows */ 73 h = huge * x; | 71 } else { 72 /* x >= 192.7: the result always overflows */ 73 h = huge * x; |
74 return (cpackf(h * h * cosf(y), h * sinf(y))); | 74 return (CMPLXF(h * h * cosf(y), h * sinf(y))); |
75 } 76 } 77 78 if (ix == 0 && iy >= 0x7f800000) | 75 } 76 } 77 78 if (ix == 0 && iy >= 0x7f800000) |
79 return (cpackf(y - y, copysignf(0, x * (y - y)))); | 79 return (CMPLXF(y - y, copysignf(0, x * (y - y)))); |
80 81 if (iy == 0 && ix >= 0x7f800000) { 82 if ((hx & 0x7fffff) == 0) | 80 81 if (iy == 0 && ix >= 0x7f800000) { 82 if ((hx & 0x7fffff) == 0) |
83 return (cpackf(x * x, copysignf(0, x) * y)); 84 return (cpackf(x * x, copysignf(0, (x + x) * y))); | 83 return (CMPLXF(x * x, copysignf(0, x) * y)); 84 return (CMPLXF(x * x, copysignf(0, (x + x) * y))); |
85 } 86 87 if (ix < 0x7f800000 && iy >= 0x7f800000) | 85 } 86 87 if (ix < 0x7f800000 && iy >= 0x7f800000) |
88 return (cpackf(y - y, x * (y - y))); | 88 return (CMPLXF(y - y, x * (y - y))); |
89 90 if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { 91 if (iy >= 0x7f800000) | 89 90 if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { 91 if (iy >= 0x7f800000) |
92 return (cpackf(x * x, x * (y - y))); 93 return (cpackf((x * x) * cosf(y), x * sinf(y))); | 92 return (CMPLXF(x * x, x * (y - y))); 93 return (CMPLXF((x * x) * cosf(y), x * sinf(y))); |
94 } 95 | 94 } 95 |
96 return (cpackf((x * x) * (y - y), (x + x) * (y - y))); | 96 return (CMPLXF((x * x) * (y - y), (x + x) * (y - y))); |
97} 98 99float complex 100ccosf(float complex z) 101{ 102 | 97} 98 99float complex 100ccosf(float complex z) 101{ 102 |
103 return (ccoshf(cpackf(-cimagf(z), crealf(z)))); | 103 return (ccoshf(CMPLXF(-cimagf(z), crealf(z)))); |
104} | 104} |