Rate This Document
Findability
Accuracy
Completeness
Readability

ccos

Compute the cosine of a complex number.

Interface Definition

C interface:

float complex ccosf(float complex x);

double complex ccos(double complex x);

Parameters

Parameter

Type

Description

Input/Output

x

  • For ccosf, x is of single-precision floating-point complex type.
  • For ccos, x is of double-precision floating-point complex type.

Floating-point value of the input data.

Input

Return Value

  • Normal range: The cosine of the complex number x is returned.
  • Special values: See 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

    -inf

    nan

    -inf

    < +0

    nan

    nan

    -inf

    -0

    nan

    -0

    -inf

    +0

    nan

    +0

    -inf

    > +0

    nan

    nan

    -inf

    inf

    inf

    nan

    -inf

    -nan

    nan

    nan

    -inf

    nan

    nan

    nan

    < +0

    -nan

    nan

    nan

    < +0

    nan

    nan

    nan

    -0

    -inf

    inf

    -0

    -0

    -0

    1

    -0

    -0

    +0

    1

    +0

    -0

    inf

    inf

    +0

    -0

    -nan

    nan

    -0

    -0

    nan

    nan

    -0

    +0

    -inf

    inf

    +0

    +0

    -0

    1

    +0

    +0

    +0

    1

    -0

    +0

    inf

    inf

    -0

    +0

    -nan

    nan

    +0

    +0

    nan

    nan

    +0

    > +0

    -nan

    nan

    nan

    > +0

    nan

    nan

    nan

    inf

    -inf

    inf

    nan

    inf

    < +0

    nan

    nan

    inf

    -0

    nan

    +0

    inf

    +0

    nan

    -0

    inf

    > +0

    nan

    nan

    inf

    inf

    inf

    nan

    inf

    -nan

    nan

    nan

    inf

    nan

    nan

    nan

    -nan

    -inf

    inf

    nan

    -nan

    < +0

    nan

    nan

    -nan

    -0

    nan

    -0

    -nan

    +0

    nan

    +0

    -nan

    > +0

    nan

    nan

    -nan

    inf

    inf

    nan

    -nan

    -nan

    nan

    nan

    -nan

    nan

    nan

    nan

    nan

    -inf

    inf

    nan

    nan

    < +0

    nan

    nan

    nan

    -0

    nan

    -0

    nan

    +0

    nan

    +0

    nan

    > +0

    nan

    nan

    nan

    inf

    inf

    nan

    nan

    -nan

    nan

    nan

    nan

    nan

    nan

    nan

Dependency

C: "kc.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(INFINITY, -INFINITY);

    // print result
    double ry;
    double iy;
    ry = __real__ ccos(cx1);
    iy = __imag__ ccos(cx1);
    printf("ccos(cx1) = %.15f, %.15f\n", ry, iy);
    ry = __real__ ccos(cx2);
    iy = __imag__ ccos(cx2);
    printf("ccos(cx2) = %.15f, %.15f\n", ry, iy);
    ry = __real__ ccos(cx3);
    iy = __imag__ ccos(cx3);
    printf("ccos(cx3) = %.15f, %.15f\n", ry, iy);

result
    /*
     * ccos(cx1) = 2.032723007019666, -3.051897799151800
     * ccos(cx2) = -27.034945603074224, 3.851153334811777
     * ccos(cx3) = inf, nan
     * */