Rate This Document
Findability
Accuracy
Completeness
Readability

SubCRev

Subtracts a vector from a constant.

The function interface declaration is as follows:

  • Operations on floating-point numbers:

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

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

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

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

  • Scaling of integers:

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

    HmppResult HMPPS_SubCRev_32s_S(const int32_t *src, int32_t val, int32_t *dst, int32_t len, int32_t scale);

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

    HmppResult HMPPS_SubCRev_16u_S(const uint16_t *src, uint16_t val, uint16_t *dst, int32_t len, int32_t scale);

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

    HmppResult HMPPS_SubCRev_32sc_S(const Hmpp32sc *src, Hmpp32sc val, Hmpp32sc *dst, int32_t len, int32_t scale);

  • In-place operations on floating-point numbers:

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

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

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

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

  • In-place scaling on integers:

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

    HmppResult HMPPS_SubCRev_32s_IS(int32_t val, int32_t *srcDst, int32_t len ,int32_t scale);

    HmppResult HMPPS_SubCRev_8u_IS(uint8_t val, uint8_t *srcDst, int32_t len, int32_t scale);

    HmppResult HMPPS_SubCRev_16u_IS(uint16_t val, uint16_t *srcDst, int32_t len, int32_t scale);

    HmppResult HMPPS_SubCRev_16sc_IS(Hmpp16sc val, Hmpp16sc *srcDst, int32_t len, int32_t scale);

    HmppResult HMPPS_SubCRev_32sc_IS(Hmpp32sc val, Hmpp32sc *srcDst, int32_t len, int32_t scale);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the subtrahend

The value cannot be NULL.

Input

val

Given constant

Not limited, depending on the type

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

[INT_MIN, 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 10

void SubCRevExample(void)
{
    float src[BUFFER_SIZE_T] = {1.46,  9.40, 10.73, 5.90, 5.74, -0.96, 8.55, -1.39, 1.71, 2.32}; 
    float valTest = 8.51;
    float dst[BUFFER_SIZE_T] = {0.00};
    (void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T);

    HmppResult result =  HMPPS_SubCRev_32f(src, valTest, 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:

subCRev: result = 0.
dst = 7.05    -0.89    -2.22    2.61    2.77    9.47    -0.04    9.90    6.80    6.19