From b72d526463e892bfc4eb30bf0c640a3cb5b9bd69 Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Mon, 27 May 2013 10:05:38 -0700 Subject: [PATCH] Fixes for isses #106 --- src/cpp/flann/algorithms/lsh_index.h | 2 +- src/cpp/flann/util/lsh_table.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpp/flann/algorithms/lsh_index.h b/src/cpp/flann/algorithms/lsh_index.h index 0c3619c9..8594f60f 100644 --- a/src/cpp/flann/algorithms/lsh_index.h +++ b/src/cpp/flann/algorithms/lsh_index.h @@ -396,7 +396,7 @@ class LshIndex : public NNIndex 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); } } diff --git a/src/cpp/flann/util/lsh_table.h b/src/cpp/flann/util/lsh_table.h index 8ed17645..f023fb4c 100644 --- a/src/cpp/flann/util/lsh_table.h +++ b/src/cpp/flann/util/lsh_table.h @@ -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 @@ -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);