Mercurial > hg > audiodb
comparison multiprobe.h @ 517:807c8be7dd45 multiprobeLSH
Completed multiprobe framework for LSH. Requires testing.
author | mas01mc |
---|---|
date | Sun, 25 Jan 2009 06:10:38 +0000 |
parents | 2a7bad47a4a7 |
children | ca1ee92c359c |
comparison
equal
deleted
inserted
replaced
516:2a7bad47a4a7 | 517:807c8be7dd45 |
---|---|
18 | 18 |
19 #include <functional> | 19 #include <functional> |
20 #include <queue> | 20 #include <queue> |
21 #include <vector> | 21 #include <vector> |
22 #include <set> | 22 #include <set> |
23 #include <algorithm> | |
24 #include <iostream> | |
23 | 25 |
24 using namespace std ; | 26 using namespace std ; |
25 | 27 |
26 typedef set<int > perturbation_set ; | 28 typedef set<int > perturbation_set ; |
27 typedef vector<perturbation_set > vector_of_perturbation_set ; | 29 typedef vector<perturbation_set > vector_of_perturbation_set ; |
31 min_heap_element, | 33 min_heap_element, |
32 vector_of_min_heap_element, | 34 vector_of_min_heap_element, |
33 greater<min_heap_element> | 35 greater<min_heap_element> |
34 > min_heap_of_perturbation_set ; | 36 > min_heap_of_perturbation_set ; |
35 typedef pair<double, pair<int, int> > sorted_distance_functions ; | 37 typedef pair<double, pair<int, int> > sorted_distance_functions ; |
38 typedef vector<sorted_distance_functions> vector_of_sorted_distance_functions; | |
36 | 39 |
37 bool operator>(const min_heap_element& a, const min_heap_element& b){ | 40 bool operator>(const min_heap_element& a, const min_heap_element& b){ |
38 return a.second > b.second; | 41 return a.second > b.second; |
39 } | 42 } |
40 | 43 |
41 bool operator<(const min_heap_element& a, const min_heap_element& b){ | 44 bool operator<(const min_heap_element& a, const min_heap_element& b){ |
42 return a.second < b.second; | 45 return a.second < b.second; |
43 } | 46 } |
44 | 47 |
45 bool operator>(const sorted_distance_functions& a, const sorted_distance_functions& b){ | 48 bool operator>(const sorted_distance_functions& a, const sorted_distance_functions& b){ |
46 return a.second > b.second; | 49 return a.first > b.first; |
47 } | 50 } |
48 | 51 |
49 bool operator<(const sorted_distance_functions& a, const sorted_distance_functions& b){ | 52 bool operator<(const sorted_distance_functions& a, const sorted_distance_functions& b){ |
50 return a.second < b.second; | 53 return a.first < b.first; |
51 } | 54 } |
52 | 55 |
53 class MultiProbe{ | 56 class MultiProbe{ |
54 protected: | 57 protected: |
55 min_heap_of_perturbation_set* minHeap; | 58 min_heap_of_perturbation_set* minHeap; |
56 vector_of_perturbation_set* outSets; | 59 vector_of_perturbation_set* outSets; |
57 sorted_distance_functions distFuns; | 60 vector_of_sorted_distance_functions* distFuns; |
61 unsigned numHashBoundaries; | |
58 public: | 62 public: |
59 MultiProbe(); | 63 MultiProbe(); |
60 ~MultiProbe(); | 64 ~MultiProbe(); |
61 | 65 |
62 // perturbation set operations | 66 // perturbation set operations |
63 perturbation_set& shift(perturbation_set); | 67 perturbation_set& shift(perturbation_set&); |
64 perturbation_set& expand(perturbation_set); | 68 perturbation_set& expand(perturbation_set&); |
65 double score(perturbation_set&); | 69 double score(perturbation_set&); |
66 bool valid(perturbation_set&); | 70 bool valid(perturbation_set&); |
67 | 71 |
68 // generation of perturbation sets | 72 // generation of perturbation sets |
69 void generatePerturbationSets(int, vector<int>&); | 73 void generatePerturbationSets(int, vector<double>&); |
70 sorted_distance_functions& makeSortedDistFuns(vector<int> &); | 74 void makeSortedDistFuns(vector<double> &); |
75 void dump(perturbation_set& ); | |
71 }; | 76 }; |
72 | 77 |
73 /* NOTES: | 78 /* NOTES: |
74 | 79 |
75 Reference: | 80 Reference: |