Rate This Document
Findability
Accuracy
Completeness
Readability

ThresholdInv

Sets a lower limit for the moduli of elements in a vector and calculates the reciprocals of the elements.

level indicates the modulus of an element and must be a positive real number. The calculation formula is as follows:

If the vector element includes 0 and level is also 0, the formula is:

The function interface declaration is as follows:

  • Operations on floating-point numbers:

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

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

    HmppResult HMPPS_Threshold_LTInv_32fc(const Hmpp32fc *src, Hmpp32fc *dst, int32_t len, float level);

  • In-place operations on floating-point numbers:

    HmppResult HMPPS_Threshold_LTInv_32f_I(float *srcDst, int32_t len, float level);

    HmppResult HMPPS_Threshold_LTInv_64f_I(double *srcDst, int32_t len, double level);

    HmppResult HMPPS_Threshold_LTInv_32fc_I(Hmpp32fc *srcDst, int32_t len, float level);

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

srcDst

Pointer to the source vector for in-place operations

The value cannot be NULL.

Input/Output

len

Vector length

(0, INT_MAX]

Input

level

Threshold

Non-negative

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.

HMPP_STS_THRESH_NEG_LEVEL_ERR

The threshold is less than 0.

HMPP_STS_INV_ZERO

This warning is generated when level is 0 or the vector element is 0. The program continues to execute, and the corresponding destination vector element is Inf(∞).

Example

#define  BUFFER_SIZE_T 20

void ThresholdInvExample(void)
{
    float src[BUFFER_SIZE_T] = { 7.68, 3.24, 10.00, 3.29, 5.34, 4.04, 5.57, 7.23, 0.63, 9.39, 9.80, 8.57, -0.94, 11.20, 2.80, -0.55, 1.95, -0.65, 7.34, 9.12};
    float dst[BUFFER_SIZE_T] = {0.00};
    HmppResult result;
    int32_t i = 0;
    result = HMPPS_Threshold_LTInv_32f(src, dst, BUFFER_SIZE_T, 3.14);
    if(result != HMPP_STS_NO_ERR){
        return;
    }
    printf("ThresholdInv: result = %d.\ndst = ", result);
    for(;i < BUFFER_SIZE_T;i++){
        printf(" %.2f   ", dst[i]);
    }
}

Output:

ThresholdInv: result = 0.
dst = 0.13    0.31    0.10    0.30    0.19    0.25    0.18    0.14    0.32    0.11    0.10    0.12    -0.32    0.09    0.32    -0.32    0.32    -0.32    0.14    0.11