Deleted Added
full compact
s_ctanhf.c (226600) s_ctanhf.c (275819)
1/*-
2 * Copyright (c) 2011 David Schultz
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 tangent of a complex argument z. See s_ctanh.c for details.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011 David Schultz
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 tangent of a complex argument z. See s_ctanh.c for details.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/lib/msun/src/s_ctanhf.c 226600 2011-10-21 06:30:16Z das $");
32__FBSDID("$FreeBSD: head/lib/msun/src/s_ctanhf.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
39float complex
40ctanhf(float complex z)

--- 5 unchanged lines hidden (view full) ---

46 x = crealf(z);
47 y = cimagf(z);
48
49 GET_FLOAT_WORD(hx, x);
50 ix = hx & 0x7fffffff;
51
52 if (ix >= 0x7f800000) {
53 if (ix & 0x7fffff)
33
34#include <complex.h>
35#include <math.h>
36
37#include "math_private.h"
38
39float complex
40ctanhf(float complex z)

--- 5 unchanged lines hidden (view full) ---

46 x = crealf(z);
47 y = cimagf(z);
48
49 GET_FLOAT_WORD(hx, x);
50 ix = hx & 0x7fffffff;
51
52 if (ix >= 0x7f800000) {
53 if (ix & 0x7fffff)
54 return (cpackf(x, (y == 0 ? y : x * y)));
54 return (CMPLXF(x, (y == 0 ? y : x * y)));
55 SET_FLOAT_WORD(x, hx - 0x40000000);
55 SET_FLOAT_WORD(x, hx - 0x40000000);
56 return (cpackf(x,
56 return (CMPLXF(x,
57 copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
58 }
59
60 if (!isfinite(y))
57 copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
58 }
59
60 if (!isfinite(y))
61 return (cpackf(y - y, y - y));
61 return (CMPLXF(y - y, y - y));
62
63 if (ix >= 0x41300000) { /* x >= 11 */
64 float exp_mx = expf(-fabsf(x));
62
63 if (ix >= 0x41300000) { /* x >= 11 */
64 float exp_mx = expf(-fabsf(x));
65 return (cpackf(copysignf(1, x),
65 return (CMPLXF(copysignf(1, x),
66 4 * sinf(y) * cosf(y) * exp_mx * exp_mx));
67 }
68
69 t = tanf(y);
70 beta = 1.0 + t * t;
71 s = sinhf(x);
72 rho = sqrtf(1 + s * s);
73 denom = 1 + beta * s * s;
66 4 * sinf(y) * cosf(y) * exp_mx * exp_mx));
67 }
68
69 t = tanf(y);
70 beta = 1.0 + t * t;
71 s = sinhf(x);
72 rho = sqrtf(1 + s * s);
73 denom = 1 + beta * s * s;
74 return (cpackf((beta * rho * s) / denom, t / denom));
74 return (CMPLXF((beta * rho * s) / denom, t / denom));
75}
76
77float complex
78ctanf(float complex z)
79{
80
75}
76
77float complex
78ctanf(float complex z)
79{
80
81 z = ctanhf(cpackf(-cimagf(z), crealf(z)));
82 return (cpackf(cimagf(z), -crealf(z)));
81 z = ctanhf(CMPLXF(-cimagf(z), crealf(z)));
82 return (CMPLXF(cimagf(z), -crealf(z)));
83}
84
83}
84