* mingwex/complex/(cabsf.c cacosf.c cacoshf.c cargf.c casinf.c
casinhf.c catanf.c catanhf.c ccosf.c ccoshf.c cexpf.c cimagf.c
clogf.c cpowf.c cprojf.c crealf.c csinf.c csinhf.c csqrtf.c
ctanf.c ctanhf.c): New files.
* mingwex/Makefile.in (COMPLEX_DISTFILES): Adjust.
(COMPLEX_OBJS(: Adjust.
* include/complex.h (cabsf, cacosf, cacoshf, cargf, casinf.
casinhf, catanf, catanhf, ccosf, ccoshf, cexpf, cimagf, clogf,
cpowf, cprojf, crealf, csinf, csinhf, csqrtf, ctanf, ctanhf):
Declare.
2004-12-26 07:56:19 +08:00
|
|
|
#include <math.h>
|
|
|
|
#include <complex.h>
|
|
|
|
|
|
|
|
float complex csqrtf (float complex Z)
|
|
|
|
{
|
|
|
|
float complex Res;
|
|
|
|
float r;
|
|
|
|
float x = __real__ Z;
|
|
|
|
float y = __imag__ Z;
|
|
|
|
|
|
|
|
if (y == 0.0f)
|
|
|
|
{
|
|
|
|
if (x < 0.0f)
|
|
|
|
{
|
|
|
|
__real__ Res = 0.0f;
|
|
|
|
__imag__ Res = sqrtf (-x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__real__ Res = sqrtf (x);
|
|
|
|
__imag__ Res = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (x == 0.0f)
|
|
|
|
{
|
|
|
|
r = sqrtf(0.5f * fabsf (y));
|
2005-10-12 14:46:18 +08:00
|
|
|
__real__ Res = r;
|
|
|
|
__imag__ Res = y > 0 ? r : -r;
|
* mingwex/complex/(cabsf.c cacosf.c cacoshf.c cargf.c casinf.c
casinhf.c catanf.c catanhf.c ccosf.c ccoshf.c cexpf.c cimagf.c
clogf.c cpowf.c cprojf.c crealf.c csinf.c csinhf.c csqrtf.c
ctanf.c ctanhf.c): New files.
* mingwex/Makefile.in (COMPLEX_DISTFILES): Adjust.
(COMPLEX_OBJS(: Adjust.
* include/complex.h (cabsf, cacosf, cacoshf, cargf, casinf.
casinhf, catanf, catanhf, ccosf, ccoshf, cexpf, cimagf, clogf,
cpowf, cprojf, crealf, csinf, csinhf, csqrtf, ctanf, ctanhf):
Declare.
2004-12-26 07:56:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float t = sqrtf (2 * (_hypot (__real__ Z, __imag__ Z) + fabsf (x)));
|
|
|
|
float u = t / 2.0f;
|
|
|
|
if ( x > 0.0f)
|
|
|
|
{
|
|
|
|
__real__ Res = u;
|
|
|
|
__imag__ Res = y / t;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__real__ Res = fabsf (y / t);
|
|
|
|
__imag__ Res = y < 0 ? -u : u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Res;
|
|
|
|
}
|