我要评分
获取效率
正确性
完整性
易理解

catan

Compute the arctangent of complex number x.

Interface Definition

C interface:

float complex catanf(float complex x);

double complex catan(double complex x);

long double complex catanl(long double complex x);

Parameters

Parameter

Type

Description

Input/Output

x

  • For catanf, x is of single-precision floating-point complex type.
  • For catan, x is of double-precision floating-point complex type.
  • For catanl, x is of complex, long, double-precision floating-point type.

Floating-point value of the input data.

Input

Return Value

  • The arctangent y of x is returned.
  • The special values are listed in the following table.

    Real Part of the Input (x.real)

    Imaginary Part of the Input (x.imag)

    Real Part of the Output (y.real)

    Imaginary Part of the Output (y.imag)

    -inf

    -inf

    –π/2

    -0.0

    -inf

    < +0.0

    –π/2

    -0.0

    -inf

    -0.0

    –π/2

    -0.0

    -inf

    +0.0

    –π/2

    +0.0

    -inf

    > +0.0

    –π/2

    +0.0

    -inf

    inf

    –π/2

    +0.0

    -inf

    -nan

    –π/2

    +0.0

    -inf

    nan

    –π/2

    +0.0

    < +0.0

    -inf

    –π/2

    -0.0

    < +0.0

    inf

    –π/2

    +0.0

    < +0.0

    -nan

    nan

    nan

    < +0.0

    nan

    nan

    nan

    -0.0

    -inf

    –π/2

    -0.0

    -0.0

    -0.0

    -0.0

    -0.0

    -0.0

    +0.0

    -0.0

    0.0

    -0.0

    inf

    –π/2

    +0.0

    -0.0

    -nan

    nan

    nan

    -0.0

    nan

    nan

    nan

    +0.0

    -inf

    π/2

    -0.0

    +0.0

    -0.0

    +0.0

    -0.0

    +0.0

    +0.0

    +0.0

    +0.0

    +0.0

    inf

    π/2

    +0.0

    +0.0

    -nan

    nan

    nan

    +0.0

    nan

    nan

    nan

    > +0.0

    -inf

    π/2

    -0.0

    > +0.0

    inf

    π/2

    +0.0

    > +0.0

    -nan

    nan

    nan

    > +0.0

    nan

    nan

    nan

    inf

    -inf

    π/2

    -0.0

    inf

    < +0.0

    π/2

    -0.0

    inf

    -0.0

    π/2

    -0.0

    inf

    +0.0

    π/2

    +0.0

    inf

    > +0.0

    π/2

    +0.0

    inf

    inf

    π/2

    +0.0

    inf

    -nan

    π/2

    +0.0

    inf

    nan

    π/2

    +0.0

    -nan

    -inf

    nan

    -0.0

    -nan

    < +0.0

    nan

    nan

    -nan

    -0.0

    nan

    -0.0

    -nan

    +0.0

    nan

    +0.0

    -nan

    > +0.0

    nan

    nan

    -nan

    inf

    nan

    +0.0

    -nan

    -nan

    nan

    nan

    -nan

    nan

    nan

    nan

    nan

    -inf

    nan

    -0.0

    nan

    < +0.0

    nan

    nan

    nan

    -0.0

    nan

    -0.0

    nan

    +0.0

    nan

    +0.0

    nan

    > +0.0

    nan

    nan

    nan

    inf

    nan

    +0.0

    nan

    -nan

    nan

    nan

    nan

    nan

    nan

    nan

Dependency

C: "km.h"

Example

C interface:
    // typical usage
    double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0;
    double complex cx1 = __builtin_complex(x1, x2);
    double complex cx2 = __builtin_complex(x3, x4);
    double complex cx3 = __builtin_complex(NAN, NAN);
    double complex cx4 = __builtin_complex(INFINITY, -INFINITY);
    double ry;
    double iy;
    ry = __real__ catan(cx1);
    iy = __imag__ catan(cx1);
    printf("catan(cx1) = %.15f, %.15f\n", ry, iy);
    ry = __real__ catan(cx2);
    iy = __imag__ catan(cx2);
    printf("catan(cx2) = %.15f, %.15f\n", ry, iy);
    ry = __real__ catan(cx3);
    iy = __imag__ catan(cx3);
    printf("catan(cx3) = %.15f, %.15f\n", ry, iy);
    ry = __real__ catan(cx4);
    iy = __imag__ catan(cx4);
    printf("catan(cx4) = %.15f, %.15f\n", ry, iy);

result:
   /*
    * catan(cx1) = 1.338972522294493, 0.402359478108525
    * catan(cx2) = 1.448306995231464, 0.158997191679999
    * catan(cx3) = nan, nan
    * catan(cx4) = 1.570796326794897, -0.000000000000000
    */