s_csinhf.c revision 226458
1226458Sdas/*- 2226458Sdas * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl 3226458Sdas * All rights reserved. 4226458Sdas * 5226458Sdas * Redistribution and use in source and binary forms, with or without 6226458Sdas * modification, are permitted provided that the following conditions 7226458Sdas * are met: 8226458Sdas * 1. Redistributions of source code must retain the above copyright 9226458Sdas * notice unmodified, this list of conditions, and the following 10226458Sdas * disclaimer. 11226458Sdas * 2. Redistributions in binary form must reproduce the above copyright 12226458Sdas * notice, this list of conditions and the following disclaimer in the 13226458Sdas * documentation and/or other materials provided with the distribution. 14226458Sdas * 15226458Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16226458Sdas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17226458Sdas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18226458Sdas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19226458Sdas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20226458Sdas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21226458Sdas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22226458Sdas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23226458Sdas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24226458Sdas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25226458Sdas */ 26226458Sdas 27226458Sdas/* 28226458Sdas * Hyperbolic sine of a complex argument z. See s_csinh.c for details. 29226458Sdas */ 30226458Sdas 31226458Sdas#include <sys/cdefs.h> 32226458Sdas__FBSDID("$FreeBSD: head/lib/msun/src/s_csinhf.c 226458 2011-10-17 05:41:03Z das $"); 33226458Sdas 34226458Sdas#include <complex.h> 35226458Sdas#include <math.h> 36226458Sdas 37226458Sdas#include "math_private.h" 38226458Sdas 39226458Sdasfloat complex 40226458Sdascsinhf(float complex z) 41226458Sdas{ 42226458Sdas float x, y; 43226458Sdas int32_t hx, hy, ix, iy; 44226458Sdas 45226458Sdas x = crealf(z); 46226458Sdas y = cimagf(z); 47226458Sdas 48226458Sdas GET_FLOAT_WORD(hx, x); 49226458Sdas GET_FLOAT_WORD(hy, y); 50226458Sdas 51226458Sdas ix = 0x7fffffff & hx; 52226458Sdas iy = 0x7fffffff & hy; 53226458Sdas 54226458Sdas if (ix < 0x7f800000 && iy < 0x7f800000) { 55226458Sdas if (iy == 0) 56226458Sdas return (cpackf(sinhf(x), y)); 57226458Sdas /* XXX We don't handle |x| > FLT_MAX ln(2) yet. */ 58226458Sdas return (cpackf(sinhf(x) * cosf(y), coshf(x) * sinf(y))); 59226458Sdas } 60226458Sdas 61226458Sdas if (ix == 0 && iy >= 0x7f800000) 62226458Sdas return (cpackf(copysignf(0, x * (y - y)), y - y)); 63226458Sdas 64226458Sdas if (iy == 0 && ix >= 0x7f800000) { 65226458Sdas if ((hx & 0x7fffff) == 0) 66226458Sdas return (cpackf(x, copysignf(0, x) * y)); 67226458Sdas return (cpackf(x, copysignf(0, y))); 68226458Sdas } 69226458Sdas 70226458Sdas if (ix < 0x7f800000 && iy >= 0x7f800000) 71226458Sdas return (cpackf(y - y, x * (y - y))); 72226458Sdas 73226458Sdas if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { 74226458Sdas if (iy >= 0x7f800000) 75226458Sdas return (cpackf(x * x, x * (y - y))); 76226458Sdas return (cpackf(x * cosf(y), INFINITY * sinf(y))); 77226458Sdas } 78226458Sdas 79226458Sdas return (cpackf((x * x) * (y - y), (x + x) * (y - y))); 80226458Sdas} 81226458Sdas 82226458Sdasfloat complex 83226458Sdascsinf(float complex z) 84226458Sdas{ 85226458Sdas 86226458Sdas z = csinhf(cpackf(-cimagf(z), crealf(z))); 87226458Sdas return (cpackf(cimagf(z), -crealf(z))); 88226458Sdas} 89