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

Sin

Calculates the sine of each element in the source vector.

The function interface declaration is as follows:

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

HmppResult HMPPS_Sin_64f(const double* src, double* dst, int32_t len);

HmppResult HMPPS_Sin_32fc(const Hmpp32fc* src, Hmpp32fc* dst, int32_t len);

HmppResult HMPPS_Sin_64fc(const Hmpp64fc* src, Hmpp64fc* dst, int32_t len);

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

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 or dst is NULL.

HMPP_STS_SIZE_ERR

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

Example

#define  BUFFER_SIZE_T 5
void SinExample()
{
    float src[BUFFER_SIZE_T] = {1, 2.5, 3.3, 1, 5};
    float constValue = 2;
    float dst[BUFFER_SIZE_T];
    HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
    HmppResult result = HMPPS_Sin_32f(src, dst, BUFFER_SIZE_T);
    if (result == HMPP_STS_NO_ERR) {
        printf("dst = ");
        for (int32_t i = 0; i < BUFFER_SIZE_T; i++) {
            printf("%.2f ", dst[i]);
        }
        printf("\n");
    }
}

Output:

dst = 0.84 0.60 -0.16 0.84 -0.96