IntersectionKernelFunction.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // /**
  2. // * @file IntersectionKernelFunction.cpp
  3. // * @brief Implementation for the intersection kernel function as distance measure between two histograms interpreted as vectors
  4. // * @author Alexander Freytag
  5. // * @date 08-12-2011 (dd-mm-yyyy)
  6. // */
  7. //
  8. // #include "IntersectionKernelFunction.h"
  9. //
  10. // using namespace NICE;
  11. //
  12. // template <typename T>
  13. // IntersectionKernelFunction<T>::IntersectionKernelFunction()
  14. // {
  15. // }
  16. //
  17. // template <typename T>
  18. // IntersectionKernelFunction<T>::~IntersectionKernelFunction()
  19. // {
  20. // }
  21. //
  22. // template <typename T>
  23. // double IntersectionKernelFunction<T>::measureDistance ( const NICE::SparseVector & a, const NICE::SparseVector & b )
  24. // {
  25. // double distance(0.0);
  26. //
  27. // for (NICE::SparseVector::const_iterator itA = a.begin(); itA != a.end(); itA++)
  28. // {
  29. // NICE::SparseVector::const_iterator itB = b.find(itA->first);
  30. // if (itB != b.end())
  31. // distance += std::min(itA->second , itB->second);
  32. // }
  33. //
  34. // return distance;
  35. // }
  36. //
  37. // template <typename T>
  38. // NICE::Matrix IntersectionKernelFunction<T>::computeKernelMatrix ( const std::vector<NICE::SparseVector > & X , const double & noise)
  39. // {
  40. // NICE::Matrix K;
  41. // K.resize(X.size(), X.size());
  42. // K.set(0.0);
  43. //
  44. // for (int i = 0; i < X.size(); i++)
  45. // {
  46. // for (int j = i; j < X.size(); j++)
  47. // {
  48. // K(i,j) = measureDistance(X[i],X[j]);
  49. // if (i!=j)
  50. // K(j,i) = K(i,j);
  51. // }
  52. // }
  53. //
  54. // //add noise on the main diagonal
  55. // for (int i = 0; i < (int) X.size(); i++)
  56. // K(i,i) += noise;
  57. // return K;
  58. // }
  59. //
  60. // template <typename T>
  61. // std::vector<double> IntersectionKernelFunction<T>::computeKernelVector ( const std::vector<NICE::SparseVector> & X , const NICE::SparseVector & xstar)
  62. // {
  63. // std::vector<double> kstar;
  64. //
  65. // kstar.resize((int) X.size());
  66. //
  67. // for (int i = 0; i < (int) X.size(); i++)
  68. // {
  69. // kstar[i] = measureDistance(X[i], xstar);
  70. // }
  71. //
  72. // return kstar;
  73. // }
  74. //
  75. // template <typename T>
  76. // void IntersectionKernelFunction<T>::sayYourName()
  77. // {
  78. // std::cerr << "I'm the Intersection Kernel." << std::endl;
  79. // }