Commit 13ed137c authored by Davis King's avatar Davis King

Added a requires clause to the set_tolerance() member function and

renamed clear() to clear_dictionary().

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402249
parent 8e513302
...@@ -36,11 +36,18 @@ namespace dlib ...@@ -36,11 +36,18 @@ namespace dlib
kernel(kernel_), kernel(kernel_),
tolerance(tolerance_) tolerance(tolerance_)
{ {
clear(); clear_dictionary();
} }
void set_tolerance (scalar_type tolerance_) void set_tolerance (scalar_type tolerance_)
{ {
// make sure requires clause is not broken
DLIB_ASSERT(tolerance_ >= 0,
"\tvoid krls::set_tolerance"
<< "\n\tinvalid tolerance value"
<< "\n\ttolerance: " << tolerance_
<< "\n\tthis: " << this
);
tolerance = tolerance_; tolerance = tolerance_;
} }
...@@ -49,7 +56,7 @@ namespace dlib ...@@ -49,7 +56,7 @@ namespace dlib
return tolerance; return tolerance;
} }
void clear () void clear_dictionary ()
{ {
dictionary.clear(); dictionary.clear();
alpha.clear(); alpha.clear();
......
...@@ -56,6 +56,8 @@ namespace dlib ...@@ -56,6 +56,8 @@ namespace dlib
scalar_type tolerance_ scalar_type tolerance_
); );
/*! /*!
requires
- tolerance_ >= 0
ensures ensures
- #get_tolerance() == tolerance_ - #get_tolerance() == tolerance_
!*/ !*/
...@@ -73,15 +75,12 @@ namespace dlib ...@@ -73,15 +75,12 @@ namespace dlib
less accurate decision function but also in less support vectors. less accurate decision function but also in less support vectors.
!*/ !*/
void clear ( void clear_dictionary (
); );
/*! /*!
ensures ensures
- clears out all learned data and puts this object back to its - clears out all learned data
initial state.
(e.g. #get_decision_function().support_vectors.size() == 0) (e.g. #get_decision_function().support_vectors.size() == 0)
- #get_tolerance() == get_tolerance()
(i.e. doesn't change the value of the tolerance)
!*/ !*/
scalar_type operator() ( scalar_type operator() (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment