Skip to content

Commit

Permalink
Fixes for isses #106
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusmuja committed May 27, 2013
1 parent baf8870 commit b72d526
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cpp/flann/algorithms/lsh_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class LshIndex : public NNIndex<Distance>
if (level == 0) return;
for (int index = lowest_index - 1; index >= 0; --index) {
// Create a new key
lsh::BucketKey new_key = key | (1 << index);
lsh::BucketKey new_key = key | (lsh::BucketKey(1) << index);
fill_xor_mask(new_key, index, level - 1, xor_masks);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/flann/util/lsh_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ class LshTable
if (speed_level_ == kArray) return;

// Use an array if it will be more than half full
if (buckets_space_.size() > (unsigned int)((1 << key_size_) / 2)) {
if (buckets_space_.size() > ((size_t(1) << key_size_) / 2)) {
speed_level_ = kArray;
// Fill the array version of it
buckets_speed_.resize(1 << key_size_);
buckets_speed_.resize(size_t(1) << key_size_);
for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) buckets_speed_[key_bucket->first] = key_bucket->second;

// Empty the hash table
Expand All @@ -284,9 +284,9 @@ class LshTable
// If the bitset is going to use less than 10% of the RAM of the hash map (at least 1 size_t for the key and two
// for the vector) or less than 512MB (key_size_ <= 30)
if (((std::max(buckets_space_.size(), buckets_speed_.size()) * CHAR_BIT * 3 * sizeof(BucketKey)) / 10
>= size_t(1 << key_size_)) || (key_size_ <= 32)) {
>= size_t(size_t(1) << key_size_)) || (key_size_ <= 32)) {
speed_level_ = kBitsetHash;
key_bitset_.resize(1 << key_size_);
key_bitset_.resize(size_t(1) << key_size_);
key_bitset_.reset();
// Try with the BucketsSpace
for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) key_bitset_.set(key_bucket->first);
Expand Down

0 comments on commit b72d526

Please sign in to comment.