FullVector.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @file FullVector.h
  3. * @brief non sparse vector
  4. * @author Erik Rodner
  5. * @date 05/11/2008
  6. */
  7. #ifndef FullVectorINCLUDE
  8. #define FullVectorINCLUDE
  9. #include <vector>
  10. #include <map>
  11. #include <iostream>
  12. #include "core/basics/Persistent.h"
  13. namespace OBJREC {
  14. /** non sparse vector */
  15. class FullVector : public NICE::Persistent
  16. {
  17. protected:
  18. public:
  19. double *data;
  20. int length;
  21. FullVector ( const std::map<int, double> & mymap );
  22. FullVector ( const std::map<short, double> & mymap );
  23. /**
  24. * Creates a vector with specified size (values will be randomized initialized)
  25. * @param length
  26. */
  27. FullVector (int length);
  28. FullVector ();
  29. FullVector ( const FullVector & v );
  30. ~FullVector ();
  31. void set ( double val );
  32. void add ( const FullVector & v );
  33. void add ( const FullVector & v, double lambda );
  34. void add ( double beta );
  35. void addMap ( const std::map<int, int> & v, double lambda = 1.0 );
  36. void addMap ( const std::map<int, double> & v, double lambda = 1.0 );
  37. void normalize ();
  38. void reinit ( int length );
  39. void restore (std::istream & is, int format = 0);
  40. void store (std::ostream & os, int format = 0) const;
  41. void clear ();
  42. double entropy () const;
  43. void multiply ( const FullVector & v );
  44. void multiply ( double val );
  45. void divide ( const FullVector & v );
  46. double sum () const;
  47. double max () const;
  48. double min () const;
  49. int maxElement () const;
  50. int maxElementExclusive ( int key ) const;
  51. void getSortedIndices ( std::vector<int> & indizes ) const;
  52. double get( size_t i ) const;
  53. inline int size() const { return length; };
  54. inline bool empty() { return length == 0; };
  55. double & operator[] (int i);
  56. void operator= ( const FullVector & v );
  57. const double & operator[] (int i) const;
  58. };
  59. } // namespace
  60. #endif