Commit 23e169da authored by Davis King's avatar Davis King

Fixed a bug in the kernel_matrix() function. It didn't compile when used with

sparse samples which were of type std::vector<std::pair<> >.  Moreover, some of
the trainers have a dependency on kernel_matrix() so this fix makes those trainers
also work with this kind of sparse sample.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404164
parent 2ee75d5f
......@@ -30,14 +30,18 @@ namespace dlib
return m[i];
}
// Only use this function if T isn't a std::pair because in that case the entire vector is
// probably itself a sparse sample.
template <typename kernel_type, typename T, typename alloc>
inline const T& access ( const std::vector<T,alloc>& m, long i)
inline typename disable_if<is_pair<T>,const T&>::type access ( const std::vector<T,alloc>& m, long i)
{
return m[i];
}
// Only use this function if T isn't a std::pair because in that case the entire vector is
// probably a sparse sample.
template <typename kernel_type, typename T, typename alloc>
inline const T& access ( const std_vector_c<T,alloc>& m, long i)
inline typename disable_if<is_pair<T>,const T&>::type access ( const std_vector_c<T,alloc>& m, long i)
{
return m[i];
}
......
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