ImplicitKernelMatrix.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @file ImplicitKernelMatrix.h
  3. * @author Erik Rodner, Alexander Freytag
  4. * @brief An implicit kernel matrix, allowing for fast multiplication with arbitrary vectors (Interface)
  5. * @date 02/14/2012
  6. */
  7. #ifndef _NICE_IMPLICITKERNELMATRIXINCLUDE
  8. #define _NICE_IMPLICITKERNELMATRIXINCLUDE
  9. // STL includes
  10. #include <iostream>
  11. // NICE-core includes
  12. #include <core/algebra/GenericMatrix.h>
  13. //
  14. #include <core/basics/Persistent.h>
  15. // gp-hik-core includes
  16. #include "gp-hik-core/OnlineLearnable.h"
  17. namespace NICE {
  18. /** @class ImplicitKernelMatrix
  19. * @brief An implicit kernel matrix, allowing for fast multiplication with arbitrary vectors
  20. * @author Erik Rodner, Alexander Freytag
  21. * @date 02/14/2012
  22. */
  23. class ImplicitKernelMatrix : public GenericMatrix, public NICE::Persistent, public NICE::OnlineLearnable
  24. {
  25. protected:
  26. public:
  27. /** simple constructor */
  28. ImplicitKernelMatrix();
  29. /** simple destructor */
  30. virtual ~ImplicitKernelMatrix();
  31. //get set methods
  32. virtual void getDiagonalElements ( Vector & diagonalElements ) const = 0;
  33. virtual void getFirstDiagonalElement ( double & diagonalElement ) const = 0;
  34. virtual uint getNumParameters() const = 0;
  35. virtual void getParameters(Vector & parameters) const = 0;
  36. virtual void setParameters(const Vector & parameters) = 0;
  37. virtual bool outOfBounds(const Vector & parameters) const = 0;
  38. virtual Vector getParameterLowerBounds() const = 0;
  39. virtual Vector getParameterUpperBounds() const = 0;
  40. virtual double approxFrobNorm() const = 0;
  41. virtual void setApproximationScheme(const int & _approxScheme) = 0;
  42. ///////////////////// INTERFACE PERSISTENT /////////////////////
  43. // interface specific methods for store and restore
  44. ///////////////////// INTERFACE PERSISTENT /////////////////////
  45. virtual void restore ( std::istream & is, int format = 0 ) = 0;
  46. virtual void store ( std::ostream & os, int format = 0 ) const = 0;
  47. virtual void clear () = 0;
  48. ///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
  49. // interface specific methods for incremental extensions
  50. ///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
  51. virtual void addExample( const NICE::SparseVector * example,
  52. const double & label,
  53. const bool & performOptimizationAfterIncrement = true
  54. ) = 0;
  55. virtual void addMultipleExamples( const std::vector< const NICE::SparseVector * > & newExamples,
  56. const NICE::Vector & newLabels,
  57. const bool & performOptimizationAfterIncrement = true
  58. ) = 0;
  59. //high order methods
  60. virtual void multiply (NICE::Vector &y, const NICE::Vector &x) const = 0;
  61. };
  62. }
  63. #endif