1 //------------------------------------------------------------------------------
2 // GB_qsort_1a: sort an 1-by-n list of integers
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 #include "GB_sort.h"
11 
12 // returns true if A [a] < B [b]
13 #define GB_lt(A,a,B,b)                  \
14     GB_lt_1 (A ## _0, a, B ## _0, b)
15 
16 // argument list for calling a function
17 #define GB_arg(A)                       \
18     A ## _0
19 
20 // argument list for calling a function, with offset
21 #define GB_arg_offset(A,x)              \
22     A ## _0 + (x)
23 
24 // argument list for defining a function
25 #define GB_args(A)                      \
26     int64_t *restrict A ## _0
27 
28 // each entry has a single key
29 #define GB_K 1
30 
31 // swap A [a] and A [b]
32 #define GB_swap(A,a,b)                                                        \
33 {                                                                             \
34     int64_t t0 = A ## _0 [a] ; A ## _0 [a] = A ## _0 [b] ; A ## _0 [b] = t0 ; \
35 }
36 
37 #define GB_partition GB_partition_1a
38 #define GB_quicksort GB_quicksort_1a
39 
40 #include "GB_qsort_template.c"
41 
42 GB_PUBLIC   // accessed by the MATLAB tests in GraphBLAS/Test only
GB_qsort_1a(int64_t * restrict A_0,const int64_t n)43 void GB_qsort_1a    // sort array A of size 1-by-n
44 (
45     int64_t *restrict A_0,      // size n array
46     const int64_t n
47 )
48 {
49     uint64_t seed = n ;
50     GB_quicksort (GB_arg (A), n, &seed) ;
51 }
52 
53