]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgfortran/intrinsics/c99_functions.c
1 /* Implementation of various C99 functions
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6 Libgfortran is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file. (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
20 Libgfortran is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public
26 License along with libgfortran; see the file COPYING. If not,
27 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 Boston, MA 02110-1301, USA. */
32 #define C99_PROTOS_H WE_DONT_WANT_PROTOS_NOW
33 #include "libgfortran.h"
35 /* IRIX's <math.h> declares a non-C99 compliant implementation of cabs,
36 which takes two floating point arguments instead of a single complex.
37 If <complex.h> is missing this prevents building of c99_functions.c.
38 To work around this we redirect cabs{,f,l} calls to __gfc_cabs{,f,l}. */
40 #if defined(__sgi__) && !defined(HAVE_COMPLEX_H)
44 #define cabs __gfc_cabs
45 #define cabsf __gfc_cabsf
46 #define cabsl __gfc_cabsl
49 /* Tru64's <math.h> declares a non-C99 compliant implementation of cabs,
50 which takes two floating point arguments instead of a single complex.
51 To work around this we redirect cabs{,f,l} calls to __gfc_cabs{,f,l}. */
57 #define cabs __gfc_cabs
58 #define cabsf __gfc_cabsf
59 #define cabsl __gfc_cabsl
62 /* Prototypes to silence -Wstrict-prototypes -Wmissing-prototypes. */
64 float cabsf(float complex);
65 double cabs(double complex);
66 long double cabsl(long double complex);
68 float cargf(float complex);
69 double carg(double complex);
70 long double cargl(long double complex);
72 float complex clog10f(float complex);
73 double complex clog10(double complex);
74 long double complex clog10l(long double complex);
77 /* Wrappers for systems without the various C99 single precision Bessel
80 #if defined(HAVE_J0) && ! defined(HAVE_J0F)
82 extern float j0f (float);
87 return (float) j0 ((double) x
);
91 #if defined(HAVE_J1) && !defined(HAVE_J1F)
93 extern float j1f (float);
97 return (float) j1 ((double) x
);
101 #if defined(HAVE_JN) && !defined(HAVE_JNF)
103 extern float jnf (int, float);
108 return (float) jn (n
, (double) x
);
112 #if defined(HAVE_Y0) && !defined(HAVE_Y0F)
114 extern float y0f (float);
119 return (float) y0 ((double) x
);
123 #if defined(HAVE_Y1) && !defined(HAVE_Y1F)
125 extern float y1f (float);
130 return (float) y1 ((double) x
);
134 #if defined(HAVE_YN) && !defined(HAVE_YNF)
136 extern float ynf (int, float);
141 return (float) yn (n
, (double) x
);
146 /* Wrappers for systems without the C99 erff() and erfcf() functions. */
148 #if defined(HAVE_ERF) && !defined(HAVE_ERFF)
150 extern float erff (float);
155 return (float) erf ((double) x
);
159 #if defined(HAVE_ERFC) && !defined(HAVE_ERFCF)
161 extern float erfcf (float);
166 return (float) erfc ((double) x
);
176 return (float) acos(x
);
180 #if HAVE_ACOSH && !HAVE_ACOSHF
184 return (float) acosh ((double) x
);
193 return (float) asin(x
);
197 #if HAVE_ASINH && !HAVE_ASINHF
201 return (float) asinh ((double) x
);
206 #define HAVE_ATAN2F 1
208 atan2f(float y
, float x
)
210 return (float) atan2(y
, x
);
219 return (float) atan(x
);
223 #if HAVE_ATANH && !HAVE_ATANHF
227 return (float) atanh ((double) x
);
236 return (float) ceil(x
);
240 #ifndef HAVE_COPYSIGNF
241 #define HAVE_COPYSIGNF 1
243 copysignf(float x
, float y
)
245 return (float) copysign(x
, y
);
254 return (float) cos(x
);
263 return (float) cosh(x
);
272 return (float) exp(x
);
281 return (float) fabs(x
);
286 #define HAVE_FLOORF 1
290 return (float) floor(x
);
297 fmodf (float x
, float y
)
299 return (float) fmod (x
, y
);
304 #define HAVE_FREXPF 1
306 frexpf(float x
, int *exp
)
308 return (float) frexp(x
, exp
);
313 #define HAVE_HYPOTF 1
315 hypotf(float x
, float y
)
317 return (float) hypot(x
, y
);
326 return (float) log(x
);
331 #define HAVE_LOG10F 1
335 return (float) log10(x
);
340 #define HAVE_SCALBN 1
342 scalbn(double x
, int y
)
344 return x
* pow(FLT_RADIX
, y
);
349 #define HAVE_SCALBNF 1
351 scalbnf(float x
, int y
)
353 return (float) scalbn(x
, y
);
362 return (float) sin(x
);
371 return (float) sinh(x
);
380 return (float) sqrt(x
);
389 return (float) tan(x
);
398 return (float) tanh(x
);
418 #define HAVE_TRUNCF 1
422 return (float) trunc (x
);
426 #ifndef HAVE_NEXTAFTERF
427 #define HAVE_NEXTAFTERF 1
428 /* This is a portable implementation of nextafterf that is intended to be
429 independent of the floating point format or its in memory representation.
430 This implementation works correctly with denormalized values. */
432 nextafterf(float x
, float y
)
434 /* This variable is marked volatile to avoid excess precision problems
435 on some platforms, including IA-32. */
436 volatile float delta
;
437 float absx
, denorm_min
;
439 if (isnan(x
) || isnan(y
))
444 return x
> 0 ? __FLT_MAX__
: - __FLT_MAX__
;
446 /* absx = fabsf (x); */
447 absx
= (x
< 0.0) ? -x
: x
;
449 /* __FLT_DENORM_MIN__ is non-zero iff the target supports denormals. */
450 if (__FLT_DENORM_MIN__
== 0.0f
)
451 denorm_min
= __FLT_MIN__
;
453 denorm_min
= __FLT_DENORM_MIN__
;
455 if (absx
< __FLT_MIN__
)
462 /* Discard the fraction from x. */
463 frac
= frexpf (absx
, &exp
);
464 delta
= scalbnf (0.5f
, exp
);
466 /* Scale x by the epsilon of the representation. By rights we should
467 have been able to combine this with scalbnf, but some targets don't
468 get that correct with denormals. */
469 delta
*= __FLT_EPSILON__
;
471 /* If we're going to be reducing the absolute value of X, and doing so
472 would reduce the exponent of X, then the delta to be applied is
473 one exponent smaller. */
474 if (frac
== 0.5f
&& (y
< x
) == (x
> 0))
477 /* If that underflows to zero, then we're back to the minimum. */
493 powf(float x
, float y
)
495 return (float) pow(x
, y
);
499 /* Note that if fpclassify is not defined, then NaN is not handled */
501 /* Algorithm by Steven G. Kargl. */
503 #if !defined(HAVE_ROUNDL)
504 #define HAVE_ROUNDL 1
505 #if defined(HAVE_CEILL)
506 /* Round to nearest integral value. If the argument is halfway between two
507 integral values then round away from zero. */
510 roundl(long double x
)
533 /* Poor version of roundl for system that don't have ceill. */
535 roundl(long double x
)
537 if (x
> DBL_MAX
|| x
< -DBL_MAX
)
539 #ifdef HAVE_NEXTAFTERL
540 static long double prechalf
= nexafterl (0.5L, LDBL_MAX
);
542 static long double prechalf
= 0.5L;
544 return (GFC_INTEGER_LARGEST
) (x
+ (x
> 0 ? prechalf
: -prechalf
));
548 return round((double) x
);
556 /* Round to nearest integral value. If the argument is halfway between two
557 integral values then round away from zero. */
584 #define HAVE_ROUNDF 1
585 /* Round to nearest integral value. If the argument is halfway between two
586 integral values then round away from zero. */
613 /* lround{f,,l} and llround{f,,l} functions. */
615 #if !defined(HAVE_LROUNDF) && defined(HAVE_ROUNDF)
616 #define HAVE_LROUNDF 1
620 return (long int) roundf (x
);
624 #if !defined(HAVE_LROUND) && defined(HAVE_ROUND)
625 #define HAVE_LROUND 1
629 return (long int) round (x
);
633 #if !defined(HAVE_LROUNDL) && defined(HAVE_ROUNDL)
634 #define HAVE_LROUNDL 1
636 lroundl (long double x
)
638 return (long long int) roundl (x
);
642 #if !defined(HAVE_LLROUNDF) && defined(HAVE_ROUNDF)
643 #define HAVE_LLROUNDF 1
647 return (long long int) roundf (x
);
651 #if !defined(HAVE_LLROUND) && defined(HAVE_ROUND)
652 #define HAVE_LLROUND 1
656 return (long long int) round (x
);
660 #if !defined(HAVE_LLROUNDL) && defined(HAVE_ROUNDL)
661 #define HAVE_LLROUNDL 1
663 llroundl (long double x
)
665 return (long long int) roundl (x
);
671 #define HAVE_LOG10L 1
672 /* log10 function for long double variables. The version provided here
673 reduces the argument until it fits into a double, then use log10. */
675 log10l(long double x
)
677 #if LDBL_MAX_EXP > DBL_MAX_EXP
682 if (x
> 0x1p
16383L) { p2_result
+= 16383; x
/= 0x1p
16383L; }
683 if (x
> 0x1p
8191L) { p2_result
+= 8191; x
/= 0x1p
8191L; }
684 if (x
> 0x1p
4095L) { p2_result
+= 4095; x
/= 0x1p
4095L; }
685 if (x
> 0x1p
2047L) { p2_result
+= 2047; x
/= 0x1p
2047L; }
686 if (x
> 0x1p
1023L) { p2_result
+= 1023; x
/= 0x1p
1023L; }
687 val
= log10 ((double) x
);
688 return (val
+ p2_result
* .30102999566398119521373889472449302L);
691 #if LDBL_MIN_EXP < DBL_MIN_EXP
696 if (x
< 0x1p
-16380L) { p2_result
+= 16380; x
/= 0x1p
-16380L; }
697 if (x
< 0x1p
-8189L) { p2_result
+= 8189; x
/= 0x1p
-8189L; }
698 if (x
< 0x1p
-4093L) { p2_result
+= 4093; x
/= 0x1p
-4093L; }
699 if (x
< 0x1p
-2045L) { p2_result
+= 2045; x
/= 0x1p
-2045L; }
700 if (x
< 0x1p
-1021L) { p2_result
+= 1021; x
/= 0x1p
-1021L; }
701 val
= fabs(log10 ((double) x
));
702 return (- val
- p2_result
* .30102999566398119521373889472449302L);
711 #define HAVE_FLOORL 1
713 floorl (long double x
)
715 /* Zero, possibly signed. */
719 /* Large magnitude. */
720 if (x
> DBL_MAX
|| x
< (-DBL_MAX
))
723 /* Small positive values. */
724 if (x
>= 0 && x
< DBL_MIN
)
727 /* Small negative values. */
728 if (x
< 0 && x
> (-DBL_MIN
))
739 fmodl (long double x
, long double y
)
744 /* Need to check that the result has the same sign as x and magnitude
745 less than the magnitude of y. */
746 return x
- floorl (x
/ y
) * y
;
751 #if !defined(HAVE_CABSF)
754 cabsf (float complex z
)
756 return hypotf (REALPART (z
), IMAGPART (z
));
760 #if !defined(HAVE_CABS)
763 cabs (double complex z
)
765 return hypot (REALPART (z
), IMAGPART (z
));
769 #if !defined(HAVE_CABSL) && defined(HAVE_HYPOTL)
772 cabsl (long double complex z
)
774 return hypotl (REALPART (z
), IMAGPART (z
));
779 #if !defined(HAVE_CARGF)
782 cargf (float complex z
)
784 return atan2f (IMAGPART (z
), REALPART (z
));
788 #if !defined(HAVE_CARG)
791 carg (double complex z
)
793 return atan2 (IMAGPART (z
), REALPART (z
));
797 #if !defined(HAVE_CARGL) && defined(HAVE_ATAN2L)
800 cargl (long double complex z
)
802 return atan2l (IMAGPART (z
), REALPART (z
));
807 /* exp(z) = exp(a)*(cos(b) + i sin(b)) */
808 #if !defined(HAVE_CEXPF)
811 cexpf (float complex z
)
818 COMPLEX_ASSIGN (v
, cosf (b
), sinf (b
));
823 #if !defined(HAVE_CEXP)
826 cexp (double complex z
)
833 COMPLEX_ASSIGN (v
, cos (b
), sin (b
));
838 #if !defined(HAVE_CEXPL) && defined(HAVE_COSL) && defined(HAVE_SINL) && defined(EXPL)
841 cexpl (long double complex z
)
844 long double complex v
;
848 COMPLEX_ASSIGN (v
, cosl (b
), sinl (b
));
854 /* log(z) = log (cabs(z)) + i*carg(z) */
855 #if !defined(HAVE_CLOGF)
858 clogf (float complex z
)
862 COMPLEX_ASSIGN (v
, logf (cabsf (z
)), cargf (z
));
867 #if !defined(HAVE_CLOG)
870 clog (double complex z
)
874 COMPLEX_ASSIGN (v
, log (cabs (z
)), carg (z
));
879 #if !defined(HAVE_CLOGL) && defined(HAVE_LOGL) && defined(HAVE_CABSL) && defined(HAVE_CARGL)
882 clogl (long double complex z
)
884 long double complex v
;
886 COMPLEX_ASSIGN (v
, logl (cabsl (z
)), cargl (z
));
892 /* log10(z) = log10 (cabs(z)) + i*carg(z) */
893 #if !defined(HAVE_CLOG10F)
894 #define HAVE_CLOG10F 1
896 clog10f (float complex z
)
900 COMPLEX_ASSIGN (v
, log10f (cabsf (z
)), cargf (z
));
905 #if !defined(HAVE_CLOG10)
906 #define HAVE_CLOG10 1
908 clog10 (double complex z
)
912 COMPLEX_ASSIGN (v
, log10 (cabs (z
)), carg (z
));
917 #if !defined(HAVE_CLOG10L) && defined(HAVE_LOG10L) && defined(HAVE_CABSL) && defined(HAVE_CARGL)
918 #define HAVE_CLOG10L 1
920 clog10l (long double complex z
)
922 long double complex v
;
924 COMPLEX_ASSIGN (v
, log10l (cabsl (z
)), cargl (z
));
930 /* pow(base, power) = cexp (power * clog (base)) */
931 #if !defined(HAVE_CPOWF)
934 cpowf (float complex base
, float complex power
)
936 return cexpf (power
* clogf (base
));
940 #if !defined(HAVE_CPOW)
943 cpow (double complex base
, double complex power
)
945 return cexp (power
* clog (base
));
949 #if !defined(HAVE_CPOWL) && defined(HAVE_CEXPL) && defined(HAVE_CLOGL)
952 cpowl (long double complex base
, long double complex power
)
954 return cexpl (power
* clogl (base
));
959 /* sqrt(z). Algorithm pulled from glibc. */
960 #if !defined(HAVE_CSQRTF)
961 #define HAVE_CSQRTF 1
963 csqrtf (float complex z
)
974 COMPLEX_ASSIGN (v
, 0, copysignf (sqrtf (-re
), im
));
978 COMPLEX_ASSIGN (v
, fabsf (sqrtf (re
)), copysignf (0, im
));
985 r
= sqrtf (0.5 * fabsf (im
));
987 COMPLEX_ASSIGN (v
, r
, copysignf (r
, im
));
994 /* Use the identity 2 Re res Im res = Im x
995 to avoid cancellation error in d +/- Re x. */
998 r
= sqrtf (0.5 * d
+ 0.5 * re
);
1003 s
= sqrtf (0.5 * d
- 0.5 * re
);
1004 r
= fabsf ((0.5 * im
) / s
);
1007 COMPLEX_ASSIGN (v
, r
, copysignf (s
, im
));
1013 #if !defined(HAVE_CSQRT)
1014 #define HAVE_CSQRT 1
1016 csqrt (double complex z
)
1027 COMPLEX_ASSIGN (v
, 0, copysign (sqrt (-re
), im
));
1031 COMPLEX_ASSIGN (v
, fabs (sqrt (re
)), copysign (0, im
));
1038 r
= sqrt (0.5 * fabs (im
));
1040 COMPLEX_ASSIGN (v
, r
, copysign (r
, im
));
1047 /* Use the identity 2 Re res Im res = Im x
1048 to avoid cancellation error in d +/- Re x. */
1051 r
= sqrt (0.5 * d
+ 0.5 * re
);
1056 s
= sqrt (0.5 * d
- 0.5 * re
);
1057 r
= fabs ((0.5 * im
) / s
);
1060 COMPLEX_ASSIGN (v
, r
, copysign (s
, im
));
1066 #if !defined(HAVE_CSQRTL) && defined(HAVE_COPYSIGNL) && defined(HAVE_SQRTL) && defined(HAVE_FABSL) && defined(HAVE_HYPOTL)
1067 #define HAVE_CSQRTL 1
1069 csqrtl (long double complex z
)
1072 long double complex v
;
1080 COMPLEX_ASSIGN (v
, 0, copysignl (sqrtl (-re
), im
));
1084 COMPLEX_ASSIGN (v
, fabsl (sqrtl (re
)), copysignl (0, im
));
1091 r
= sqrtl (0.5 * fabsl (im
));
1093 COMPLEX_ASSIGN (v
, copysignl (r
, im
), r
);
1097 long double d
, r
, s
;
1099 d
= hypotl (re
, im
);
1100 /* Use the identity 2 Re res Im res = Im x
1101 to avoid cancellation error in d +/- Re x. */
1104 r
= sqrtl (0.5 * d
+ 0.5 * re
);
1109 s
= sqrtl (0.5 * d
- 0.5 * re
);
1110 r
= fabsl ((0.5 * im
) / s
);
1113 COMPLEX_ASSIGN (v
, r
, copysignl (s
, im
));
1120 /* sinh(a + i b) = sinh(a) cos(b) + i cosh(a) sin(b) */
1121 #if !defined(HAVE_CSINHF)
1122 #define HAVE_CSINHF 1
1124 csinhf (float complex a
)
1131 COMPLEX_ASSIGN (v
, sinhf (r
) * cosf (i
), coshf (r
) * sinf (i
));
1136 #if !defined(HAVE_CSINH)
1137 #define HAVE_CSINH 1
1139 csinh (double complex a
)
1146 COMPLEX_ASSIGN (v
, sinh (r
) * cos (i
), cosh (r
) * sin (i
));
1151 #if !defined(HAVE_CSINHL) && defined(HAVE_COSL) && defined(HAVE_COSHL) && defined(HAVE_SINL) && defined(HAVE_SINHL)
1152 #define HAVE_CSINHL 1
1154 csinhl (long double complex a
)
1157 long double complex v
;
1161 COMPLEX_ASSIGN (v
, sinhl (r
) * cosl (i
), coshl (r
) * sinl (i
));
1167 /* cosh(a + i b) = cosh(a) cos(b) - i sinh(a) sin(b) */
1168 #if !defined(HAVE_CCOSHF)
1169 #define HAVE_CCOSHF 1
1171 ccoshf (float complex a
)
1178 COMPLEX_ASSIGN (v
, coshf (r
) * cosf (i
), - (sinhf (r
) * sinf (i
)));
1183 #if !defined(HAVE_CCOSH)
1184 #define HAVE_CCOSH 1
1186 ccosh (double complex a
)
1193 COMPLEX_ASSIGN (v
, cosh (r
) * cos (i
), - (sinh (r
) * sin (i
)));
1198 #if !defined(HAVE_CCOSHL) && defined(HAVE_COSL) && defined(HAVE_COSHL) && defined(HAVE_SINL) && defined(HAVE_SINHL)
1199 #define HAVE_CCOSHL 1
1201 ccoshl (long double complex a
)
1204 long double complex v
;
1208 COMPLEX_ASSIGN (v
, coshl (r
) * cosl (i
), - (sinhl (r
) * sinl (i
)));
1214 /* tanh(a + i b) = (tanh(a) + i tan(b)) / (1 - i tanh(a) tan(b)) */
1215 #if !defined(HAVE_CTANHF)
1216 #define HAVE_CTANHF 1
1218 ctanhf (float complex a
)
1223 rt
= tanhf (REALPART (a
));
1224 it
= tanf (IMAGPART (a
));
1225 COMPLEX_ASSIGN (n
, rt
, it
);
1226 COMPLEX_ASSIGN (d
, 1, - (rt
* it
));
1232 #if !defined(HAVE_CTANH)
1233 #define HAVE_CTANH 1
1235 ctanh (double complex a
)
1238 double complex n
, d
;
1240 rt
= tanh (REALPART (a
));
1241 it
= tan (IMAGPART (a
));
1242 COMPLEX_ASSIGN (n
, rt
, it
);
1243 COMPLEX_ASSIGN (d
, 1, - (rt
* it
));
1249 #if !defined(HAVE_CTANHL) && defined(HAVE_TANL) && defined(HAVE_TANHL)
1250 #define HAVE_CTANHL 1
1252 ctanhl (long double complex a
)
1255 long double complex n
, d
;
1257 rt
= tanhl (REALPART (a
));
1258 it
= tanl (IMAGPART (a
));
1259 COMPLEX_ASSIGN (n
, rt
, it
);
1260 COMPLEX_ASSIGN (d
, 1, - (rt
* it
));
1267 /* sin(a + i b) = sin(a) cosh(b) + i cos(a) sinh(b) */
1268 #if !defined(HAVE_CSINF)
1269 #define HAVE_CSINF 1
1271 csinf (float complex a
)
1278 COMPLEX_ASSIGN (v
, sinf (r
) * coshf (i
), cosf (r
) * sinhf (i
));
1283 #if !defined(HAVE_CSIN)
1286 csin (double complex a
)
1293 COMPLEX_ASSIGN (v
, sin (r
) * cosh (i
), cos (r
) * sinh (i
));
1298 #if !defined(HAVE_CSINL) && defined(HAVE_COSL) && defined(HAVE_COSHL) && defined(HAVE_SINL) && defined(HAVE_SINHL)
1299 #define HAVE_CSINL 1
1301 csinl (long double complex a
)
1304 long double complex v
;
1308 COMPLEX_ASSIGN (v
, sinl (r
) * coshl (i
), cosl (r
) * sinhl (i
));
1314 /* cos(a + i b) = cos(a) cosh(b) - i sin(a) sinh(b) */
1315 #if !defined(HAVE_CCOSF)
1316 #define HAVE_CCOSF 1
1318 ccosf (float complex a
)
1325 COMPLEX_ASSIGN (v
, cosf (r
) * coshf (i
), - (sinf (r
) * sinhf (i
)));
1330 #if !defined(HAVE_CCOS)
1333 ccos (double complex a
)
1340 COMPLEX_ASSIGN (v
, cos (r
) * cosh (i
), - (sin (r
) * sinh (i
)));
1345 #if !defined(HAVE_CCOSL) && defined(HAVE_COSL) && defined(HAVE_COSHL) && defined(HAVE_SINL) && defined(HAVE_SINHL)
1346 #define HAVE_CCOSL 1
1348 ccosl (long double complex a
)
1351 long double complex v
;
1355 COMPLEX_ASSIGN (v
, cosl (r
) * coshl (i
), - (sinl (r
) * sinhl (i
)));
1361 /* tan(a + i b) = (tan(a) + i tanh(b)) / (1 - i tan(a) tanh(b)) */
1362 #if !defined(HAVE_CTANF)
1363 #define HAVE_CTANF 1
1365 ctanf (float complex a
)
1370 rt
= tanf (REALPART (a
));
1371 it
= tanhf (IMAGPART (a
));
1372 COMPLEX_ASSIGN (n
, rt
, it
);
1373 COMPLEX_ASSIGN (d
, 1, - (rt
* it
));
1379 #if !defined(HAVE_CTAN)
1382 ctan (double complex a
)
1385 double complex n
, d
;
1387 rt
= tan (REALPART (a
));
1388 it
= tanh (IMAGPART (a
));
1389 COMPLEX_ASSIGN (n
, rt
, it
);
1390 COMPLEX_ASSIGN (d
, 1, - (rt
* it
));
1396 #if !defined(HAVE_CTANL) && defined(HAVE_TANL) && defined(HAVE_TANHL)
1397 #define HAVE_CTANL 1
1399 ctanl (long double complex a
)
1402 long double complex n
, d
;
1404 rt
= tanl (REALPART (a
));
1405 it
= tanhl (IMAGPART (a
));
1406 COMPLEX_ASSIGN (n
, rt
, it
);
1407 COMPLEX_ASSIGN (d
, 1, - (rt
* it
));