Mercurial > hg > audiodb
comparison multiprobe.h @ 519:fdcd436d7cbd multiprobeLSH
lshlib MultiProbe glue added. Compiles and links against audioDB. Fails LSH tests at the moment.
author | mas01mc |
---|---|
date | Mon, 26 Jan 2009 05:42:15 +0000 |
parents | ca1ee92c359c |
children |
comparison
equal
deleted
inserted
replaced
518:ca1ee92c359c | 519:fdcd436d7cbd |
---|---|
32 typedef set<int > perturbation_set ; | 32 typedef set<int > perturbation_set ; |
33 | 33 |
34 typedef class MinHeapElement{ | 34 typedef class MinHeapElement{ |
35 public: | 35 public: |
36 perturbation_set perturbs; | 36 perturbation_set perturbs; |
37 double score; | 37 float score; |
38 MinHeapElement(perturbation_set a, double s); | 38 MinHeapElement(perturbation_set a, float s); |
39 virtual ~MinHeapElement(); | 39 virtual ~MinHeapElement(); |
40 } min_heap_element; | 40 } min_heap_element; |
41 | 41 |
42 typedef priority_queue<min_heap_element, | 42 typedef priority_queue<min_heap_element, |
43 vector<min_heap_element>, | 43 vector<min_heap_element>, |
44 greater<min_heap_element> | 44 greater<min_heap_element> |
45 > min_heap_of_perturbation_set ; | 45 > min_heap_of_perturbation_set ; |
46 | 46 |
47 typedef pair<double, pair<int, int> > sorted_distance_functions ; | 47 typedef pair<float, pair<int, int> > sorted_distance_functions ; |
48 | |
49 bool operator> (const min_heap_element& a, const min_heap_element& b){ | |
50 return a.score > b.score; | |
51 } | |
52 | |
53 bool operator< (const min_heap_element& a, const min_heap_element& b){ | |
54 return a.score < b.score; | |
55 } | |
56 | |
57 bool operator>(const sorted_distance_functions& a, const sorted_distance_functions& b){ | |
58 return a.first > b.first; | |
59 } | |
60 | |
61 bool operator<(const sorted_distance_functions& a, const sorted_distance_functions& b){ | |
62 return a.first < b.first; | |
63 } | |
64 | 48 |
65 class MultiProbe{ | 49 class MultiProbe{ |
66 protected: | 50 protected: |
67 min_heap_of_perturbation_set* minHeap; | 51 min_heap_of_perturbation_set* minHeap; |
68 min_heap_of_perturbation_set* outSets; | 52 min_heap_of_perturbation_set* outSets; |
74 void cleanup(); | 58 void cleanup(); |
75 | 59 |
76 // perturbation set operations | 60 // perturbation set operations |
77 perturbation_set& shift(perturbation_set&); | 61 perturbation_set& shift(perturbation_set&); |
78 perturbation_set& expand(perturbation_set&); | 62 perturbation_set& expand(perturbation_set&); |
79 double score(perturbation_set&); | 63 float score(perturbation_set&); |
80 bool valid(perturbation_set&); | 64 bool valid(perturbation_set&); |
81 void makeSortedDistFuns(vector<double> &); | 65 void makeSortedDistFuns(vector<float> &); |
66 void makeSortedDistFuns(float* x, unsigned N); | |
67 | |
68 // perturbation set generation algorithm | |
69 void algorithm1(unsigned T); | |
82 | 70 |
83 public: | 71 public: |
84 MultiProbe(); | 72 MultiProbe(); |
85 ~MultiProbe(); | 73 ~MultiProbe(); |
86 | 74 |
87 // generation of perturbation sets | 75 // generation of perturbation sets |
88 void generatePerturbationSets(vector<double>& vectorOfBounaryDistances, int numSetsToGenerate); | 76 void generatePerturbationSets(vector<float>& vectorOfBounaryDistances, unsigned numSetsToGenerate); |
77 void generatePerturbationSets(float* arrayOfBoundaryDistances, unsigned numDistances, unsigned numSetsToGenerate); | |
89 perturbation_set getNextPerturbationSet(); | 78 perturbation_set getNextPerturbationSet(); |
90 void dump(perturbation_set); | 79 void dump(perturbation_set); |
91 size_t size(); // Number of perturbation sets are in the output queue | 80 size_t size(); // Number of perturbation sets are in the output queue |
92 bool empty(); // predicate for empty MultiProbe set | 81 bool empty(); // predicate for empty MultiProbe set |
82 int getIndex(perturbation_set::iterator it); // return index of hash function for given set entry | |
83 int getBoundary(perturbation_set::iterator it); // return boundary {-1,+1} for given set entry | |
93 }; | 84 }; |
94 | 85 |
95 | 86 |
96 /* NOTES: | 87 /* NOTES: |
97 | 88 |