diff --git a/Source/SupportFunctions/arm_quick_sort_f32.c b/Source/SupportFunctions/arm_quick_sort_f32.c index 04290f7e..7c2fa240 100644 --- a/Source/SupportFunctions/arm_quick_sort_f32.c +++ b/Source/SupportFunctions/arm_quick_sort_f32.c @@ -29,84 +29,92 @@ #include "arm_math.h" #include "arm_sorting.h" - - -static void arm_quick_sort_core_f32(float32_t *pSrc, uint32_t first, uint32_t last, uint8_t dir) +static uint32_t arm_quick_sort_partition_f32(float32_t *pSrc, int32_t first, int32_t last, uint8_t dir) { - uint32_t i, j, pivot; + /* This function will be called */ + int32_t i, j, pivot_index; + float32_t pivot; float32_t temp; - if(dir) + /* The first element is the pivot */ + pivot_index = first; + pivot = pSrc[pivot_index]; + + /* Initialize indices for do-while loops */ + i = first - 1; + j = last + 1; + + while(i < j) { - if(firstpSrc[pivot]) - j--; // Move to the left - - if(i j - temp=pSrc[i]; - pSrc[i]=pSrc[j]; - pSrc[j]=temp; - } - } - - // Swap pivot <-> j - temp=pSrc[pivot]; - pSrc[pivot]=pSrc[j]; - pSrc[j]=temp; - - arm_quick_sort_core_f32(pSrc, first, j-1, dir); - arm_quick_sort_core_f32(pSrc, j+1, last, dir); + i++; + } while (pSrc[i] < pivot && i pivot); } - } - else - { - if(first pivot && i=pSrc[pivot] && i Swap */ + temp=pSrc[i]; + pSrc[i]=pSrc[j]; pSrc[j]=temp; - - arm_quick_sort_core_f32(pSrc, first, j-1, dir); - arm_quick_sort_core_f32(pSrc, j+1, last, dir); } } + return j; +} + +static void arm_quick_sort_core_f32(float32_t *pSrc, int32_t first, int32_t last, uint8_t dir) +{ + /* If the array [first ... last] has more than one element */ + if(firstdir); + /* The previous function could be called recursively a maximum + * of (blockSize-1) times, generating a stack consumption of 4*(blockSize-1) bytes. */ } /** diff --git a/Testing/desc.txt b/Testing/desc.txt index 35af5b64..2429e977 100644 --- a/Testing/desc.txt +++ b/Testing/desc.txt @@ -325,9 +325,9 @@ group Root { test_insertion_sort_f32 nb=16 const:test_insertion_sort_const_f32 test_merge_sort_f32 nb=11 outofplace:test_merge_sort_out_f32 test_merge_sort_f32 nb=16 const:test_merge_sort_const_f32 - disabled{test_quick_sort_f32 nb=11 outofplace:test_quick_sort_out_f32} - disabled{test_quick_sort_f32 nb=11 inplace:test_quick_sort_in_f32} - disabled{test_quick_sort_f32 nb=16 const:test_quick_sort_const_f32} + test_quick_sort_f32 nb=11 outofplace:test_quick_sort_out_f32 + test_quick_sort_f32 nb=11 inplace:test_quick_sort_in_f32 + test_quick_sort_f32 nb=16 const:test_quick_sort_const_f32 test_selection_sort_f32 nb=11 outofplace:test_selection_sort_out_f32 test_selection_sort_f32 nb=11 inplace:test_selection_sort_in_f32 test_selection_sort_f32 nb=16 const:test_selection_sort_const_f32