Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
6d7b0358
Commit
6d7b0358
authored
Apr 12, 2013
by
Davis King
Browse files
Fixed the hash_similar_angles_* hash functions so they also work on
matrices of float values.
parent
9bf9b7be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
dlib/lsh/hashes.h
dlib/lsh/hashes.h
+2
-1
dlib/test/linear_manifold_regularizer.cpp
dlib/test/linear_manifold_regularizer.cpp
+8
-4
No files found.
dlib/lsh/hashes.h
View file @
6d7b0358
...
@@ -57,10 +57,11 @@ namespace dlib
...
@@ -57,10 +57,11 @@ namespace dlib
const
matrix_exp
<
EXP
>&
v
const
matrix_exp
<
EXP
>&
v
)
const
)
const
{
{
typedef
typename
EXP
::
type
T
;
uint64
temp
=
0
;
uint64
temp
=
0
;
for
(
unsigned
long
i
=
0
;
i
<
64
;
++
i
)
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
;
temp
<<=
1
;
temp
<<=
1
;
}
}
...
...
dlib/test/linear_manifold_regularizer.cpp
View file @
6d7b0358
...
@@ -40,10 +40,11 @@ namespace
...
@@ -40,10 +40,11 @@ namespace
}
}
}
}
template
<
typename
scalar_type
>
void
test_knn_lsh_sparse
()
void
test_knn_lsh_sparse
()
{
{
dlib
::
rand
rnd
;
dlib
::
rand
rnd
;
std
::
vector
<
std
::
map
<
unsigned
long
,
doubl
e
>
>
samples
;
std
::
vector
<
std
::
map
<
unsigned
long
,
scalar_typ
e
>
>
samples
;
samples
.
resize
(
20
);
samples
.
resize
(
20
);
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
++
i
)
{
{
...
@@ -57,10 +58,11 @@ namespace
...
@@ -57,10 +58,11 @@ namespace
test_find_k_nearest_neighbors_lsh
<
hash_similar_angles_512
>
(
samples
);
test_find_k_nearest_neighbors_lsh
<
hash_similar_angles_512
>
(
samples
);
}
}
template
<
typename
scalar_type
>
void
test_knn_lsh_dense
()
void
test_knn_lsh_dense
()
{
{
dlib
::
rand
rnd
;
dlib
::
rand
rnd
;
std
::
vector
<
matrix
<
doubl
e
,
0
,
1
>
>
samples
;
std
::
vector
<
matrix
<
scalar_typ
e
,
0
,
1
>
>
samples
;
samples
.
resize
(
20
);
samples
.
resize
(
20
);
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
++
i
)
{
{
...
@@ -386,8 +388,10 @@ namespace
...
@@ -386,8 +388,10 @@ namespace
}
}
test_knn1
();
test_knn1
();
test_knn2
();
test_knn2
();
test_knn_lsh_sparse
();
test_knn_lsh_sparse
<
double
>
();
test_knn_lsh_dense
();
test_knn_lsh_sparse
<
float
>
();
test_knn_lsh_dense
<
double
>
();
test_knn_lsh_dense
<
float
>
();
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment