#include #ifndef VQCLUSTERINFO_H #define VQCLUSTERINFO_H namespace icl{ class VQClusterInfo{ typedef std::vector fvec; public: VQClusterInfo(int dim=0): m_iDim(0), m_pfCenters(0), /* {{{ open */ m_pfPCAInfos(0), m_pfErrors(0), m_pvecElems(0){ if(dim){ resize(dim); } } /* }}} */ ~VQClusterInfo(){ /* {{{ open */ resize(0); } /* }}} */ void resize(int dim){ /* {{{ open */ if(m_iDim == dim) return; m_iDim = dim; if(m_pfCenters){ delete m_pfCenters; delete m_pfPCAInfos; delete m_pfErrors; delete m_pvecElems; } if(dim){ m_pfCenters = new float[dim*2]; m_pfPCAInfos = new float[dim*3]; m_pfErrors = new float[dim]; m_pvecElems = new fvec[dim]; }else{ m_pfCenters = 0; m_pfPCAInfos = 0; m_pfErrors = 0; m_pvecElems = 0; } } /* }}} */ void addElem(int prototypeIndex, float x, float y){ /* {{{ open */ printf("adding index-%d dim-%d \n",prototypeIndex,m_iDim); m_pvecElems[prototypeIndex].push_back(x); m_pvecElems[prototypeIndex].push_back(y); } /* }}} */ void clear(){ /* {{{ open */ for(int i=0;i