mirror of
https://github.com/fluencelabs/musl
synced 2025-04-24 23:02:14 +00:00
the factor of -i noted in the comment at the top of casin.c was omitted from the actual code, yielding a result rotated 90 degrees and propagating into errors in other functions defined in terms of casin. implement multiplication by -i as a rotation of the real and imaginary parts of the result, rather than by actual multiplication, since the latter cannot be optimized without knowledge that the operand is finite. here, the rotation is the actual intent, anyway.
22 lines
435 B
C
22 lines
435 B
C
#include "libm.h"
|
|
|
|
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
|
|
long double complex casinl(long double complex z)
|
|
{
|
|
return casin(z);
|
|
}
|
|
#else
|
|
// FIXME
|
|
long double complex casinl(long double complex z)
|
|
{
|
|
long double complex w;
|
|
long double x, y;
|
|
|
|
x = creall(z);
|
|
y = cimagl(z);
|
|
w = CMPLXL(1.0 - (x - y)*(x + y), -2.0*x*y);
|
|
long double complex r = clogl(CMPLXL(-y, x) + csqrtl(w));
|
|
return CMPLXL(cimagl(r), -creall(r));
|
|
}
|
|
#endif
|