1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//------------------------------------------------------------------------------
// LG_qsort_template: quicksort of a K-by-n array
//------------------------------------------------------------------------------
// LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
// SPDX-License-Identifier: BSD-2-Clause
//
// For additional details (including references to third party source code and
// other files) see the LICENSE file or contact permission@sei.cmu.edu. See
// Contributors.txt for a full list of contributors. Created, in part, with
// funding and support from the U.S. Government (see Acknowledgments.txt file).
// DM22-0790
// Contributed by Timothy A. Davis, Texas A&M University
//------------------------------------------------------------------------------
// This file is #include'd in LG_qsort*.c to create specific versions for
// different kinds of sort keys and auxiliary arrays. Requires an inline or
// macro definition of the LG_lt function. The LG_lt function has the form
// LG_lt (A,i,B,j) and returns true if A[i] < B[j].
// All of these functions are static; there will be versions of them in each
// variant of LG_qsort*, and given unique names via #define's in the
// #include'ing file.
//------------------------------------------------------------------------------
// LG_partition: use a pivot to partition an array
//------------------------------------------------------------------------------
// C.A.R Hoare partition method, partitions an array in-place via a pivot.
// k = partition (A, n) partitions A [0:n-1] such that all entries in
// A [0:k] are <= all entries in A [k+1:n-1].
static inline int64_t
//------------------------------------------------------------------------------
// LG_quicksort: recursive single-threaded quicksort
//------------------------------------------------------------------------------
static void LG_quicksort // sort A [0:n-1]