long double complex CLANG_PORT_DECL(cpowl) (long double complex X, long double complex Y) { long double complex Res; long double i; long double r = hypotl (__real__ X, __imag__ X); if (r == 0.0L) { __real__ Res = __imag__ Res = 0.0L; } else { long double rho; long double theta; i = cargl (X); theta = i * __real__ Y; if (__imag__ Y == 0.0L) /* This gives slightly more accurate results in these cases. */ rho = powl (r, __real__ Y); else { r = logl (r); /* rearrangement of cexp(X * clog(Y)) */ theta += r * __imag__ Y; rho = expl (r * __real__ Y - i * __imag__ Y); } __real__ Res = rho * cosl (theta); __imag__ Res = rho * sinl (theta); } return Res; }
long double complex clog10l (long double complex z) { long double complex v; COMPLEX_ASSIGN (v, log10l (cabsl (z)), cargl (z)); return v; }
void test3l(__complex__ long double x, __complex__ long double y, int i) { if (ccosl(x) != ccosl(-x)) link_error(); if (ccosl(ctanl(x)) != ccosl(ctanl(-x))) link_error(); if (ctanl(x-y) != -ctanl(y-x)) link_error(); if (ccosl(x/y) != ccosl(-x/y)) link_error(); if (ccosl(x/y) != ccosl(x/-y)) link_error(); if (ccosl(x/ctanl(y)) != ccosl(-x/ctanl(-y))) link_error(); if (ccosl(x*y) != ccosl(-x*y)) link_error(); if (ccosl(x*y) != ccosl(x*-y)) link_error(); if (ccosl(ctanl(x)*y) != ccosl(ctanl(-x)*-y)) link_error(); if (ccosl(ctanl(x/y)) != ccosl(-ctanl(x/-y))) link_error(); if (ccosl(i ? x : y) != ccosl(i ? -x : y)) link_error(); if (ccosl(i ? x : y) != ccosl(i ? x : -y)) link_error(); if (ccosl(i ? x : ctanl(y/x)) != ccosl(i ? -x : -ctanl(-y/x))) link_error(); if (~x != -~-x) link_error(); if (ccosl(~x) != ccosl(-~-x)) link_error(); if (ctanl(~(x-y)) != -ctanl(~(y-x))) link_error(); if (ctanl(~(x/y)) != -ctanl(~(x/-y))) link_error(); #ifdef HAVE_C99_RUNTIME if (cargl(x) != atan2l(__imag__ x, __real__ x)) link_error (); #endif }
long double complex cpowl(long double complex a, long double complex z) { long double complex w; long double x, y, r, theta, absa, arga; x = creall(z); y = cimagl(z); absa = cabsl(a); if (absa == 0.0L) { return (0.0L + 0.0L * I); } arga = cargl(a); r = powl(absa, x); theta = x * arga; if (y != 0.0L) { r = r * expl(-y * arga); theta = theta + y * logl(absa); } w = r * cosl(theta) + (r * sinl(theta)) * I; return (w); }
TEST_TRACE(C99 7.3.8.1) d = cabs(d); f = cabsf(f); ld = cabsl(ld); TEST_TRACE(C99 7.3.8.2) d = cpow(d, d); f = cpowf(f, f); ld = cpowl(ld, ld); TEST_TRACE(C99 7.3.8.3) d = csqrt(d); f = csqrtf(f); ld = csqrtl(ld); TEST_TRACE(C99 7.3.9.1) d = carg(d); f = cargf(f); ld = cargl(ld); TEST_TRACE(C99 7.3.9.2) d = cimag(d); f = cimagf(f); ld = cimagl(ld); TEST_TRACE(C99 7.3.9.3) d = conj(d); f = conjf(f); ld = conjl(ld); TEST_TRACE(C99 7.3.9.4) d = cproj(d); f = cprojf(f); ld = cprojl(ld); } TEST_TRACE(C99 7.3.9.5) double rd = creal(d);
TEST(complex, cargl) { ASSERT_EQ(0.0, cargl(0)); }