KernelStd.cpp 683 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @file KernelStd.cpp
  3. * @brief Standard kernel
  4. * @author Erik Rodner
  5. * @date 10/24/2007
  6. */
  7. #include <iostream>
  8. #include "vislearning/math/distances/KernelStd.h"
  9. using namespace OBJREC;
  10. using namespace std;
  11. // refactor-nice.pl: check this substitution
  12. // old: using namespace ice;
  13. using namespace NICE;
  14. KernelStd::KernelStd() : Kernel(true)
  15. {
  16. }
  17. KernelStd::~KernelStd()
  18. {
  19. }
  20. double KernelStd::K (const NICE::Vector & x, const NICE::Vector & y) const
  21. {
  22. if ( x.size() != y.size() )
  23. fthrow (Exception, "KernelStd::K: vectors must have the same dimension\n");
  24. double sum = 0.0;
  25. for ( int i = 0 ; i < (int)x.size() ; i++ )
  26. sum += x[i] * y[i];
  27. return sum;
  28. }