KernelStd.cpp 678 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 "KernelStd.h"
  14. using namespace OBJREC;
  15. using namespace std;
  16. using namespace NICE;
  17. KernelStd::KernelStd() : Kernel(true)
  18. {
  19. }
  20. KernelStd::~KernelStd()
  21. {
  22. }
  23. double KernelStd::K (const NICE::Vector & x, const NICE::Vector & y) const
  24. {
  25. if ( x.size() != y.size() )
  26. fthrow (Exception, "KernelStd::K: vectors must have the same dimension\n");
  27. double sum = 0.0;
  28. for ( int i = 0 ; i < (int)x.size() ; i++ )
  29. sum += x[i] * y[i];
  30. return sum;
  31. }