Rate This Document
Findability
Accuracy
Completeness
Readability

DivC

Divides each element in a vector by a constant.

The function interface declaration is as follows:

  • Operations on floating-point numbers:

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

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

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

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

  • Operations on integers with scaling:

    HmppResult HMPPS_DivC_8u_S(const uint8_t *src, const uint8_t val, uint8_t *dst, int32_t len, double scale);

    HmppResult HMPPS_DivC_16u_S(const uint16_t *src, const uint16_t val, uint16_t *dst, int32_t len, doublescale);

    HmppResult HMPPS_DivC_16s_S(const int16_t *src, int16_t val, int16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_DivC_16sc_S(const Hmpp16sc *src, Hmpp16sc val, Hmpp16sc *dst, int32_t len, double scale);

  • In-place operations on floating-point numbers:

    HmppResult HMPPS_DivC_32f_I(float val, float *srcDst, int32_t len);

    HmppResult HMPPS_DivC_64f_I(double val, double *srcDst, int32_t len);

    HmppResult HMPPS_DivC_32fc_I(Hmpp32fc val, Hmpp32fc *srcDst, int32_t len);

    HmppResult HMPPS_DivC_64fc_I(Hmpp64fc val, Hmpp64fc* srcDst, int32_t len);

  • In-place operations on integers with scaling:

    HmppResult HMPPS_DivC_8u_IS(const uint8_t val, uint8_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_DivC_16u_IS(const uint16_t val, uint16_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_DivC_16sc_IS(const Hmpp16sc val, Hmpp16sc* srcDst, int32_t len, double scale);

    HmppResult HMPPS_DivC_16s_IS(int16_t val, int16_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_DivC_64s_IS(int64_t val, int64_t *srcDst, int32_t len, double scale);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector

The value cannot be NULL.

Input

val

Fixed value, divisor

The value cannot be 0.

Input

dst

Pointer to the destination vector

The value cannot be NULL.

Output

srcDst

Performs operations on the vector directly, and is used as a source vector and a destination 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 src, dst, or srcDst is NULL.

HMPP_STS_SIZE_ERR

The value of len must be greater than 0.

HMPP_STS_DIV_BY_ZERO_ERR

The divisor is 0.

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 DivCExample(void)
{
    float src[BUFFER_SIZE_T] = {10.42, 8.64, 3.22, 10.90, 10.11, 4.27, 0.53, 4.00, 4.73, -1.23};
    float dst[BUFFER_SIZE_T] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00};
    float val = 8.51;
    int32_t i, result;
    result = HMPPS_DivC_32f(src, val, 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 = 1.22  1.02  0.38  1.28  1.19  0.50  0.06  0.47  0.56 -0.14