#ifndef VQCLUSTERINFO_H #define VQCLUSTERINFO_H #include namespace icl{ /// Utiltiy class for accessing meta-information about VQClusters \ingroup G_UTILS /** The dimension of a VQCluster info is equal to the center/ prototype/cluster-count of the top-level VQ2D object. For each prototype/center/cluster the cluster info provides some meta information like cluster mean or clusters major axis (length and angle) **/ class VQClusterInfo{ /// internally used float vector type typedef std::vector fvec; public: /// creates a new cluster info with given dimension VQClusterInfo(int dim=0): m_iDim(0), m_pfCenters(0), /* {{{ open */ m_pfPCAInfos(0), m_pfErrors(0), m_pvecElems(0){ if(dim){ resize(dim); } } /* }}} */ /// Destructor ~VQClusterInfo(){ /* {{{ open */ resize(0); } /* }}} */ /// resets the dimension of this cluster info class /** old data content is lost */ 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; } } /* }}} */ /// adds a data element for given prototype index 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); } /* }}} */ /// clears internal data with 0 void clear(){ /* {{{ open */ for(int i=0;i