Rate This Document
Findability
Accuracy
Completeness
Readability

v?atan2

Compute the element-wise arc tangent of src1/src2. src1, src2, and the arc tangent are all vectors.

Interface Definition

C interface:

void vsatan2(const int len, const float* src1, const float* src2, float* dst);

void vdatan2(const int len, const double* src1, const double* src2, double* dst);

Fortran interface:

CALL VSATAN2(LEN, SRC1, SRC2, DST);

CALL VDATAN2(LEN, SRC1, SRC2, 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

src1

  • For vsatan2, src1 is of single-precision floating-point type.
  • For vdatan2, src1 is of double-precision floating-point type.

Input vector src1 with length len.

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

Input

src2

  • For vsatan2, src2 is of single-precision floating-point type.
  • For vdatan2, src2 is of double-precision floating-point type.

Input vector src2 with length len.

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

Input

dst

  • For vsatan2, dst is of single-precision floating-point type.
  • For vdatan2, dst is of double-precision floating-point type.

Output vector dst with length len.

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

Output

Return Value

  • An azimuth from the origin to the point (x, y) is returned for each operation value atan2(y, x), that is, the included angle with reference to the x-axis. The unit of the return value is radian, and the value range is (-π, +π].
  • If y is ±0 and x is negative or -0, the return value is ±π.
  • If y is ±0 and x is positive or +0, the return value is ±0.
  • If y is ±∞ and x is a finite number, the return value is ±π/2.
  • If y is ±∞ and x is –∞, the return value is ±3π/4.
  • If y is ±∞ and x is +∞, the return value is ±π/4.
  • If x is ±0 and y is negative, the return value is -π/2.
  • If x is ±0 and y is positive, the return value is +π/2.
  • If x is -∞ and y is a finite positive number, the return value is +π.
  • If x is -∞ and y is a finite negative number, the return value is -π.
  • If x is +∞ and y is a finite positive number, the return value is +0.
  • If x is +∞ and y is a finite negative number, the return value is -0.
  • If x or y is NaN, the return value is NaN.

Dependencies

C: "kvml.h"

Fortran: "kvml.f03"

Examples

C interface:

    int i, len = 4; 
    float src1[len] = [0.0f, 1.0f, -inf, inf]; 
    float src2[len] = [0.0f, 2.0f, inf, nan]; 
    float* dst = (float*)malloc(sizeof(float) * len); 
    if (dst == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0; 
    } 
    vsatan2(len, src1, src2, dst); 
    /** 
     *  Output dst: 
     *     0.0  0.463647603988647  -0.785398185253143  nan 
     * 
     */

Fortran interface:

    INTEGER :: LEN = 4 
    REAL(4) SRC1(4)  
    REAL(4) SRC2(4) 
    REAL(4) DST(4) 
    DATA SRC1 /1.2, 2.5, -2.4, 3.6/ 
    DATA SRC2 /8.6, -2.5, -12.4, 32.6/ 
    CALL VSATAN2(LEN, SRC1, SRC2, DST) 
    !  
    ! OUTPUT DST: 
    !     0.138639733, 2.35619450, -2.95040822, 0.109983824 
    !