PandA-2024.02
sort.c
Go to the documentation of this file.
1 #include "sort.h"
2 
3 void merge(TYPE a[SIZE], int start, int m, int stop){
4  TYPE temp[SIZE];
5  int i, j, k;
6 
7  merge_label1 : for(i=start; i<=m; i++){
8  temp[i] = a[i];
9  }
10 
11  merge_label2 : for(j=m+1; j<=stop; j++){
12  temp[m+1+stop-j] = a[j];
13  }
14 
15  i = start;
16  j = stop;
17 
18  merge_label3 : for(k=start; k<=stop; k++){
19  TYPE tmp_j = temp[j];
20  TYPE tmp_i = temp[i];
21  if(tmp_j < tmp_i) {
22  a[k] = tmp_j;
23  j--;
24  } else {
25  a[k] = tmp_i;
26  i++;
27  }
28  }
29 }
30 
32  int start, stop;
33  int i, m, from, mid, to;
34 
35  start = 0;
36  stop = SIZE;
37 
38  mergesort_label1 : for(m=1; m<stop-start; m+=m) {
39  mergesort_label2 : for(i=start; i<stop; i+=m+m) {
40  from = i;
41  mid = i+m-1;
42  to = i+m+m-1;
43  if(to < stop){
44  merge(a, from, mid, to);
45  }
46  else{
47  merge(a, from, mid, stop);
48  }
49  }
50  }
51 }
#define TYPE
Definition: backprop.h:21
static const uint32_t k[]
Definition: sha-256.c:22
#define SIZE
Definition: adpcm.c:775
void merge(TYPE a[SIZE], int start, int m, int stop)
Definition: sort.c:3
void ms_mergesort(TYPE a[SIZE])
Definition: sort.c:31

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13