KernelStd.cpp 779 B

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