diff --git a/src/COREMOD_tools/quicksort.c b/src/COREMOD_tools/quicksort.c index cea35d27..c2c132aa 100644 --- a/src/COREMOD_tools/quicksort.c +++ b/src/COREMOD_tools/quicksort.c @@ -216,6 +216,67 @@ void qs_ushort( } } + + + +void qs2( + double * __restrict array, + double * __restrict array1, + unsigned long left, + unsigned long right +) +{ + register unsigned long i, j; + double x, y; + double y1; + + i = left; + j = right; + x = array[(left + right) / 2]; + + do + { + while(array[i] < x && i < right) + { + i++; + } + while(x < array[j] && j > left && j > 0) + { + j--; + } + + if(i <= j) + { + y = array[i]; + array[i] = array[j]; + array[j] = y; + + y1 = array1[i]; + array1[i] = array1[j]; + array1[j] = y1; + + i++; + + if(j > 0) + { + j--; + } + } + } + while(i <= j); + + if(left < j) + { + qs2(array, array1, left, j); + } + if(i < right) + { + qs2(array, array1, i, right); + } +} + + + void qs3( double * __restrict array, double * __restrict array1, @@ -277,6 +338,12 @@ void qs3( } } + + + + + + void qs3_float( float * __restrict array, float * __restrict array1, @@ -681,6 +748,7 @@ void qs3ll_double( } } + void qs3ulul_double( double * __restrict array, unsigned long * __restrict array1, @@ -778,6 +846,15 @@ void quick_sort_ushort( qs_ushort(array, 0, count - 1); } +void quick_sort2( + double * __restrict array, + double * __restrict array1, + unsigned long count +) +{ + qs2(array, array1, 0, count - 1); +} + void quick_sort3( double * __restrict array, diff --git a/src/COREMOD_tools/quicksort.h b/src/COREMOD_tools/quicksort.h index 339d5f7d..fc3407ca 100644 --- a/src/COREMOD_tools/quicksort.h +++ b/src/COREMOD_tools/quicksort.h @@ -51,6 +51,14 @@ void quick_sort_ushort( unsigned long count ); +void qs2( + double * __restrict array, + double * __restrict array1, + unsigned long left, + unsigned long right +); + + void qs3( double * __restrict array, double * __restrict array1, @@ -67,6 +75,12 @@ void qs3_double( unsigned long right ); +void quick_sort2( + double * __restrict array, + double * __restrict array1, + unsigned long count +); + void quick_sort3( double * __restrict array, double * __restrict array1,