Threshold
Uses a constant to set the threshold for elements in a vector.
The interface contains the relOp parameter, which specifies the comparison operation type. The value of this parameter can be HMPP_CMP_LT (lower than) or HMPP_CMP_GT (greater than).
The formula is as follows:
- If src is a real number sequence and relOP = HMPP_CMP_LT, then:

- If src is a real number sequence and relOP = HMPP_CMP_GT, then:

- If src is a complex number sequence and relOP = HMPP_CMP_LT, then:

- If src is a complex number sequence and relOP = HMPP_CMP_GT, then:

The function interface is declared as follows:
- Operations on integers:
HmppResult HMPPS_Threshold_16s(const int16_t* src, int16_t* dst, int32_t len, int16_t level, HmppCmpOp relOp);
- Operations on floating-point numbers:
HmppResult HMPPS_Threshold_32f(const float* src, float* dst, int32_t len, float level, HmppCmpOp relOp);
HmppResult HMPPS_Threshold_64f(const double* src, double* dst, int32_t len, double level, HmppCmpOp relOp);
HmppResult HMPPS_Threshold_32fc(const Hmpp32fc* src, Hmpp32fc* dst, int32_t len, float level, HmppCmpOp relOp);
- In-place operations on integers:
HmppResult HMPPS_Threshold_16s_I(int16_t* srcDst, int32_t len, int16_t level, HmppCmpOp relOp);
- In-place operations on floating-point numbers:
HmppResult HMPPS_Threshold_32f_I(float* srcDst, int32_t len, float level, HmppCmpOp relOp);
HmppResult HMPPS_Threshold_64f_I(double* srcDst, int32_t len, double level, HmppCmpOp relOp);
HmppResult HMPPS_Threshold_32fc_I(Hmpp32fc* srcDst, int32_t len, float level, HmppCmpOp relOp);
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 |
relOp |
Operation mode |
HMPP_CMP_LT, HMPP_CMP_GT |
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_BAD_ARG_ERR |
The operation mode is incorrect. |
Example
#define BUFFER_SIZE_T 10
void ThresholdExample(void) {
float src[BUFFER_SIZE_T] = {-1.64, -1.63, -1.09, 0.71, 3.20,
-0.43, -0.41, 4.83, 5.36, 4.40};
float dst1[BUFFER_SIZE_T] = {0.00};
float dst2[BUFFER_SIZE_T] = {0.00};
HmppResult result;
result = HMPPS_Threshold_32f(src, dst1, BUFFER_SIZE_T, 3.14, HMPP_CMP_LT);
printf("Threshold1: result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst1 =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst1[i]);
}
result = HMPPS_Threshold_32f(src, dst2, BUFFER_SIZE_T, 3.14, HMPP_CMP_GT);
printf("\nThreshold2: result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst2 =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst2[i]);
}
printf("\n");
}
Output:
Threshold1: result = 0 dst1 = 3.14 3.14 3.14 3.14 3.20 3.14 3.14 4.83 5.36 4.40 Threshold2: result = 0 dst2 = -1.64 -1.63 -1.09 0.71 3.14 -0.43 -0.41 3.14 3.14 3.14