Commit 6d7b0358 authored by Davis King's avatar Davis King

Fixed the hash_similar_angles_* hash functions so they also work on

matrices of float values.
parent 9bf9b7be
......@@ -57,10 +57,11 @@ namespace dlib
const matrix_exp<EXP>& v
) const
{
typedef typename EXP::type T;
uint64 temp = 0;
for (unsigned long i = 0; i < 64; ++i)
{
if (dot(gaussian_randm(v.size(),1,i+seed*64), v) > 0)
if (dot(matrix_cast<T>(gaussian_randm(v.size(),1,i+seed*64)), v) > 0)
temp |= 1;
temp <<= 1;
}
......
......@@ -40,10 +40,11 @@ namespace
}
}
template <typename scalar_type>
void test_knn_lsh_sparse()
{
dlib::rand rnd;
std::vector<std::map<unsigned long,double> > samples;
std::vector<std::map<unsigned long,scalar_type> > samples;
samples.resize(20);
for (unsigned int i = 0; i < samples.size(); ++i)
{
......@@ -57,10 +58,11 @@ namespace
test_find_k_nearest_neighbors_lsh<hash_similar_angles_512>(samples);
}
template <typename scalar_type>
void test_knn_lsh_dense()
{
dlib::rand rnd;
std::vector<matrix<double,0,1> > samples;
std::vector<matrix<scalar_type,0,1> > samples;
samples.resize(20);
for (unsigned int i = 0; i < samples.size(); ++i)
{
......@@ -386,8 +388,10 @@ namespace
}
test_knn1();
test_knn2();
test_knn_lsh_sparse();
test_knn_lsh_dense();
test_knn_lsh_sparse<double>();
test_knn_lsh_sparse<float>();
test_knn_lsh_dense<double>();
test_knn_lsh_dense<float>();
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment