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

Function sparse_to_dense

dlib/svm/sparse_vector.h:845–872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843 {
844 template <typename sparse_vector_type>
845 inline matrix<typename sparse_vector_type::value_type::second_type,0,1> sparse_to_dense (
846 const sparse_vector_type& vect,
847 unsigned long num_dimensions
848 )
849 {
850 // You must use unsigned integral key types in your sparse vectors
851 typedef typename sparse_vector_type::value_type::first_type idx_type;
852 typedef typename sparse_vector_type::value_type::second_type value_type;
853 COMPILE_TIME_ASSERT(is_unsigned_type<idx_type>::value);
854
855 matrix<value_type,0,1> result;
856
857 if (vect.size() == 0)
858 return result;
859
860 result.set_size(num_dimensions);
861 result = 0;
862
863 for (typename sparse_vector_type::const_iterator j = vect.begin(); j != vect.end(); ++j)
864 {
865 if ((long)(j->first) < result.size())
866 {
867 result(j->first) += j->second;
868 }
869 }
870
871 return result;
872 }
873 }
874
875// ----------------------------------------------------------------------------------------

Callers 14

add_dfFunction · 0.85
add_normalized_dfFunction · 0.85
test1Function · 0.85
run_testMethod · 0.85
test1Function · 0.85
perform_testMethod · 0.85
run_testMethod · 0.85
test_sparse_to_denseMethod · 0.85
run_prior_sparse_testFunction · 0.85
run_prior_sparse_testFunction · 0.85
dotest_sparse_vectorsFunction · 0.85
find_cFunction · 0.85

Calls 8

join_colsFunction · 0.85
max_index_plus_oneFunction · 0.70
colmFunction · 0.50
sizeMethod · 0.45
set_sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45

Tested by 10

test1Function · 0.68
run_testMethod · 0.68
test1Function · 0.68
perform_testMethod · 0.68
run_testMethod · 0.68
test_sparse_to_denseMethod · 0.68
run_prior_sparse_testFunction · 0.68
run_prior_sparse_testFunction · 0.68
dotest_sparse_vectorsFunction · 0.68
find_cFunction · 0.68