/**
* @file KMeansOnline.h
* @brief online kmeans clustering
* @author Erik Rodner
* @date 02/13/2008

*/
#ifndef KMEANSONLINEINCLUDE
#define KMEANSONLINEINCLUDE

#include "core/vector/VectorT.h"
#include "core/vector/MatrixT.h"

#include "core/basics/Config.h"
#include "ClusterOnline.h"
#include "vislearning/cbaselib/Example.h"


namespace OBJREC
{

/** online kmeans clustering */
class KMeansOnline : public ClusterOnline
{

  protected:
    size_t numClusters;
    double gamma;

  public:

    /** simple constructor */
    KMeansOnline ( size_t numClusters, double gamma = 1.0 );

    /** simple destructor */
    virtual ~KMeansOnline();

    int updateClusters ( const NICE::Vector & x );
    void init ();

    /**
     * Cluster algorithm using examples
     * @param ex input examples
     */
    void cluster ( const Examples &ex );

    /**
     * returns the distance to the centre of each cluster
     * @param vin input vector
     * @param dist distance
     * @param size how much centres should considered
     * @param hard use a hard assignment (all values = 1 or 0) or not
      */
    void getDist ( const NICE::Vector &vin, NICE::SparseVector &dist, int size = 1, bool hard = false );
};


} // namespace

#endif
