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

#include <iostream>

#include "VectorFeature.h"
#include "vislearning/cbaselib/FeaturePool.h"

using namespace OBJREC;

using namespace std;

using namespace NICE;

/** simple destructor */
VectorFeature::~VectorFeature()
{
}

double VectorFeature::val( const Example *example ) const
{
    return (*(example->vec))[feature_index];
}

void VectorFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
{
    for ( int i = 0 ; i < dimension ; i++ )
    {
		VectorFeature *f = new VectorFeature ( dimension );
		f->feature_index = i;
		featurePool.addFeature(f, 1.0 / dimension);
    }
}

Feature *VectorFeature::clone() const
{
    VectorFeature *f = new VectorFeature( dimension );
    f->feature_index = feature_index;
    return f;
}

Feature *VectorFeature::generateFirstParameter () const
{
    return clone();
}

void VectorFeature::restore (istream & is, int format)
{
    is >> feature_index;
}

void VectorFeature::store (ostream & os, int format) const
{
    os << "VECTORFEATURE "
       << feature_index;
}

void VectorFeature::clear ()
{
}

void VectorFeature::getStump ( int & _feature_index, int & _dimension ) const
{
    _feature_index = feature_index;
    _dimension = dimension;
}
