#include #include #include "vislearning/math/mathbase/Featuretype.h" using namespace OBJREC; using namespace NICE; using namespace std; FeatureType::FeatureType ( const FeatureType &_ft ) { sv = _ft.sv; v = _ft.v; ft = _ft.ft; } FeatureType::FeatureType ( int f, int dim ) { ft = f; setDim ( dim ); } FeatureType::FeatureType ( SparseVector &tsv ) : sv ( tsv ) { sv = tsv; ft = SPARSEVECTORFEATURE; v.clear(); } FeatureType::FeatureType ( Vector &tv ) //: v(tv) { v.resize ( tv.size() ); for ( int i = 0; i < v.size(); i++ ) { v[i] = tv[i]; } ft = VECTORFEATURE; sv.clear(); } void FeatureType::setDim ( int dim ) { if ( ft == SPARSEVECTORFEATURE ) { sv.setDim ( dim ); } else { v.resize ( dim ); } } double FeatureType::get ( int pos ) const { assert ( pos < getDim() ); if ( ft == SPARSEVECTORFEATURE ) { return sv.get ( pos ); } else { return v[pos]; } } int FeatureType::getType() { return ft; } int FeatureType::getDim() const { if ( ft == SPARSEVECTORFEATURE ) { return sv.getDim(); } else { return ( int ) v.size(); } } const NICE::Vector& FeatureType::getVec() const { return v; } const SparseVector& FeatureType::getSVec() const { return sv; }