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

v?arg

Compute the argument of the input complex number, that is, the arctangent value of the ratio of the imaginary part to the real part.

Interface Definition

C interface:

void vcarg(const int len, const float complex* src, float* dst);

void vzarg(const int len, const double complex* src, double* dst);

Parameters

Parameter

Type

Description

Input/Output

len

Integer

Number of elements in the input vector.

If len ≤ 0, the system displays a message indicating that the value of len is invalid.

Input

src

  • Single-precision floating-point complex type for vcarg
  • Double-precision floating-point complex type for vzarg

Input vector src with length len.

If the pointer is null, the system prompts a null pointer error.

Input

dst

  • Single-precision floating-point type for vcarg
  • Double-precision floating-point type for vzarg

Output vector dst with length len.

If the pointer is null, the system prompts a null pointer error.

Output

Return Value

  • The argument of the input complex number is returned for each operation value. The formula is: arg(x + yi) = arctan(y/x)
  • For special values, see the following table.

RE(z)

i * IM(z)

-∞

-X

-0

+0

+X

+∞

NAN

+i * ∞

+∞+i*∞

+π/2

+π/2

+π/2

+π/2

+π/4

NAN

+i * Y

  

+π/2

+π/2

  

+0

NAN

+i * 0

+0

+0

+0

NAN

-i * 0

-0

-0

-0

NAN

-i * Y

  

-π/2

-π/2

  

-0

NAN

-i * ∞

-3*π/4

-π/2

-π/2

-π/2

-π/2

-π/4

NAN

+i * NAN

NAN

NAN

NAN

NAN

NAN

NAN

NAN

Dependency

C: "kvml.h"

Example

C interface:
    #define N 4
    const complex float src[N] = {
        __builtin_complex(-8.0f, 25.0f),
        __builtin_complex(+INFINITY, -2.1f),
        __builtin_complex(2.6f, 25.0f),
        __builtin_complex(-0.0f, +0.1f)
    };
    float dst[N] = {0};

    vcarg(N, src, dst);
    printFArr("output:", N, dst);
 
    /** 
     *  input: (-8.000,25.000) (  inf,-2.100) (2.600,25.000) (-0.000,0.100)
     *  output: 1.880   -0.000    1.467    1.571
     */