MetricKnn API
Fast Similarity Search using the Metric Space Approach
Main Page
Classes
Files
Examples
File List
File Members
src
metricknn
metricknn_c
impl
macros_util.h
1
/*
2
* Copyright (C) 2012-2015, Juan Manuel Barrios <juanmanuel@barrios.cl>
3
* All rights reserved.
4
*
5
* This file is part of MetricKnn.
6
* MetricKnn is made available under the terms of the BSD 2-Clause License.
7
*/
8
9
#ifndef MACROS_UTIL_H_
10
#define MACROS_UTIL_H_
11
12
/******************/
13
14
#define INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, constantDatatype, typeVector) \
15
} else if (varDatatype.mknn_datatype_code == constantDatatype.mknn_datatype_code) { \
16
varAssign = namePrefix##typeVector; \
17
18
#define ASSIGN_SINGLE_DATATYPE(varAssign, varDatatype, namePrefix) \
19
if(false) { \
20
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_8bits, int8_t) \
21
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_16bits, int16_t) \
22
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_32bits, int32_t) \
23
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_64bits, int64_t) \
24
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_8bits, uint8_t) \
25
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_16bits, uint16_t) \
26
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_32bits, uint32_t) \
27
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_64bits, uint64_t) \
28
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_FLOATING_POINT_32bits, float) \
29
INTERNAL_TEST_SINGLE_ASSIGN(varAssign, varDatatype, namePrefix, MKNN_DATATYPE_FLOATING_POINT_64bits, double) \
30
} else \
31
my_log_error("unknown mknn_datatype code %i\n", varDatatype.mknn_datatype_code);
32
33
/******************/
34
35
#define INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, constantDatatype2, typeVector2) \
36
} else if (varDatatype1.mknn_datatype_code == constantDatatype1.mknn_datatype_code && varDatatype2.mknn_datatype_code == constantDatatype2.mknn_datatype_code) { \
37
varAssign = namePrefix##typeVector1##_##typeVector2; \
38
39
#define INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1) \
40
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_SIGNED_INTEGER_8bits, int8_t) \
41
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_SIGNED_INTEGER_16bits, int16_t) \
42
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_SIGNED_INTEGER_32bits, int32_t) \
43
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_SIGNED_INTEGER_64bits, int64_t) \
44
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_UNSIGNED_INTEGER_8bits, uint8_t) \
45
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_UNSIGNED_INTEGER_16bits, uint16_t) \
46
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_UNSIGNED_INTEGER_32bits, uint32_t) \
47
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_UNSIGNED_INTEGER_64bits, uint64_t) \
48
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_FLOATING_POINT_32bits, float) \
49
INTERNAL_TEST_DOUBLE_ASSIGN(varAssign, varDatatype1, varDatatype2, namePrefix, constantDatatype1, typeVector1, MKNN_DATATYPE_FLOATING_POINT_64bits, double)
50
51
#define ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix) \
52
if(false) { \
53
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_8bits, int8_t) \
54
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_16bits, int16_t) \
55
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_32bits, int32_t) \
56
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_SIGNED_INTEGER_64bits, int64_t) \
57
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_8bits, uint8_t) \
58
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_16bits, uint16_t) \
59
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_32bits, uint32_t) \
60
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_UNSIGNED_INTEGER_64bits, uint64_t) \
61
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_FLOATING_POINT_32bits, float) \
62
INTERNAL_ASSIGN_DOUBLE_DATATYPE(varAssign, varDatatype1, varDatatype2, namePrefix, MKNN_DATATYPE_FLOATING_POINT_64bits, double) \
63
} else \
64
my_log_error("unknown mknn_datatypes codes %i %i\n", varDatatype1.mknn_datatype_code, varDatatype2.mknn_datatype_code);
65
66
67
/******************/
68
#define GENERATE_SINGLE_DATATYPE(VAR_NAME) \
69
VAR_NAME(int8_t) \
70
VAR_NAME(int16_t) \
71
VAR_NAME(int32_t) \
72
VAR_NAME(int64_t) \
73
VAR_NAME(uint8_t) \
74
VAR_NAME(uint16_t) \
75
VAR_NAME(uint32_t) \
76
VAR_NAME(uint64_t) \
77
VAR_NAME(float) \
78
VAR_NAME(double)
79
80
/******************/
81
82
#define INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, type1) \
83
VAR_NAME(type1, int8_t) \
84
VAR_NAME(type1, uint8_t) \
85
VAR_NAME(type1, int16_t) \
86
VAR_NAME(type1, uint16_t) \
87
VAR_NAME(type1, int32_t) \
88
VAR_NAME(type1, uint32_t) \
89
VAR_NAME(type1, int64_t) \
90
VAR_NAME(type1, uint64_t) \
91
VAR_NAME(type1, float) \
92
VAR_NAME(type1, double)
93
94
#define GENERATE_DOUBLE_DATATYPE(VAR_NAME) \
95
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, int8_t) \
96
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, uint8_t) \
97
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, int16_t) \
98
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, uint16_t) \
99
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, int32_t) \
100
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, uint32_t) \
101
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, int64_t) \
102
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, uint64_t) \
103
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, float) \
104
INTERNAL_GENERATE_DOUBLE_DATATYPE(VAR_NAME, double)
105
106
/* **************** */
107
108
#define INTERNAL_FLOAT_WITH_DIFF_ABS(VAR_NAME, varFloat) \
109
VAR_NAME(varFloat , int8_t , float , fabsf) \
110
VAR_NAME(varFloat , uint8_t , float , fabsf) \
111
VAR_NAME(varFloat , int16_t , double , fabs ) \
112
VAR_NAME(varFloat , uint16_t , double , fabs ) \
113
VAR_NAME(varFloat , int32_t , double , fabs ) \
114
VAR_NAME(varFloat , uint32_t , double , fabs ) \
115
VAR_NAME(varFloat , int64_t , double , fabs ) \
116
VAR_NAME(varFloat , uint64_t , double , fabs ) \
117
VAR_NAME(varFloat , float , float , fabsf) \
118
VAR_NAME(varFloat , double , double , fabs )
119
120
#define INTERNAL_DOUBLE_WITH_DIFF_ABS(VAR_NAME, varDouble) \
121
VAR_NAME(varDouble, int8_t , double , fabs ) \
122
VAR_NAME(varDouble, uint8_t , double , fabs ) \
123
VAR_NAME(varDouble, int16_t , double , fabs ) \
124
VAR_NAME(varDouble, uint16_t , double , fabs ) \
125
VAR_NAME(varDouble, int32_t , double , fabs ) \
126
VAR_NAME(varDouble, uint32_t , double , fabs ) \
127
VAR_NAME(varDouble, int64_t , double , fabs ) \
128
VAR_NAME(varDouble, uint64_t , double , fabs ) \
129
VAR_NAME(varDouble, float , double , fabs ) \
130
VAR_NAME(varDouble, double , double , fabs )
131
132
#define INTERNAL_INT3264_WITH_DIFF_ABS(VAR_NAME, varInt) \
133
VAR_NAME(varInt , int8_t , int64_t , llabs) \
134
VAR_NAME(varInt , uint8_t , int64_t , llabs) \
135
VAR_NAME(varInt , int16_t , int64_t , llabs) \
136
VAR_NAME(varInt , uint16_t , int64_t , llabs) \
137
VAR_NAME(varInt , int32_t , int64_t , llabs) \
138
VAR_NAME(varInt , uint32_t , int64_t , llabs) \
139
VAR_NAME(varInt , int64_t , int64_t , llabs) \
140
VAR_NAME(varInt , uint64_t , int64_t , llabs) \
141
VAR_NAME(varInt , float , double , fabs ) \
142
VAR_NAME(varInt , double , double , fabs )
143
144
#define INTERNAL_INT16_WITH_DIFF_ABS(VAR_NAME, varInt16) \
145
VAR_NAME(varInt16 , int8_t , int32_t , labs ) \
146
VAR_NAME(varInt16 , uint8_t , int32_t , labs ) \
147
VAR_NAME(varInt16 , int16_t , int32_t , labs ) \
148
VAR_NAME(varInt16 , uint16_t , int32_t , labs ) \
149
VAR_NAME(varInt16 , int32_t , int64_t , llabs) \
150
VAR_NAME(varInt16 , uint32_t , int64_t , llabs) \
151
VAR_NAME(varInt16 , int64_t , int64_t , llabs) \
152
VAR_NAME(varInt16 , uint64_t , int64_t , llabs) \
153
VAR_NAME(varInt16 , float , double , fabs ) \
154
VAR_NAME(varInt16 , double , double , fabs )
155
156
#define INTERNAL_INT8_WITH_DIFF_ABS(VAR_NAME, varInt8) \
157
VAR_NAME(varInt8 , int8_t , int32_t , abs ) \
158
VAR_NAME(varInt8 , uint8_t , int32_t , abs ) \
159
VAR_NAME(varInt8 , int16_t , int32_t , labs ) \
160
VAR_NAME(varInt8 , uint16_t , int32_t , labs ) \
161
VAR_NAME(varInt8 , int32_t , int64_t , llabs) \
162
VAR_NAME(varInt8 , uint32_t , int64_t , llabs) \
163
VAR_NAME(varInt8 , int64_t , int64_t , llabs) \
164
VAR_NAME(varInt8 , uint64_t , int64_t , llabs) \
165
VAR_NAME(varInt8 , float , double , fabs ) \
166
VAR_NAME(varInt8 , double , double , fabs )
167
168
#define GENERATE_DOUBLE_DATATYPE_WITH_DIFF_ABS(VAR_NAME) \
169
INTERNAL_INT8_WITH_DIFF_ABS(VAR_NAME, int8_t) \
170
INTERNAL_INT8_WITH_DIFF_ABS(VAR_NAME, uint8_t) \
171
INTERNAL_INT16_WITH_DIFF_ABS(VAR_NAME, int16_t) \
172
INTERNAL_INT16_WITH_DIFF_ABS(VAR_NAME, uint16_t) \
173
INTERNAL_INT3264_WITH_DIFF_ABS(VAR_NAME, int32_t) \
174
INTERNAL_INT3264_WITH_DIFF_ABS(VAR_NAME, uint32_t) \
175
INTERNAL_INT3264_WITH_DIFF_ABS(VAR_NAME, int64_t) \
176
INTERNAL_INT3264_WITH_DIFF_ABS(VAR_NAME, uint64_t) \
177
INTERNAL_FLOAT_WITH_DIFF_ABS(VAR_NAME, float) \
178
INTERNAL_DOUBLE_WITH_DIFF_ABS(VAR_NAME, double)
179
180
#endif
Generated on Fri Aug 28 2015 09:43:33 for MetricKnn API by
1.8.9.1
Powered by