MCPcopy Create free account
hub / github.com/davisking/dlib / make_sparse_vector

Function make_sparse_vector

dlib/svm/sparse_vector.h:978–993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

976 typename T
977 >
978 T make_sparse_vector (
979 const T& v
980 )
981 {
982 // You must use unsigned integral key types in your sparse vectors
983 typedef typename T::value_type::first_type idx_type;
984 typedef typename T::value_type::second_type value_type;
985 COMPILE_TIME_ASSERT(is_unsigned_type<idx_type>::value);
986 std::map<idx_type,value_type> temp;
987 for (typename T::const_iterator i = v.begin(); i != v.end(); ++i)
988 {
989 temp[i->first] += i->second;
990 }
991
992 return T(temp.begin(), temp.end());
993 }
994
995// ----------------------------------------------------------------------------------------
996

Callers 3

test_sparse_vectorFunction · 0.90
test_sparse_to_denseMethod · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by 2

test_sparse_vectorFunction · 0.72
test_sparse_to_denseMethod · 0.68