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

Add

Adds two vectors.

The function interface declaration is as follows:

  • Operations on integers:

    HmppResult HMPPS_Add_8u16u(const uint8_t *src1, const uint8_t *src2, uint16_t *dst, int32_t len);

    HmppResult HMPPS_Add_16u(const uint16_t *src1, const uint16_t *src2, uint16_t *dst, int32_t len);

    HmppResult HMPPS_Add_32u(const uint32_t *src1, const uint32_t *src2, uint32_t *dst, int32_t len);

    HmppResult HMPPS_Add_16s(const int16_t *src1, const int16_t *src2, int16_t *dst, int32_t len);

  • Operations on integers and floating-point numbers:

    HmppResult HMPPS_Add_16s32f(const int16_t *src1, const int16_t *src2, float *dst, int32_t len);

  • Operations on floating-point numbers:

    HmppResult HMPPS_Add_32f(const float *src1, const float *src2, float *dst, int32_t len);

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

    HmppResult HMPPS_Add_32fc(const Hmpp32fc *src1, const Hmpp32fc *src2, Hmpp32fc *dst, int32_t len);

    HmppResult HMPPS_Add_64fc(const Hmpp64fc *src1, const Hmpp64fc *src2, Hmpp64fc *dst, int32_t len);

  • Operations on integers with scaling:

    HmppResult HMPPS_Add_8u_S(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Add_16u_S(const uint16_t *src1, const uint16_t *src2, uint16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Add_16s_S(const int16_t *src1, const int16_t *src2, int16_t *dst, int32_t len, double scale);

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

    HmppResult HMPPS_Add_64s_S(const int64_t *src1, const int64_t *src2, int64_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Add_16sc_S(const Hmpp16sc *src1, const Hmpp16sc *src2, Hmpp16sc *dst, int32_t len, double scale);

    HmppResult HMPPS_Add_32sc_S(const Hmpp32sc *src1, const Hmpp32sc *src2, Hmpp32sc *dst, int32_t len, double scale);

  • In-place operations on integers:

    HmppResult HMPPS_Add_32u_I(const uint32_t *src, uint32_t *srcDst, int32_t len);

    HmppResult HMPPS_Add_16s_I(const int16_t *src, int16_t *srcDst, int32_t len);

    HmppResult HMPPS_Add_16s32s_I(const int16_t *src, int32_t *srcDst, int32_t len);

  • In-place operations on floating-point numbers:

    HmppResult HMPPS_Add_32f_I(const float *src, float *srcDst, int32_t len);

    HmppResult HMPPS_Add_64f_I(const double *src, double *srcDst, int32_t len);

    HmppResult HMPPS_Add_32fc_I(const Hmpp32fc *src, Hmpp32fc *srcDst, int32_t len);

    HmppResult HMPPS_Add_64fc_I(const Hmpp64fc *src, Hmpp64fc *srcDst, int32_t len);

  • In-place operations on integers with scaling:

    HmppResult HMPPS_Add_8u_IS(const uint8_t *src, uint8_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Add_16u_IS(const uint16_t *src, uint16_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Add_16s_IS(const int16_t *src, int16_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Add_32s_IS(const int32_t *src, int32_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Add_16sc_IS(const Hmpp16sc *src, Hmpp16sc *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Add_32sc_IS(const Hmpp32sc *src, Hmpp32sc *srcDst, int32_t len, double scale);

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

srcDst

Pointer to the source vector for in-place operations

The value cannot be NULL.

Input/Output

len

Vector length

(0, INT_MAX]

Input

scale

Scale factor

scale = 2n, where n is an integer. The value is within (0, INF).

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

HMPP_STS_SIZE_ERR

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

HMPP_STS_SCALE_ERR

The value of scale is not within the range (0, INF) or the input is not a number (NaN).

Example

#define BUFFER_SIZE_T 9
void AddExample(void)
{
    uint32_t src1[BUFFER_SIZE_T] = {1598181665, 1446829146, 2752624014, 2171200733, 2676378769, 1078554841, 1318511000, 2592925506, 2518880388};
    uint32_t src2[BUFFER_SIZE_T] = {422526272, 1563791282, 1664517688, 1278844750, 1984585164, 1554125489, 1115993496, 1182866132, 2965039412};
    uint32_t dst[BUFFER_SIZE_T] = {0};
 
    HmppResult result = HMPPS_Add_32u(src1, src2, dst, BUFFER_SIZE_T);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }

    printf("\ndst = ");
    for (int32_t i = 0; i < BUFFER_SIZE_T; i++) {
        printf("%d ", dst[i]);
    }
}

Output:

result = 0
dst = 2020707937 -1284346868 -1 -844921813 -1 -1662286966 -1860462800 -519175658 -1