/**
* @file FullVector.h
* @brief non sparse vector
* @author Erik Rodner
* @date 05/11/2008

*/
#ifndef FullVectorINCLUDE
#define FullVectorINCLUDE


#include <vector>
#include <map>
#include <iostream>

#include "core/basics/Persistent.h"


namespace OBJREC {

/** non sparse vector */
class FullVector : public NICE::Persistent
{

  protected:

  public:

    double *data;
    int length;

    FullVector ( const std::map<int, double> & mymap );
    FullVector ( const std::map<short, double> & mymap );
    /**
     * Creates a vector with specified size (values will be randomized initialized)
     * @param length
     */
    FullVector ( int length );
    FullVector ();
    FullVector ( const FullVector & v );
    ~FullVector ();

    void set ( double val );

    void add ( const FullVector & v );
    void add ( const FullVector & v, double lambda );
    void add ( double beta );

    void addMap ( const std::map<int, int> & v, double lambda = 1.0 );
    void addMap ( const std::map<int, double> & v, double lambda = 1.0 );

    void normalize ();

    void reinit ( int length );

    void restore ( std::istream & is, int format = 0 );
    void store ( std::ostream & os, int format = 0 ) const;
    void clear ();

    double entropy () const;

    void multiply ( const FullVector & v );
    void multiply ( double val );
    void divide ( const FullVector & v );
    double sum () const;

    double max () const;
    double min () const;
    int maxElement () const;
    int maxElementExclusive ( int key ) const;
    void getSortedIndices ( std::vector<int> & indizes ) const;

    double get ( size_t i ) const;

    inline int size() const {
      return length;
    };
    inline bool empty() {
      return length == 0;
    };

    double & operator[] ( int i );
    void operator= ( const FullVector & v );
    const double & operator[] ( int i ) const;

};


} // namespace

#endif
