forked from nmslib/nmslib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_spaces.h
158 lines (136 loc) · 8.04 KB
/
init_spaces.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* Non-metric Space Library
*
* Main developers: Bilegsaikhan Naidan, Leonid Boytsov, Yury Malkov, Ben Frederickson, David Novak
*
* For the complete list of contributors and further details see:
* https://github.com/searchivarius/NonMetricSpaceLib
*
* Copyright (c) 2013-2018
*
* This code is released under the
* Apache License Version 2.0 http://www.apache.org/licenses/.
*
*/
#ifndef INIT_SPACES_H
#define INIT_SPACES_H
#include "spacefactory.h"
#include "factory/space/space_edist.h"
#include "factory/space/space_bit_hamming.h"
#include "factory/space/space_bit_jaccard.h"
#include "factory/space/space_bregman.h"
#include "factory/space/space_dummy.h"
#include "factory/space/space_js.h"
#include "factory/space/space_lp.h"
#include "factory/space/space_scalar.h"
#include "factory/space/space_sparse_lp.h"
#include "factory/space/space_sparse_scalar.h"
#include "factory/space/space_word_embed.h"
#include "factory/space/space_ab_diverg.h"
#include "factory/space/space_renyi_diverg.h"
#include "factory/space/space_sparse_jaccard.h"
#if defined(WITH_EXTRAS)
#include "factory/space/space_sqfd.h"
#endif
namespace similarity {
inline void initSpaces() {
// Registering a dummy space
REGISTER_SPACE_CREATOR(int, SPACE_DUMMY, CreateDummy)
REGISTER_SPACE_CREATOR(float, SPACE_DUMMY, CreateDummy)
REGISTER_SPACE_CREATOR(double, SPACE_DUMMY, CreateDummy)
// Registering binary/bit Hamming/Jaccard
SpaceFactoryRegistry<int>::CreateFuncPtr bit_hamming_func_ptr = CreateBitHamming<int,uint32_t>;
REGISTER_SPACE_CREATOR(int, SPACE_BIT_HAMMING, bit_hamming_func_ptr )
SpaceFactoryRegistry<float>::CreateFuncPtr bit_jaccard_func_ptr = CreateBitJaccard<float,uint32_t>;
REGISTER_SPACE_CREATOR(float, SPACE_BIT_JACCARD, bit_jaccard_func_ptr )
// Registering the Levensthein-distance: regular and normalized
REGISTER_SPACE_CREATOR(int, SPACE_LEVENSHTEIN, CreateLevenshtein)
REGISTER_SPACE_CREATOR(float, SPACE_LEVENSHTEIN_NORM, CreateLevenshteinNormalized)
// Registering Bregman divergences
REGISTER_SPACE_CREATOR(float, SPACE_KLDIV_FAST, CreateKLDivFast)
REGISTER_SPACE_CREATOR(double, SPACE_KLDIV_FAST, CreateKLDivFast)
REGISTER_SPACE_CREATOR(float, SPACE_KLDIV_FAST_RIGHT_QUERY, CreateKLDivFastRightQuery)
REGISTER_SPACE_CREATOR(double, SPACE_KLDIV_FAST_RIGHT_QUERY, CreateKLDivFastRightQuery)
REGISTER_SPACE_CREATOR(float, SPACE_KLDIVGEN_FAST, CreateKLDivGenFast)
REGISTER_SPACE_CREATOR(double, SPACE_KLDIVGEN_FAST, CreateKLDivGenFast)
REGISTER_SPACE_CREATOR(float, SPACE_KLDIVGEN_SLOW, CreateKLDivGenSlow)
REGISTER_SPACE_CREATOR(double, SPACE_KLDIVGEN_SLOW, CreateKLDivGenSlow)
REGISTER_SPACE_CREATOR(float, SPACE_KLDIVGEN_FAST_RIGHT_QUERY, CreateKLDivGenFastRightQuery)
REGISTER_SPACE_CREATOR(double, SPACE_KLDIVGEN_FAST_RIGHT_QUERY, CreateKLDivGenFastRightQuery)
REGISTER_SPACE_CREATOR(float, SPACE_ITAKURASAITO_FAST, CreateItakuraSaitoFast)
REGISTER_SPACE_CREATOR(double, SPACE_ITAKURASAITO_FAST, CreateItakuraSaitoFast)
// Jensen-Shannon functions and their derivatives
REGISTER_SPACE_CREATOR(float, SPACE_JS_DIV_SLOW, CreateJSDivSlow)
REGISTER_SPACE_CREATOR(double, SPACE_JS_DIV_SLOW, CreateJSDivSlow)
REGISTER_SPACE_CREATOR(float, SPACE_JS_DIV_FAST, CreateJSDivFastPrecomp)
REGISTER_SPACE_CREATOR(double, SPACE_JS_DIV_FAST, CreateJSDivFastPrecomp)
REGISTER_SPACE_CREATOR(float, SPACE_JS_DIV_FAST_APPROX, CreateJSDivFastPrecompApprox)
REGISTER_SPACE_CREATOR(double, SPACE_JS_DIV_FAST_APPROX, CreateJSDivFastPrecompApprox)
REGISTER_SPACE_CREATOR(float, SPACE_JS_METR_SLOW, CreateJSMetricSlow)
REGISTER_SPACE_CREATOR(double, SPACE_JS_METR_SLOW, CreateJSMetricSlow)
REGISTER_SPACE_CREATOR(float, SPACE_JS_METR_FAST, CreateJSMetricFastPrecomp)
REGISTER_SPACE_CREATOR(double, SPACE_JS_METR_FAST, CreateJSMetricFastPrecomp)
REGISTER_SPACE_CREATOR(float, SPACE_JS_METR_FAST_APPROX, CreateJSMetricFastPrecompApprox)
REGISTER_SPACE_CREATOR(double, SPACE_JS_METR_FAST_APPROX, CreateJSMetricFastPrecompApprox)
// Word embeddings
REGISTER_SPACE_CREATOR(float, SPACE_WORD_EMBED, CreateWordEmbed)
REGISTER_SPACE_CREATOR(double, SPACE_WORD_EMBED, CreateWordEmbed)
// LP spaces
REGISTER_SPACE_CREATOR(float, SPACE_L, CreateL)
REGISTER_SPACE_CREATOR(double, SPACE_L, CreateL)
REGISTER_SPACE_CREATOR(float, SPACE_LINF, CreateLINF)
REGISTER_SPACE_CREATOR(double, SPACE_LINF, CreateLINF)
REGISTER_SPACE_CREATOR(float, SPACE_L1, CreateL1)
REGISTER_SPACE_CREATOR(double, SPACE_L1, CreateL1)
REGISTER_SPACE_CREATOR(float, SPACE_L2, CreateL2)
REGISTER_SPACE_CREATOR(double, SPACE_L2, CreateL2)
// Scalar product and related distances
// Dense
REGISTER_SPACE_CREATOR(float, SPACE_COSINE_SIMILARITY, CreateCosineSimilarity)
REGISTER_SPACE_CREATOR(double, SPACE_COSINE_SIMILARITY, CreateCosineSimilarity)
REGISTER_SPACE_CREATOR(float, SPACE_ANGULAR_DISTANCE, CreateAngularDistance)
REGISTER_SPACE_CREATOR(double, SPACE_ANGULAR_DISTANCE, CreateAngularDistance)
REGISTER_SPACE_CREATOR(float, SPACE_NEGATIVE_SCALAR, CreateNegativeScalarProduct)
REGISTER_SPACE_CREATOR(double, SPACE_NEGATIVE_SCALAR, CreateNegativeScalarProduct)
// Sparse
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_L, CreateSparseL)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_L, CreateSparseL)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_LINF, CreateSparseLINF)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_LINF, CreateSparseLINF)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_L1, CreateSparseL1)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_L1, CreateSparseL1)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_L2, CreateSparseL2)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_L2, CreateSparseL2)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_COSINE_SIMILARITY, CreateSparseCosineSimilarity)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_COSINE_SIMILARITY, CreateSparseCosineSimilarity)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_ANGULAR_DISTANCE, CreateSparseAngularDistance)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_ANGULAR_DISTANCE, CreateSparseAngularDistance)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_NEGATIVE_SCALAR, CreateSparseNegativeScalarProduct)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_QUERY_NORM_NEGATIVE_SCALAR, CreateSparseQueryNormNegativeScalarProduct)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_COSINE_SIMILARITY_FAST, CreateSparseCosineSimilarityFast)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_ANGULAR_DISTANCE_FAST, CreateSparseAngularDistanceFast)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_NEGATIVE_SCALAR_FAST, CreateSparseNegativeScalarProductFast)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_QUERY_NORM_NEGATIVE_SCALAR_FAST, CreateSparseQueryNormNegativeScalarProductFast)
REGISTER_SPACE_CREATOR(float, SPACE_SPARSE_JACCARD, CreateSpaceSparseJaccard)
REGISTER_SPACE_CREATOR(double, SPACE_SPARSE_JACCARD, CreateSpaceSparseJaccard)
#if defined(WITH_EXTRAS)
// Signature Quadratic Form Distance
REGISTER_SPACE_CREATOR(float, SPACE_SQFD_HEURISTIC_FUNC, CreateSqfdHeuristicFunc)
REGISTER_SPACE_CREATOR(double, SPACE_SQFD_HEURISTIC_FUNC, CreateSqfdHeuristicFunc)
REGISTER_SPACE_CREATOR(float, SPACE_SQFD_MINUS_FUNC, CreateSqfdMinusFunc)
REGISTER_SPACE_CREATOR(double, SPACE_SQFD_MINUS_FUNC, CreateSqfdMinusFunc)
REGISTER_SPACE_CREATOR(float, SPACE_SQFD_GAUSSIAN_FUNC, CreateSqfdGaussianFunc)
REGISTER_SPACE_CREATOR(double, SPACE_SQFD_GAUSSIAN_FUNC, CreateSqfdGaussianFunc)
#endif
REGISTER_SPACE_CREATOR(float, SPACE_AB_DIVERG_SLOW, CreateAlphaBetaDivergSlow)
REGISTER_SPACE_CREATOR(double, SPACE_AB_DIVERG_SLOW, CreateAlphaBetaDivergSlow)
REGISTER_SPACE_CREATOR(float, SPACE_AB_DIVERG_FAST, CreateAlphaBetaDivergFast)
REGISTER_SPACE_CREATOR(double, SPACE_AB_DIVERG_FAST, CreateAlphaBetaDivergFast)
REGISTER_SPACE_CREATOR(float, SPACE_RENYI_DIVERG_SLOW, CreateRenyiDivergSlow)
REGISTER_SPACE_CREATOR(double, SPACE_RENYI_DIVERG_SLOW, CreateRenyiDivergSlow)
REGISTER_SPACE_CREATOR(float, SPACE_RENYI_DIVERG_FAST, CreateRenyiDivergFast)
REGISTER_SPACE_CREATOR(double, SPACE_RENYI_DIVERG_FAST, CreateRenyiDivergFast)
REGISTER_SPACE_CREATOR(int, SPACE_L2SQR_SIFT, CreateL2SqrSIFT)
}
}
#endif