-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo_DumpyOS_DTW.cpp
More file actions
44 lines (34 loc) · 1.19 KB
/
Copy pathdemo_DumpyOS_DTW.cpp
File metadata and controls
44 lines (34 loc) · 1.19 KB
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
#include "../commons/dataloaders.hpp"
#include "../lib/daisy.hpp"
#include <chrono>
#include <algorithm>
int main()
{
daisy::idx_t n_database = 200000;
unsigned long long dim = 96;
unsigned long long n_query = 10;
daisy::idx_t k = 5;
float *database = loadRandomData(n_database, dim, 100, true);
float *query = loadRandomData(n_query, dim, 50, true);
printf("Loaded %llu database points and %llu query points with dimension %llu\n", n_database, n_query, dim);
daisy::DumpyOS dumpyos_search(daisy::DistanceType::DTW);
dumpyos_search.setNumThreads(4);
int warp_window = std::max(1, static_cast<int>(dim * 0.1));
dumpyos_search.setWarpingWindow(warp_window);
dumpyos_search.buildIndex(database, n_database, dim);
daisy::idx_t *I = new daisy::idx_t[n_query * k];
float *D = new float[n_query * k];
dumpyos_search.searchIndex(query, n_query, k, I, D);
for (daisy::idx_t i = 0; i < n_query; i++) {
printf("Query %llu: ", i);
for (daisy::idx_t j = 0; j < k; j++) {
printf("%llu ", I[i * k + j]);
}
printf("\n");
}
delete[] database;
delete[] query;
delete[] I;
delete[] D;
return 0;
}