1*81418a27Smrg /* Return cosine of a complex type.
2*81418a27Smrg    Copyright (C) 1997-2018 Free Software Foundation, Inc.
3*81418a27Smrg    This file is part of the GNU C Library.
4*81418a27Smrg    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5*81418a27Smrg 
6*81418a27Smrg    The GNU C Library is free software; you can redistribute it and/or
7*81418a27Smrg    modify it under the terms of the GNU Lesser General Public
8*81418a27Smrg    License as published by the Free Software Foundation; either
9*81418a27Smrg    version 2.1 of the License, or (at your option) any later version.
10*81418a27Smrg 
11*81418a27Smrg    The GNU C Library is distributed in the hope that it will be useful,
12*81418a27Smrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*81418a27Smrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*81418a27Smrg    Lesser General Public License for more details.
15*81418a27Smrg 
16*81418a27Smrg    You should have received a copy of the GNU Lesser General Public
17*81418a27Smrg    License along with the GNU C Library; if not, see
18*81418a27Smrg    <http://www.gnu.org/licenses/>.  */
19*81418a27Smrg 
20*81418a27Smrg #include "quadmath-imp.h"
21*81418a27Smrg 
22*81418a27Smrg __complex128
cacosq(__complex128 x)23*81418a27Smrg cacosq (__complex128 x)
24*81418a27Smrg {
25*81418a27Smrg   __complex128 y;
26*81418a27Smrg   __complex128 res;
27*81418a27Smrg   int rcls = fpclassifyq (__real__ x);
28*81418a27Smrg   int icls = fpclassifyq (__imag__ x);
29*81418a27Smrg 
30*81418a27Smrg   if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE
31*81418a27Smrg       || (rcls == QUADFP_ZERO && icls == QUADFP_ZERO))
32*81418a27Smrg     {
33*81418a27Smrg       y = casinq (x);
34*81418a27Smrg 
35*81418a27Smrg       __real__ res = (__float128) M_PI_2q - __real__ y;
36*81418a27Smrg       if (__real__ res == 0)
37*81418a27Smrg 	__real__ res = 0;
38*81418a27Smrg       __imag__ res = -__imag__ y;
39*81418a27Smrg     }
40*81418a27Smrg   else
41*81418a27Smrg     {
42*81418a27Smrg       __real__ y = -__imag__ x;
43*81418a27Smrg       __imag__ y = __real__ x;
44*81418a27Smrg 
45*81418a27Smrg       y = __quadmath_kernel_casinhq (y, 1);
46*81418a27Smrg 
47*81418a27Smrg       __real__ res = __imag__ y;
48*81418a27Smrg       __imag__ res = __real__ y;
49*81418a27Smrg     }
50*81418a27Smrg 
51*81418a27Smrg   return res;
52*81418a27Smrg }
53