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
d73d9e92
"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "c8b0f0eb21354df3b920e75fc1517d4d06d757b4"
Commit
d73d9e92
authored
Apr 30, 2012
by
Davis King
Browse files
Made the sparse vector dot() more flexible.
parent
59639060
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
dlib/svm/sparse_vector.h
dlib/svm/sparse_vector.h
+21
-4
dlib/svm/sparse_vector_abstract.h
dlib/svm/sparse_vector_abstract.h
+2
-2
No files found.
dlib/svm/sparse_vector.h
View file @
d73d9e92
...
@@ -216,16 +216,33 @@ namespace dlib
...
@@ -216,16 +216,33 @@ namespace dlib
// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------
template
<
typename
T
>
typename
T
::
value_type
::
second_type
dot
(
namespace
impl
{
// This funny looking thing is here to let us use SFINAE to make the dot()
// function below only get selected from the overload resolution order if
// it's operating on two sparse vectors.
template
<
typename
T
,
typename
U
>
struct
dot_ret_type
{
typedef
T
type
;
};
}
// This funny looking thing is here to let us use SFINAE to make the dot()
// function below only get selected from the overload resolution order if
// it's operating on two sparse vectors.
template
<
typename
T
,
typename
U
>
typename
dlib
::
sparse_vector
::
impl
::
dot_ret_type
<
typename
T
::
value_type
::
second_type
,
typename
U
::
value_type
::
second_type
>::
type
dot
(
const
T
&
a
,
const
T
&
a
,
const
T
&
b
const
U
&
b
)
)
{
{
typedef
typename
T
::
value_type
::
second_type
scalar_type
;
typedef
typename
T
::
value_type
::
second_type
scalar_type
;
typename
T
::
const_iterator
ai
=
a
.
begin
();
typename
T
::
const_iterator
ai
=
a
.
begin
();
typename
T
::
const_iterator
bi
=
b
.
begin
();
typename
U
::
const_iterator
bi
=
b
.
begin
();
scalar_type
sum
=
0
;
scalar_type
sum
=
0
;
while
(
ai
!=
a
.
end
()
&&
bi
!=
b
.
end
())
while
(
ai
!=
a
.
end
()
&&
bi
!=
b
.
end
())
...
...
dlib/svm/sparse_vector_abstract.h
View file @
d73d9e92
...
@@ -152,10 +152,10 @@ namespace dlib
...
@@ -152,10 +152,10 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
template
<
typename
T
,
typename
U
>
typename
T
::
value_type
::
second_type
dot
(
typename
T
::
value_type
::
second_type
dot
(
const
T
&
a
,
const
T
&
a
,
const
T
&
b
const
U
&
b
);
);
/*!
/*!
requires
requires
...
...
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