GMHIKernel.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * @file GMHIKernel.h
  3. * @author Erik Rodner, Alexander Freytag
  4. * @brief Fast multiplication with histogram intersection kernel matrices (Interface)
  5. * @date 01/02/2012
  6. */
  7. #ifndef _NICE_GMHIKERNELINCLUDE
  8. #define _NICE_GMHIKERNELINCLUDE
  9. #include <vector>
  10. #include <core/algebra/GenericMatrix.h>
  11. #include "ImplicitKernelMatrix.h"
  12. #include "FeatureMatrixT.h"
  13. #include "FastMinKernel.h"
  14. namespace NICE {
  15. /**
  16. * @class GMHIKernel
  17. * @brief Fast multiplication with histogram intersection kernel matrices
  18. * @author Erik Rodner, Alexander Freytag
  19. */
  20. class GMHIKernel : public ImplicitKernelMatrix
  21. {
  22. protected:
  23. FastMinKernel *fmk;
  24. const Quantization *q;
  25. ParameterizedFunction *pf;
  26. bool verbose;
  27. bool use_sparse_implementation;
  28. bool useOldPreparation;
  29. public:
  30. /** simple constructor */
  31. GMHIKernel( FastMinKernel *_fmk, ParameterizedFunction *_pf = NULL, const Quantization *_q = NULL );
  32. /** multiply with a vector: A*x = y */
  33. virtual void multiply (NICE::Vector & y, const NICE::Vector & x) const;
  34. /** get the number of rows in A */
  35. virtual uint rows () const;
  36. /** get the number of columns in A */
  37. virtual uint cols () const;
  38. /** simple destructor */
  39. virtual ~GMHIKernel();
  40. /** get the diagonal elements of the current matrix */
  41. virtual void getDiagonalElements ( Vector & diagonalElements ) const;
  42. virtual void getFirstDiagonalElement ( double & diagonalElement ) const;
  43. uint getNumParameters() const;
  44. void getParameters(Vector & parameters) const;
  45. void setParameters(const Vector & parameters);
  46. bool outOfBounds(const Vector & parameters) const;
  47. Vector getParameterLowerBounds() const;
  48. Vector getParameterUpperBounds() const;
  49. void setVerbose( const bool & _verbose);
  50. void setUseOldPreparation( const bool & _useOldPreparation);
  51. virtual double approxFrobNorm() const;
  52. virtual void setApproximationScheme(const int & _approxScheme);
  53. void setFastMinKernel(NICE::FastMinKernel * _fmk){fmk = _fmk;};
  54. ///////////////////// INTERFACE PERSISTENT /////////////////////
  55. // interface specific methods for store and restore
  56. ///////////////////// INTERFACE PERSISTENT /////////////////////
  57. virtual void restore ( std::istream & is, int format = 0 ) {};//fmk->restore( is, format );};
  58. virtual void store ( std::ostream & os, int format = 0 ) const {};//fmk->store( os, format );};
  59. virtual void clear () {};
  60. ///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
  61. // interface specific methods for incremental extensions
  62. ///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
  63. virtual void addExample( const NICE::SparseVector * example,
  64. const double & label,
  65. const bool & performOptimizationAfterIncrement = true
  66. );
  67. virtual void addMultipleExamples( const std::vector< const NICE::SparseVector * > & newExamples,
  68. const NICE::Vector & newLabels,
  69. const bool & performOptimizationAfterIncrement = true
  70. );
  71. };
  72. }
  73. #endif