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
6d48b166
Commit
6d48b166
authored
Dec 06, 2011
by
Davis King
Browse files
Added methods to get the assignment by reference rather than returning
a copy by value.
parent
407e9aff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
dlib/svm/assignment_function.h
dlib/svm/assignment_function.h
+22
-4
dlib/svm/assignment_function_abstract.h
dlib/svm/assignment_function_abstract.h
+18
-0
No files found.
dlib/svm/assignment_function.h
View file @
6d48b166
...
...
@@ -99,14 +99,17 @@ namespace dlib
bool
forces_assignment
(
)
const
{
return
force_assignment
;
}
result_type
operator
()
(
void
predict_assignments
(
const
std
::
vector
<
lhs_element
>&
lhs
,
const
std
::
vector
<
rhs_element
>&
rhs
const
std
::
vector
<
rhs_element
>&
rhs
,
result_type
&
assignment
)
const
{
using
dlib
::
sparse_vector
::
dot
;
using
dlib
::
dot
;
assignment
.
clear
();
matrix
<
double
>
cost
;
unsigned
long
size
;
if
(
force_assignment
)
...
...
@@ -139,7 +142,6 @@ namespace dlib
}
}
std
::
vector
<
long
>
assignment
;
if
(
cost
.
size
()
!=
0
)
{
...
...
@@ -157,8 +159,24 @@ namespace dlib
if
(
assignment
[
i
]
>=
(
long
)
rhs
.
size
())
assignment
[
i
]
=
-
1
;
}
}
return
assignment
;
void
predict_assignments
(
const
sample_type
&
item
,
result_type
&
assignment
)
const
{
predict_assignments
(
item
.
first
,
item
.
second
,
assignment
);
}
result_type
operator
()(
const
std
::
vector
<
lhs_element
>&
lhs
,
const
std
::
vector
<
rhs_element
>&
rhs
)
const
{
result_type
temp
;
predict_assignments
(
lhs
,
rhs
,
temp
);
return
temp
;
}
result_type
operator
()
(
...
...
dlib/svm/assignment_function_abstract.h
View file @
6d48b166
...
...
@@ -247,6 +247,24 @@ namespace dlib
- returns (*this)(item.first, item.second);
!*/
void
predict_assignments
(
const
sample_type
&
item
,
result_type
&
assignment
)
const
;
/*!
ensures
- #assignment == (*this)(item)
!*/
void
predict_assignments
(
const
std
::
vector
<
lhs_element
>&
lhs
,
const
std
::
vector
<
rhs_element
>&
rhs
result_type
&
assignment
)
const
;
/*!
ensures
- #assignment == (*this)(lhs,rhs)
!*/
};
// ----------------------------------------------------------------------------------------
...
...
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