* config/avr/avr.md ("mcu_enhanced"): New attribute.
[official-gcc.git] / libstdc++-v3 / math / cexpl.c
blob83cb4db5e584acaaed1201251a9fb4898396be11
1 /* Return value of complex exp function for long double complex value. */
3 /* Copyright (C) 1997-1999 Free Software Foundation, Inc.
5 This file is part of the GNU ISO C++ Library. This library is free
6 software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this library; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 USA.
21 As a special exception, you may use this file as part of a free software
22 library without restriction. Specifically, if other files instantiate
23 templates or use macros or inline functions from this file, or you compile
24 this file and link it with other files to produce an executable, this
25 file does not by itself cause the resulting executable to be covered by
26 the GNU General Public License. This exception does not however
27 invalidate any other reasons why the executable file might be covered by
28 the GNU General Public License. */
30 #include <math.h>
31 #include "mathconf.h"
34 __complex__ long double
35 cexpl (__complex__ long double x)
37 __complex__ long double retval;
39 if (FINITEL_P (__real__ x))
41 /* Real part is finite. */
42 if (FINITEL_P (__imag__ x))
44 /* Imaginary part is finite. */
45 long double exp_val = expl (__real__ x);
46 long double sinix = sinl (__imag__ x);
47 long double cosix = cosl (__imag__ x);
49 if (FINITEL_P (exp_val))
51 __real__ retval = exp_val * cosix;
52 __imag__ retval = exp_val * sinix;
54 else
56 __real__ retval = copysignl (exp_val, cosix);
57 __imag__ retval = copysignl (exp_val, sinix);
60 else
62 /* If the imaginary part is +-inf or NaN and the real part
63 is not +-inf the result is NaN + iNaN. */
64 __real__ retval = NAN;
65 __imag__ retval = NAN;
68 else if (INFINITEL_P (__real__ x))
70 /* Real part is infinite. */
71 if (FINITEL_P (__imag__ x))
73 /* Imaginary part is finite. */
74 long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL;
76 if (__imag__ x == 0.0)
78 /* Imaginary part is 0.0. */
79 __real__ retval = value;
80 __imag__ retval = __imag__ x;
82 else
84 long double sinix = sinl (__imag__ x);
85 long double cosix = cosl (__imag__ x);
87 __real__ retval = copysignl (value, cosix);
88 __imag__ retval = copysignl (value, sinix);
91 else if (signbit (__real__ x) == 0)
93 __real__ retval = HUGE_VALL;
94 __imag__ retval = NAN;
96 else
98 __real__ retval = 0.0;
99 __imag__ retval = copysignl (0.0, __imag__ x);
102 else
104 /* If the real part is NaN the result is NaN + iNaN. */
105 __real__ retval = NAN;
106 __imag__ retval = NAN;
109 return retval;