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

Function add

dlib/svm/sparse_vector.h:463–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461
462 template <typename T>
463 typename disable_if<is_matrix<T>,T>::type add (
464 const T& a,
465 const T& b
466 )
467 {
468 T temp;
469
470 typename T::const_iterator i = a.begin();
471 typename T::const_iterator j = b.begin();
472 while (i != a.end() && j != b.end())
473 {
474 if (i->first == j->first)
475 {
476 temp.insert(temp.end(), std::make_pair(i->first, i->second + j->second));
477 ++i;
478 ++j;
479 }
480 else if (i->first < j->first)
481 {
482 temp.insert(temp.end(), *i);
483 ++i;
484 }
485 else
486 {
487 temp.insert(temp.end(), *j);
488 ++j;
489 }
490 }
491
492 while (i != a.end())
493 {
494 temp.insert(temp.end(), *i);
495 ++i;
496 }
497 while (j != b.end())
498 {
499 temp.insert(temp.end(), *j);
500 ++j;
501 }
502
503 return temp;
504 }
505
506 template <typename T, typename U>
507 typename enable_if_c<is_matrix<T>::value && is_matrix<U>::value, matrix_add_exp<T,U> >::type add (

Callers 2

addMethod · 0.50
addMethod · 0.50

Calls 3

beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected