Rate This Document
Findability
Accuracy
Completeness
Readability

Arctan2

Calculates the arc tangent values of two vectors in four quadrants.

The formula is as follows: Dst[n]=tan-1(Src[n]), where n ranges [0, len).

The function interface is declared as follows:

Operations on floating-point numbers:

HmppResult HMPPS_Arctan2_32f(const float *src1, const float *src2, float *dst, const int32_tlen);

HmppResult HMPPS_Arctan2_64f(const double *src1, const double *src2, double *dst, const int32_t len);

Parameters

Parameter

Description

Value Range

Input/Output

src1

Pointer to the first source vector

The value cannot be NULL.

Input

src2

Pointer to the second source vector

The value cannot be NULL.

Input

dst

Pointer to the destination vector

The value cannot be NULL.

Output

len

Vector length

(0, INT_MAX]

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

The value of src1, src2, or dst is NULL.

HMPP_STS_SIZE_ERR

The value of len is equal to or less than 0.

Example

#define BUFFER_SIZE_T 10

void Arctan2Example(void)
{
    float src1[BUFFER_SIZE_T] = {4.52, 5.92, 5.16, 6.15, 8.17, 9.93, 6.04, 11.17, 2.79, 3.58};
    float src2[BUFFER_SIZE_T] = {11.17, 2.79, 3.58, 4.52, 5.92, 5.16, 6.15, 8.17, 9.93, 6.04};
    float dst[BUFFER_SIZE_T];
    (void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T);
    HmppResult result = HMPPS_Arctan2_32f(src1, src2, dst, BUFFER_SIZE_T);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("dst =");
    for (int i = 0; i < BUFFER_SIZE_T; i++) {
        printf(" %.2f", dst[i]);
    }
    printf("\n");
}

Output:

result = 0
dst = 0.38 1.13 0.96 0.94 0.94 1.09 0.78 0.94 0.27 0.54