Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
d73d9e92
Commit
d73d9e92
authored
May 01, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the sparse vector dot() more flexible.
parent
59639060
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
sparse_vector.h
dlib/svm/sparse_vector.h
+21
-4
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