New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of Multiprobe LSH #691
Changes from 1 commit
8dd409d
8264347
f24ac2c
27510fe
a48c842
4adaf8f
8bc5ced
a048f46
d332ea1
00377a8
f0638a0
6d11521
fa7f62d
ae81ee5
840efe9
2af985c
75dead3
89b3c7b
79b954a
e2596c5
5d603b2
039af23
71eda99
2aa839c
cc6a5c2
4ba6f6d
71edfbb
d418c09
f1e11fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,10 +359,10 @@ class LSHSearch | |
* @param additionalProbingBins matrix. Each column will hold one additional | ||
* bin. | ||
*/ | ||
void GetAdditionalProbingBins(const arma::vec &queryCode, | ||
const arma::vec &queryCodeNotFloored, | ||
void GetAdditionalProbingBins(const arma::vec& queryCode, | ||
const arma::vec& queryCodeNotFloored, | ||
const size_t T, | ||
arma::mat &additionalProbingBins) const; | ||
arma::mat& additionalProbingBins) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing seems off here, the second/third/fourth arguments should align with the first. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a matter of preference, but to be consistent with the rest of the code: when declaring a variable, place the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you, I didn't notice that. |
||
//! Reference dataset. | ||
const arma::mat* referenceSet; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,20 +402,22 @@ inline bool perturbationValid(const std::vector<size_t>& A, | |
} | ||
*/ | ||
|
||
//Returns the score of a perturbation vector generated by perturbation set A. | ||
//The score of a pertubation set (vector) is the sum of scores of the | ||
//participating actions. | ||
// Returns the score of a perturbation vector generated by perturbation set A. | ||
// The score of a pertubation set (vector) is the sum of scores of the | ||
// participating actions. | ||
inline double perturbationScore(const std::vector<bool>& A, | ||
const arma::vec& scores) | ||
{ | ||
double score = 0.0; | ||
for (size_t i = 0; i < A.size(); ++i) | ||
score += A[i] ? scores(i) : 0; //add scores of non-zero indices | ||
if (A[i]) | ||
score += scores(i) // add scores of non-zero indices | ||
return score; | ||
} | ||
|
||
// Inline function used by GetAdditionalProbingBins. The vector shift operation | ||
// replaces the largest element of a vector A with (largest element) + 1. | ||
// Returns true if resulting vector is valid, otherwise false. | ||
inline bool perturbationShift(std::vector<bool>& A) | ||
{ | ||
size_t maxPos = 0; | ||
|
@@ -434,18 +436,19 @@ inline bool perturbationShift(std::vector<bool>& A) | |
|
||
// Inline function used by GetAdditionalProbingBins. The vector expansion | ||
// operation adds the element [1 + (largest_element)] to a vector A, where | ||
// largest_element is the largest element of A. | ||
// largest_element is the largest element of A. Returns true if resulting vector | ||
// is valid, otherwise false. | ||
inline bool perturbationExpand(std::vector<bool>& A) | ||
{ | ||
// Find the last '1' in A | ||
size_t maxPos = 0; | ||
for (size_t i = 0; i < A.size(); ++i) | ||
if (A[i]) //marked true | ||
if (A[i]) // marked true | ||
maxPos = i; | ||
|
||
if ( maxPos + 1 < A.size()) // otherwise, this is an invalid vector | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
A[maxPos+1] = 1; | ||
A[maxPos + 1] = 1; | ||
return true; | ||
} | ||
return false; | ||
|
@@ -458,16 +461,12 @@ inline bool perturbationExpand(std::vector<bool>& A) | |
inline bool perturbationValid(const std::vector<bool>& A, | ||
const size_t numProj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another small comment---we should name this function |
||
{ | ||
// Stack allocation and initialization to 0 (bool check[numProj] = {0}) made | ||
// some compilers complain, and std::vector might even be compressed (depends | ||
// on implementation) so this saves some space. | ||
// Use check to mark dimensions we have seen before in A. If a dimension is | ||
// seen twice (or more), A is not a valid perturbation. | ||
std::vector<bool> check(numProj); | ||
|
||
if (A.size() > 2 * numProj) | ||
{ | ||
Log::Assert(1 == 2); | ||
return false; // This should never happen | ||
} | ||
return false; // This should never happen. | ||
|
||
// Check that we only see each dimension once. If not, vector is not valid. | ||
for (size_t i = 0; i < A.size(); ++i) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same applies here about the line wrap spacing.