blob: 149744acbdf0cd7cac754c77d0976b8f45a8171a (
plain)
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
|
// See LICENSE for license details.
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#define USE_N_SQUARED_SORT
#define FAKE_MALLOC_INIT(words, name) \
uint32_t heap_##name[words]; \
const size_t max_alloc_##name = (words) * sizeof(uint32_t); \
size_t cur_pos_##name; \
void* fake_malloc_##name( size_t size ) \
{ \
static bool init = false; \
if(!init) { \
cur_pos_##name = 0; \
init = true; \
} \
if(cur_pos_##name < (words)) { \
void *ptr = (void*) &heap_##name[cur_pos_##name]; \
cur_pos_##name += size & ~((uint32_t)3) + 1; \
return ptr; \
} else { \
return NULL; \
} \
}
#ifndef _TAV_SORT_H_
#define _TAV_SORT_H_
int
n_squared_sort (float * value, int * index, int len);
int
radix_sort_tuples (int * value, int * index, int len, int radix_bits);
int
insertion_sort (float * value, int * index, int len);
int
quicksort (float * array, int * index, int len);
/* This defines the length at quicksort switches to insertion sort */
#ifndef MAX_THRESH
#define MAX_THRESH 10
#endif
#ifndef RADIX_BITS
#define RADIX_BITS (8)
#endif
#endif /* _TAV_SORT_H_ */
|