diff --git a/dlib/svm/kernel.h b/dlib/svm/kernel.h index f5b93adb3..671d47dc9 100644 --- a/dlib/svm/kernel.h +++ b/dlib/svm/kernel.h @@ -50,6 +50,13 @@ namespace dlib const_cast(gamma) = k.gamma; return *this; } + + bool operator== ( + const radial_basis_kernel& k + ) const + { + return gamma == k.gamma; + } }; template < @@ -128,6 +135,13 @@ namespace dlib const_cast(degree) = k.degree; return *this; } + + bool operator== ( + const polynomial_kernel& k + ) const + { + return (gamma == k.gamma) && (coef == k.coef) && (degree == k.degree); + } }; template < @@ -187,6 +201,13 @@ namespace dlib { return trans(a)*b; } + + bool operator== ( + const linear_kernel& k + ) const + { + return true; + } }; template < diff --git a/dlib/svm/kernel_abstract.h b/dlib/svm/kernel_abstract.h index ebb31958f..a247e4049 100644 --- a/dlib/svm/kernel_abstract.h +++ b/dlib/svm/kernel_abstract.h @@ -34,6 +34,8 @@ namespace dlib dlib/memory_manager/memory_manager_kernel_abstract.h or dlib/memory_manager_global/memory_manager_global_kernel_abstract.h or dlib/memory_manager_stateless/memory_manager_stateless_kernel_abstract.h + - an overloaded == operator that tells you if two kernels are + identical or not. For examples of kernel functions see the following objects (e.g. the radial_basis_kernel). @@ -103,6 +105,17 @@ namespace dlib - returns *this !*/ + bool operator== ( + const radial_basis_kernel& k + ) const; + /*! + ensures + - if (k and *this are identical) then + - returns true + - else + - returns false + !*/ + }; template < @@ -203,6 +216,16 @@ namespace dlib - returns *this !*/ + bool operator== ( + const polynomial_kernel& k + ) const; + /*! + ensures + - if (k and *this are identical) then + - returns true + - else + - returns false + !*/ }; template < @@ -258,6 +281,14 @@ namespace dlib ensures - returns trans(a)*b !*/ + + bool operator== ( + const linear_kernel& k + ) const; + /*! + ensures + - returns true + !*/ }; template <