1*181254a7Smrg /* GCC Quad-Precision Math Library
2*181254a7Smrg Copyright (C) 2010, 2011 Free Software Foundation, Inc.
3*181254a7Smrg Written by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
4*181254a7Smrg
5*181254a7Smrg This file is part of the libquadmath library.
6*181254a7Smrg Libquadmath is free software; you can redistribute it and/or
7*181254a7Smrg modify it under the terms of the GNU Library General Public
8*181254a7Smrg License as published by the Free Software Foundation; either
9*181254a7Smrg version 2 of the License, or (at your option) any later version.
10*181254a7Smrg
11*181254a7Smrg Libquadmath is distributed in the hope that it will be useful,
12*181254a7Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
13*181254a7Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14*181254a7Smrg Library General Public License for more details.
15*181254a7Smrg
16*181254a7Smrg You should have received a copy of the GNU Library General Public
17*181254a7Smrg License along with libquadmath; see the file COPYING.LIB. If
18*181254a7Smrg not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19*181254a7Smrg Boston, MA 02110-1301, USA. */
20*181254a7Smrg
21*181254a7Smrg #include "quadmath-imp.h"
22*181254a7Smrg
23*181254a7Smrg #ifdef HAVE_FENV_H
24*181254a7Smrg # include <fenv.h>
25*181254a7Smrg #endif
26*181254a7Smrg
27*181254a7Smrg
28*181254a7Smrg #define REALPART(z) (__real__(z))
29*181254a7Smrg #define IMAGPART(z) (__imag__(z))
30*181254a7Smrg #define COMPLEX_ASSIGN(z_, r_, i_) {__real__(z_) = (r_); __imag__(z_) = (i_);}
31*181254a7Smrg
32*181254a7Smrg
33*181254a7Smrg __float128
cabsq(__complex128 z)34*181254a7Smrg cabsq (__complex128 z)
35*181254a7Smrg {
36*181254a7Smrg return hypotq (REALPART (z), IMAGPART (z));
37*181254a7Smrg }
38*181254a7Smrg
39*181254a7Smrg
40*181254a7Smrg __complex128
cexpiq(__float128 x)41*181254a7Smrg cexpiq (__float128 x)
42*181254a7Smrg {
43*181254a7Smrg __float128 sinix, cosix;
44*181254a7Smrg __complex128 v;
45*181254a7Smrg sincosq (x, &sinix, &cosix);
46*181254a7Smrg COMPLEX_ASSIGN (v, cosix, sinix);
47*181254a7Smrg return v;
48*181254a7Smrg }
49*181254a7Smrg
50*181254a7Smrg
51*181254a7Smrg __float128
cargq(__complex128 z)52*181254a7Smrg cargq (__complex128 z)
53*181254a7Smrg {
54*181254a7Smrg return atan2q (IMAGPART (z), REALPART (z));
55*181254a7Smrg }
56*181254a7Smrg
57*181254a7Smrg
58*181254a7Smrg __complex128
cpowq(__complex128 base,__complex128 power)59*181254a7Smrg cpowq (__complex128 base, __complex128 power)
60*181254a7Smrg {
61*181254a7Smrg return cexpq (power * clogq (base));
62*181254a7Smrg }
63*181254a7Smrg
64*181254a7Smrg
65*181254a7Smrg __complex128
ccosq(__complex128 x)66*181254a7Smrg ccosq (__complex128 x)
67*181254a7Smrg {
68*181254a7Smrg __complex128 y;
69*181254a7Smrg
70*181254a7Smrg COMPLEX_ASSIGN (y, -IMAGPART (x), REALPART (x));
71*181254a7Smrg return ccoshq (y);
72*181254a7Smrg }
73