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

Function sparse_matrix_vector_multiply

dlib/svm/sparse_vector.h:1055–1084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1053
1054 template <typename EXP, typename T, long NR, long NC, typename MM, typename L>
1055 void sparse_matrix_vector_multiply (
1056 const std::vector<sample_pair>& edges,
1057 const matrix_exp<EXP>& v,
1058 matrix<T,NR,NC,MM,L>& result
1059 )
1060 {
1061 // make sure requires clause is not broken
1062 DLIB_ASSERT(max_index_plus_one(edges) <= (unsigned long)v.size() &&
1063 is_col_vector(v),
1064 "\t void sparse_matrix_vector_multiply()"
1065 << "\n\t Invalid inputs were given to this function"
1066 << "\n\t max_index_plus_one(edges): " << max_index_plus_one(edges)
1067 << "\n\t v.size(): " << v.size()
1068 << "\n\t is_col_vector(v): " << is_col_vector(v)
1069 );
1070
1071 result.set_size(v.nr(),v.nc());
1072 result = 0;
1073
1074 for (unsigned long k = 0; k < edges.size(); ++k)
1075 {
1076 const long i = edges[k].index1();
1077 const long j = edges[k].index2();
1078 const double d = edges[k].distance();
1079
1080 result(i) += v(j)*d;
1081 if (i != j)
1082 result(j) += v(i)*d;
1083 }
1084 }
1085
1086// ----------------------------------------------------------------------------------------
1087

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