Rate This Document
Findability
Accuracy
Completeness
Readability

Sort

Sorts vectors in ascending or descending order.

The function interface declaration is as follows:
  • Sorting of integers in ascending order:

    HmppResult HMPPS_SortAscend_8u_I(uint8_t* srcDst, int32_t len);

    HmppResult HMPPS_SortAscend_16u_I(uint16_t* srcDst, int32_t len);

    HmppResult HMPPS_SortAscend_16s_I(int16_t* srcDst, int32_t len);

    HmppResult HMPPS_SortAscend_32s_I(int32_t* srcDst, int32_t len);

  • Sorting of floating-point numbers in ascending order:

    HmppResult HMPPS_SortAscend_32f_I(float* srcDst, int32_t len);

    HmppResult HMPPS_SortAscend_64f_I(double* srcDst, int32_t len);

  • Sorting of integers in descending order:

    HmppResult HMPPS_SortDescend_8u_I(uint8_t* srcDst, int32_t len);

    HmppResult HMPPS_SortDescend_16u_I(uint16_t* srcDst, int32_t len);

    HmppResult HMPPS_SortDescend_16s_I(int16_t* srcDst, int32_t len);

    HmppResult HMPPS_SortDescend_32s_I(int32_t* srcDst, int32_t len);

  • Sorting of floating-point numbers in descending order:

    HmppResult HMPPS_SortDescend_32f_I(float* srcDst, int32_t len);

    HmppResult HMPPS_SortDescend_64f_I(double* srcDst, int32_t len);

Parameters

Parameter

Description

Value Range

Input/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

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 srcDst is NULL.

HMPP_STS_SIZE_ERR

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

Example

#define BUFFER_SIZE_T 9
void Sort_Example() {
    uint8_t src[BUFFER_SIZE_T] = {255, 0, 254, 0, 253, 1, 252, 2, 251};
    int32_t i;
    HmppResult result = HMPPS_SortAscend_8u_I(src, BUFFER_SIZE_T);
    if (result == HMPP_STS_NO_ERR) {
        printf("result = %d\n", result);
        printf("dst = ");
        for (i = 0; i < BUFFER_SIZE_T; i++) {
            printf("%d ", src[i]);
        }
        printf("\n");
    }
}

Output:

result = 0
dst = 0 0 1 2 251 252 253 254 255