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

Function sparse_matrix_vector_multiply

dlib/svm/sparse_vector.h:1022–1051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1020
1021 template <typename EXP, typename T, long NR, long NC, typename MM, typename L>
1022 void sparse_matrix_vector_multiply (
1023 const std::vector<sample_pair>& edges,
1024 const matrix_exp<EXP>& v,
1025 matrix<T,NR,NC,MM,L>& result
1026 )
1027 {
1028 // make sure requires clause is not broken
1029 DLIB_ASSERT(max_index_plus_one(edges) <= (unsigned long)v.size() &&
1030 is_col_vector(v),
1031 "\t void sparse_matrix_vector_multiply()"
1032 << "\n\t Invalid inputs were given to this function"
1033 << "\n\t max_index_plus_one(edges): " << max_index_plus_one(edges)
1034 << "\n\t v.size(): " << v.size()
1035 << "\n\t is_col_vector(v): " << is_col_vector(v)
1036 );
1037
1038 result.set_size(v.nr(),v.nc());
1039 result = 0;
1040
1041 for (unsigned long k = 0; k < edges.size(); ++k)
1042 {
1043 const long i = edges[k].index1();
1044 const long j = edges[k].index2();
1045 const double d = edges[k].distance();
1046
1047 result(i) += v(j)*d;
1048 if (i != j)
1049 result(j) += v(i)*d;
1050 }
1051 }
1052
1053// ----------------------------------------------------------------------------------------
1054

Calls 9

is_col_vectorFunction · 0.85
max_index_plus_oneFunction · 0.70
sizeMethod · 0.45
set_sizeMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
distanceMethod · 0.45
beginMethod · 0.45
endMethod · 0.45