bufferkdtree (C sources)
C source code for the Python bufferkdtree implementation
 All Classes Files Functions Variables Typedefs Macros
util.h
Go to the documentation of this file.
1 /*
2  * util.h
3  *
4  * Copyright (C) 2013-2016 Fabian Gieseke <fabian.gieseke@di.ku.dk>
5  * 1976 Niklaus Wirth
6  * License: GPL v2
7  *
8  */
9 #ifndef INCLUDE_UTIL_H_
10 #define INCLUDE_UTIL_H_
11 
12 #include "float.h"
13 
14 #include <stdlib.h>
15 #include <assert.h>
16 #include <float.h>
17 #include <math.h>
18 #include <stdio.h>
19 #include <time.h>
20 #include <sys/resource.h>
21 #include <sys/time.h>
22 #include <pthread.h>
23 #include <sched.h>
24 #include <errno.h>
25 #include <string.h>
26 #include <ctype.h>
27 
37 void transpose_array_float(float* array,
38  int n,
39  int d,
40  float* array_transposed);
41 
51 void transpose_array_double(double* array,
52  int n,
53  int d,
54  double* array_transposed);
55 
65 void transpose_array_int(int* array,
66  int n,
67  int d,
68  int* array_transposed);
69 
76 int compare_floats(const void *p1,
77  const void *p2);
78 
86 int compare_ints(const void *p1,
87  const void *p2);
88 
90 
91 #define ELEM_SWAP(a,b) { register elem_type t=(a);(a)=(b);(b)=t; }
92 #define median(a,n) kth_smallest(a,n,((n)/2))
93 
94 /*---------------------------------------------------------------------------
95  Function : kth_smallest()
96  In : array of elements, # of elements in the array, rank k
97  Out : one element
98  Job : find the kth smallest element in the array
99  Notice : use the median() macro defined below to get the median.
100 
101  Reference:
102 
103  Author: Wirth, Niklaus
104  Title: Algorithms + data structures = programs
105  Publisher: Englewood Cliffs: Prentice-Hall, 1976
106  Physical description: 366 p.
107  Series: Prentice-Hall Series in Automatic Computation
108 
109  ---------------------------------------------------------------------------*/
110 elem_type kth_smallest(elem_type a[], int n, int k);
111 
120  int n,
121  int k);
122 
123 #endif /* INCLUDE_UTIL_H_ */
int compare_ints(const void *p1, const void *p2)
Definition: util.c:114
void transpose_array_double(double *array, int n, int d, double *array_transposed)
Definition: util.c:50
void transpose_array_int(int *array, int n, int d, int *array_transposed)
Definition: util.c:71
elem_type kth_smallest(elem_type a[], int n, int k)
Definition: util.c:146
int compare_floats(const void *p1, const void *p2)
Definition: util.c:90
void transpose_array_float(float *array, int n, int d, float *array_transposed)
Definition: util.c:29
int kth_smallest_idx(elem_type a[], int n, int k)
Definition: util.c:159
FLOAT_TYPE elem_type
Definition: util.h:89
#define FLOAT_TYPE
Definition: float.h:17