Rate This Document
Findability
Accuracy
Completeness
Readability

Arctan

Calculates the arc tangent value of each element in a vector.

The calculation formula is: pDst[n]=tan-1(pSrc[n]), where n ranges [0, len).

The function interface declaration is as follows:

  • Operations on floating-point numbers:

    HmppResult HMPPS_Arctan_32f(const float* src, float* dst, int32_t len);

    HmppResult HMPPS_Arctan_64f(const double* src, double* dst, int32_tlen);

  • In-place operations on floating-point numbers:

    HmppResult HMPPS_Arctan_32f_I(float* srcDst, int32_tlen);

    HmppResult HMPPS_Arctan_64f_I(double* srcDst, int32_tlen);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector

The value cannot be NULL.

Input

dst

Pointer to the destination vector

The value cannot be NULL.

Output

srcDst

Pointer to the in-place operation vector

The value cannot be NULL.

Input/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 src, dst, or srcDst is NULL.

HMPP_STS_SIZE_ERR

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

Example

#define BUFFER_SIZE_T 10

void ArctanExample(void)
{
    float src[BUFFER_SIZE_T] = {4.52, 5.92, 5.16, 6.15, 8.17, 9.93, 6.04, 11.17, 2.79, 3.58};
    float dst[BUFFER_SIZE_T];
    (void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
    HmppResult result = HMPPS_Arctan_32f(src, 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 = 1.35 1.40 1.38 1.41 1.45 1.47 1.41 1.48 1.23 1.30