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

Function general_dot

dlib/svm/sparse_vector.h:222–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220 {
221 template <typename T, typename U>
222 typename T::value_type::second_type general_dot (
223 const T& a,
224 const U& b
225 )
226 {
227 typedef typename T::value_type::second_type scalar_type;
228
229 typename T::const_iterator ai = a.begin();
230 typename U::const_iterator bi = b.begin();
231
232 scalar_type sum = 0;
233 while (ai != a.end() && bi != b.end())
234 {
235 if (ai->first == bi->first)
236 {
237 sum += ai->second * bi->second;
238 ++ai;
239 ++bi;
240 }
241 else if (ai->first < bi->first)
242 {
243 ++ai;
244 }
245 else
246 {
247 ++bi;
248 }
249 }
250
251 return sum;
252 }
253
254 template <typename T, typename U>
255 inline typename T::value_type::second_type dot (

Callers 1

dotFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected