summaryrefslogtreecommitdiff
path: root/lib/libm/ctanl.c
blob: 65a9c2a58ca15da6c95d219e85f2685fed5d1d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "__complex.h" // for ctansl

#include <complex.h> // for cimagl, complex, creall, I, ctanl
#include <math.h>    // for HUGE_VALL, coshl, cosl, fabsl, sinhl, sinl

long double complex ctanl(long double complex z)
{
	long double d = cosl(2.0L * creall(z)) + coshl(2.0L * cimagl(z));

	if (fabsl(d) < 0.25L) {
		d = ctansl(z);
	}

	if (d == 0.0L) {
		return HUGE_VALL + HUGE_VALL * (long double complex)I;
	}

	return sinl(2.0L * creall(z)) / d +
	       (sinhl(2.0L * cimagl(z)) / d) * (long double complex)I;
}