Rate This Document
Findability
Accuracy
Completeness
Readability

Div

Divides a vector by another vector.

The function interface declaration is as follows:

  • Operations on integers with scaling:

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

    HmppResult HMPPS_Div_16u_S(const uint16* src1, const uiuint16_tsrc2, uiuint16_tdst, int32_t len, double scale);

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

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

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

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

  • Operations on floating-point numbers:

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

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

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

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

  • In-place operations on integers with scaling:

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

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

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

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

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

  • In-place operations on floating-point numbers:

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

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

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

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

Parameters

Parameter

Description

Value Range

Input/Output

src1

Pointer to the divisor vector

The value cannot be NULL.

Input

src2

Pointer to the dividend 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

scale

Scale factor

scale = 2^n, 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 must be greater than 0.

HMPP_STS_DIV_BY_ZERO_ERR

Divide-by-zero error

HMPP_STS_SCALE_ERR

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

Example

#define BUFFER_SIZE_T 10
void DivExample(void)
{
    float src1[BUFFER_SIZE_T] = { -1.64, -1.63, -1.09, 0.71, 3.20, -0.43, -0.41, 4.83, 5.36, 4.40};
    float src2[BUFFER_SIZE_T] = { 5.20, 9.12, 0.86, 10.13, 5.94, -0.62, 9.19, 11.44, -0.07, 10.23};
    float dst[BUFFER_SIZE_T] = {0.00};
    int32_t i, result;
    result = HMPPS_Div_32f(src1, src2, dst, BUFFER_SIZE_T);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("dst =");
    for (i = 0; i < BUFFER_SIZE_T; i++) {
        printf(" %.2f", dst[i]);
    }
    printf("\n");
}

Output:

result = 0.
dst = -3.17  -5.60  -0.79  14.27  1.86  1.44  -22.41  2.37  -0.01  2.32