GMHIKernelRaw.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @file GMHIKernelRaw.h
  3. * @author Erik Rodner, Alexander Freytag
  4. * @brief Fast multiplication with histogram intersection kernel matrices (Interface)
  5. */
  6. #ifndef _NICE_GMHIKERNELRAWINCLUDE
  7. #define _NICE_GMHIKERNELRAWINCLUDE
  8. #include <vector>
  9. #include <core/algebra/GenericMatrix.h>
  10. namespace NICE {
  11. /**
  12. * @class GMHIKernel
  13. * @brief Fast multiplication with histogram intersection kernel matrices
  14. * @author Erik Rodner, Alexander Freytag
  15. */
  16. class GMHIKernelRaw : public GenericMatrix
  17. {
  18. public:
  19. typedef struct sparseVectorElement {
  20. uint example_index;
  21. double value;
  22. bool operator< (const sparseVectorElement & a) const
  23. {
  24. return value < a.value;
  25. }
  26. } sparseVectorElement;
  27. protected:
  28. sparseVectorElement **examples_raw;
  29. double **table_A;
  30. double **table_B;
  31. uint *nnz_per_dimension;
  32. uint num_dimension;
  33. uint num_examples;
  34. double d_noise;
  35. void initData ( const std::vector< const NICE::SparseVector *> & examples );
  36. void cleanupData ();
  37. double **allocateTable() const;
  38. void copyTable(double **src, double **dst) const;
  39. public:
  40. /** simple constructor */
  41. GMHIKernelRaw( const std::vector< const NICE::SparseVector *> & examples, const double d_noise = 0.1 );
  42. /** multiply with a vector: A*x = y; this is not really const anymore!! */
  43. virtual void multiply (NICE::Vector & y, const NICE::Vector & x) const;
  44. /** get the number of rows in A */
  45. virtual uint rows () const;
  46. /** get the number of columns in A */
  47. virtual uint cols () const;
  48. double **getTableA() const;
  49. double **getTableB() const;
  50. uint *getNNZPerDimension() const;
  51. /** simple destructor */
  52. virtual ~GMHIKernelRaw();
  53. sparseVectorElement **getDataMatrix() const { return examples_raw; };
  54. };
  55. }
  56. #endif