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