Rate This Document
Findability
Accuracy
Completeness
Readability

MinIndx

Obtains the minimum value and its index in a vector.

The function interface declaration is as follows:

  • Operations on integers:

    HmppResult HMPPS_MinIndx_16s(const int16_t *src, int32_t len, int16_t *min, int32_t *indx);

    HmppResult HMPPS_MinIndx_32s(const int32_t *src, int32_t len, int32_t *min, int32_t *indx);

  • Operations on floating-point numbers:

    HmppResult HMPPS_MinIndx_32f(const float *src, int32_t len, float *min, int32_t *indx);

    HmppResult HMPPS_MinIndx_64f(const double *src, int32_t len, double *min, int32_t *indx);

Parameters

Parameter

Description

Value Range

Input/Output

src

Source vector

The value cannot be NULL.

Input

len

Vector length

(0, INT_MAX]

Input

min

Minimum value of a vector element

The value cannot be NULL.

Output

indx

Index of the minimum element in the vector

The value cannot be NULL.

Output

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, min, or indx is NULL.

HMPP_STS_SIZE_ERR

The value of len is less than or equal to 0.

Example

#define BUFFER_SIZE_T 10

void MinIndxExample(void)
{
    int16_t src[BUFFER_SIZE_T] = {3, 0, 2, -8, 3, 15, 26, -31, 1, 23};
    int16_t min;
    int32_t minIndex;

    HmppResult result = HMPPS_MinIndx_16s(src, BUFFER_SIZE_T, &min, &minIndex);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("min = %d, index of min is %d\n", min, minIndex);
}

Output:

result = 0
min = -31, index of min is 7