Indirectly sorts all elements of a vector using radix sorting algorithm.
IppStatus ippsSortRadixIndexAscend_8u(const Ipp32f* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexAscend_16u(const Ipp16u* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexAscend_16s(const Ipp16s* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexAscend_32s(const Ipp32s* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexAscend_32u(const Ipp32u* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexAscend_32f(const Ipp32f* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexDescend_8u(const Ipp32f* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexDescend_16u(const Ipp16u* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexDescend_16s(const Ipp16s* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexDescend_32s(const Ipp32s* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexDescend_32u(const Ipp32u* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
IppStatus ippsSortRadixIndexDescend_32f(const Ipp32f* const pSrc, Ipp32s srcStrideBytes, Ipp32s* pDstIndx, Ipp32s* pTmpIndx, Ipp32s len);
pSrc |
Pointer the source sparse keys vector. |
srcStrideBytes |
Distance in bytes between two consecutive elements of the source vector. |
pDstIndx |
Pointer to the destination vector of indexes. |
pTmpIndx |
Pointer to the temporary vector of indexes. |
len |
Number of elements in the vectors. |
The functions ippsSortRadixIndexAscend and ippsSortRadixIndexDescend are declared in the ipps.h file. These functions indirectly sort all elements of the source sparse keys vector pSrc in the ascending or descending order, respectively, using "radix sort" algorithm and store the indexes of resulting arrangement order in the destination vector pDstIndx. Elements of the source vector are not rearranged.
Temporary vector pTmpIndx is required by the algorithm, its size must be equal to the size of the destination vector and be sufficient to contain len number of indexes. Intervals between the elements of the source sparse vector pSrc in memory must be equal to the value of srcStrideBytes, minimum value of which is equal to the size of the datatype of the key value. The sorting algorithm does not change the relative order of the elements with equal keys.
The example below shows how to call the functionsippsSortRadixindexAscend_8u_I and ippsSortRadixindexDescend_8u_I.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when the pSrc or pTmpIndx is NULL. |
ippStsSizeErr |
Indicates an error when len is less than or equal to 0, or srcStrideBytes is less than sizeof(key type). |
void testsort(void) {
struct C {
Ipp8u key1;
Ipp8u key2;
float data;
} c_array[4] = {{0,2,1.0f}, {1,3,2.0f}, {1,4,3.0f}, {8,2,10.0f}};
int idx1[4], idx2[4], tmp[4], i;
ippsSortRadixIndexDescend_8u(&c_array[0].key1, sizeof(C), idx1, tmp, 4);
ippsSortRadixIndexAscend_8u(&c_array[0].key2, sizeof(C), idx2, tmp, 4);
printf("%f, %f, %f, %f\n",c_array[idx1[0]].data, c_array[idx1[1]].data, c_array[idx1[2]].data, c_array[idx1[3]].data );
printf("%f, %f, %f, %f\n",c_array[idx2[0]].data, c_array[idx2[1]].data, c_array[idx2[2]].data, c_array[idx2[3]].data );
}
Result
10.0 2.0 3.0 1.0
1.0 10.0 2.0 3.0
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.