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

Function make_sparse_vector

dlib/svm/sparse_vector.h:945–960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

943 typename T
944 >
945 T make_sparse_vector (
946 const T& v
947 )
948 {
949 // You must use unsigned integral key types in your sparse vectors
950 typedef typename T::value_type::first_type idx_type;
951 typedef typename T::value_type::second_type value_type;
952 COMPILE_TIME_ASSERT(is_unsigned_type<idx_type>::value);
953 std::map<idx_type,value_type> temp;
954 for (typename T::const_iterator i = v.begin(); i != v.end(); ++i)
955 {
956 temp[i->first] += i->second;
957 }
958
959 return T(temp.begin(), temp.end());
960 }
961
962// ----------------------------------------------------------------------------------------
963

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