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
aee36c3d
Commit
aee36c3d
authored
Nov 24, 2012
by
Davis King
Browse files
Added overloads of sparse_matrix_vector_multiply() that return their result
like normal rather than passing it back by reference.
parent
2bd7f123
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
dlib/svm/sparse_vector.h
dlib/svm/sparse_vector.h
+26
-0
dlib/svm/sparse_vector_abstract.h
dlib/svm/sparse_vector_abstract.h
+40
-0
No files found.
dlib/svm/sparse_vector.h
View file @
aee36c3d
...
@@ -942,6 +942,19 @@ namespace dlib
...
@@ -942,6 +942,19 @@ namespace dlib
}
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
matrix
<
typename
EXP
::
type
,
0
,
1
>
sparse_matrix_vector_multiply
(
const
std
::
vector
<
sample_pair
>&
edges
,
const
matrix_exp
<
EXP
>&
v
)
{
matrix
<
typename
EXP
::
type
,
0
,
1
>
result
;
sparse_matrix_vector_multiply
(
edges
,
v
,
result
);
return
result
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
,
typename
T
,
long
NR
,
long
NC
,
typename
MM
,
typename
L
>
template
<
typename
EXP
,
typename
T
,
long
NR
,
long
NC
,
typename
MM
,
typename
L
>
...
@@ -975,6 +988,19 @@ namespace dlib
...
@@ -975,6 +988,19 @@ namespace dlib
}
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
matrix
<
typename
EXP
::
type
,
0
,
1
>
sparse_matrix_vector_multiply
(
const
std
::
vector
<
ordered_sample_pair
>&
edges
,
const
matrix_exp
<
EXP
>&
v
)
{
matrix
<
typename
EXP
::
type
,
0
,
1
>
result
;
sparse_matrix_vector_multiply
(
edges
,
v
,
result
);
return
result
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/svm/sparse_vector_abstract.h
View file @
aee36c3d
...
@@ -576,6 +576,46 @@ namespace dlib
...
@@ -576,6 +576,46 @@ namespace dlib
(i.e. result will have the same dimensions as v)
(i.e. result will have the same dimensions as v)
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
matrix
<
typename
EXP
::
type
,
0
,
1
>
sparse_matrix_vector_multiply
(
const
std
::
vector
<
sample_pair
>&
edges
,
const
matrix_exp
<
EXP
>&
v
);
/*!
requires
- is_col_vector(v) == true
- max_index_plus_one(edges) <= v.size()
ensures
- This is just a convenience routine for invoking the above
sparse_matrix_vector_multiply() routine. In particular, it just calls
sparse_matrix_vector_multiply() with a temporary result matrix and then
returns the result.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
matrix
<
typename
EXP
::
type
,
0
,
1
>
sparse_matrix_vector_multiply
(
const
std
::
vector
<
ordered_sample_pair
>&
edges
,
const
matrix_exp
<
EXP
>&
v
);
/*!
requires
- is_col_vector(v) == true
- max_index_plus_one(edges) <= v.size()
ensures
- This is just a convenience routine for invoking the above
sparse_matrix_vector_multiply() routine. In particular, it just calls
sparse_matrix_vector_multiply() with a temporary result matrix and then
returns the result.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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