MinEvery
Obtains the minimum value of each pair of elements in two vectors.
The function interface declaration is as follows:
- Operations on floating-point numbers:
HmppResult HMPPS_MinEvery_32f(const float *src1, const float *src2, float *dst, int32_t len);
HmppResult HMPPS_MinEvery_64f(const double *src1, const double *src2, double *dst, int32_t len);
- In-place operations on integers:
HmppResult HMPPS_MinEvery_16s_I(const int16_t *src, int16_t *srcDst, int32_t len);
HmppResult HMPPS_MinEvery_32s_I(const int32_t *src, int32_t *srcDst, int32_t len);
- In-place operations on floating-point numbers:
HmppResult HMPPS_MinEvery_32f_I(const float *src, float *srcDst, int32_t len);
HmppResult HMPPS_MinEvery_64f_I(const double *src, double *srcDst, int32_t len);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src1 |
Pointer to the first source vector |
The value cannot be NULL. |
Input |
src2 |
Pointer to the second source vector |
The value cannot be NULL. |
Input |
dst |
Pointer to the destination vector |
The value cannot be NULL. |
Output |
src |
Pointer to the source vector for in-place operations |
The value cannot be NULL. |
Input |
srcDst |
Pointer to the destination vector for in-place operations |
The value cannot be NULL. |
Input/Output |
len |
Vector length |
(0, 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 src1, src2, dst, src, or srcDst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
Note
The len input parameter is of the unsigned type. If a negative value is transferred, len will be changed to a large value, causing an unknown error.
Example
#define BUFFER_SIZE_T 10
void MinEveryExample(void)
{
float src1[BUFFER_SIZE_T] = {3.25, 0.45, 2.23, -8.11, 3.10, 15.56, 26.53, -31.13, 1.44, 23.18};
float src2[BUFFER_SIZE_T] = {0.32, 0.56, -12.45, 45.67, 12.10, -2.11, -7.60, 6.78, 8.88, 1.24};
float dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
HmppResult result = HMPPS_MinEvery_32f(src1, src2, dst, BUFFER_SIZE_T);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("The min vector is:");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst[i]);
}
printf("\n");
}
Output:
result = 0 The min vector is: 0.32 0.45 -12.45 -8.11 3.10 -2.11 -7.60 -31.13 1.44 1.24