MCPcopy Create free account
hub / github.com/audeering/opensmile / MyQuickSortAscending

Function MyQuickSortAscending

src/newmat/sort.cpp:157–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155 }
156}
157static void MyQuickSortAscending(Real* first, Real* last, int depth)
158{
159 REPORT
160 for (;;)
161 {
162 const int length = last - first + 1;
163 if (length < DoSimpleSort) { REPORT return; }
164 if (depth++ > MaxDepth)
165 Throw(ConvergenceException("QuickSortAscending fails: "));
166 Real* centre = first + length/2;
167 const Real test = SortThreeDescending(last, centre, first);
168 Real* f = first; Real* l = last;
169 for (;;)
170 {
171 while (*(++f) < test) {}
172 while (*(--l) > test) {}
173 if (l <= f) break;
174 const Real temp = *f; *f = *l; *l = temp;
175 }
176 if (f > centre)
177 { REPORT MyQuickSortAscending(l+1, last, depth); last = f-1; }
178 else { REPORT MyQuickSortAscending(first, f-1, depth); first = l+1; }
179 }
180}
181
182//********* sort diagonal matrix & rearrange matrix columns ****************
183

Callers 1

SortAscendingFunction · 0.85

Calls 3

SortThreeDescendingFunction · 0.85
ThrowFunction · 0.70

Tested by

no test coverage detected