ThresholdAbsVal
Uses a constant to set the threshold for the absolute values of elements in a vector. Different from the ThresholdAbs interface, the vector element that is not within the threshold range is set to the specified value.
The function interface declaration is as follows:
- Operations on integers:
HmppResult HMPPS_Threshold_LTAbsVal_16s(const int16_t* src, int16_t* dst, int32_t len, int16_t level, int16_t value);
HmppResult HMPPS_Threshold_LTAbsVal_32s(const int32_t* src, int32_t* dst, int32_t len, int32_t level, int32_t value);
- Operations on floating-point numbers:
HmppResult HMPPS_Threshold_LTAbsVal_32f(const float* src, float* dst, int32_t len, float level, float value);
HmppResult HMPPS_Threshold_LTAbsVal_64f(const double* src, double* dst, int32_t len, double level, double value);
- In-place operations on integers:
HmppResult HMPPS_Threshold_LTAbsVal_16s_I(int16_t* srcDst, int32_t len, int16_t level, int16_t value);
HmppResult HMPPS_Threshold_LTAbsVal_32s_I(int32_t* srcDst, int32_t len, int32_t level, int32_t value);
- In-place operations on floating-point numbers:
HmppResult HMPPS_Threshold_LTAbsVal_32f_I(float* srcDst, int32_t len, float level, float value);
HmppResult HMPPS_Threshold_LTAbsVal_64f_I(double* srcDst, int32_t len, double level, double value);
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 |
Not limited, depending on the type |
Input |
value |
Specified constant |
Not limited, depending on the type |
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_T 20
void ThresholdAbsValExample(void)
{
float src[BUFFER_SIZE_T] = {11.44, -0.07, 10.23, 8.78, -0.30, 1.72, -1.37, 3.39, 7.37, 7.40,
8.36, -1.56, 6.65, 0.04, 6.56, 8.60, 0.84, 4.96, 5.13, 2.56};
float dst[BUFFER_SIZE_T] = {0.00};
HmppResult result;
int32_t i = 0;
result = HMPPS_Threshold_LTAbsVal_32f(src, dst, BUFFER_SIZE_T, 3.14, 8.51);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("ThresholdAbsVal: result = %d.\ndst = ", result);
for (; i < BUFFER_SIZE_T; i++) {
printf(" %.2f ", dst[i]);
}
}
Output:
ThresholdAbsVal: result = 0. dst = 11.44 8.51 10.23 8.78 8.51 8.51 8.51 3.39 7.37 7.40 8.36 8.51 6.65 8.51 6.56 8.60 8.51 4.96 5.13 8.51