diff --git a/dlib/svm/kernel_matrix.h b/dlib/svm/kernel_matrix.h index 028cb9c84..ac398436c 100644 --- a/dlib/svm/kernel_matrix.h +++ b/dlib/svm/kernel_matrix.h @@ -7,6 +7,7 @@ #include "kernel_matrix_abstract.h" #include "../matrix.h" #include "../algs.h" +#include "../statistics/random_subset_selector.h" namespace dlib { @@ -23,6 +24,12 @@ namespace dlib return m(i); } + template + inline const T& access ( const random_subset_selector& m, long i) + { + return m[i]; + } + template inline const T& access ( const std::vector& m, long i) { @@ -52,6 +59,12 @@ namespace dlib return m.size(); } + template + inline unsigned long size ( const random_subset_selector& m) + { + return m.size(); + } + template inline unsigned long size ( const std::vector& m) { diff --git a/dlib/svm/kernel_matrix_abstract.h b/dlib/svm/kernel_matrix_abstract.h index 3afef2383..6638bb608 100644 --- a/dlib/svm/kernel_matrix_abstract.h +++ b/dlib/svm/kernel_matrix_abstract.h @@ -25,7 +25,8 @@ namespace dlib requires - kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h. This kernel must also be capable of operating on the contents of v. - - V == dlib::matrix, std::vector, dlib::std_vector_c, or kernel_type::sample_type. + - V == dlib::matrix, std::vector, dlib::std_vector_c, dlib::random_subset_selector, or + kernel_type::sample_type. - if (V is a dlib::matrix) then - is_vector(v) == true ensures @@ -58,8 +59,10 @@ namespace dlib requires - kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h This kernel must also be capable of operating on the contents of v1 and v2. - - V1 == dlib::matrix, std::vector, dlib::std_vector_c, or kernel_type::sample_type. - - V2 == dlib::matrix, std::vector, dlib::std_vector_c, or kernel_type::sample_type. + - V1 == dlib::matrix, std::vector, dlib::std_vector_c, dlib::random_subset_selector, or + kernel_type::sample_type. + - V2 == dlib::matrix, std::vector, dlib::std_vector_c, dlib::random_subset_selector, or + kernel_type::sample_type. - if (V1 is a dlib::matrix) then - is_vector(v1) == true - if (V2 is a dlib::matrix) then