/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2012 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : include/ICLMath/VQClusterInfo.h ** ** Module : ICLMath ** ** Authors: Christof Elbrechter ** ** ** ** ** ** Commercial License ** ** ICL can be used commercially, please refer to our website ** ** www.iclcv.org for more details. ** ** ** ** GNU General Public License Usage ** ** Alternatively, this file may be used under the terms of the ** ** GNU General Public License version 3.0 as published by the ** ** Free Software Foundation and appearing in the file LICENSE.GPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the GNU General Public License ** ** version 3.0 requirements will be met: ** ** http://www.gnu.org/copyleft/gpl.html. ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** *********************************************************************/ #pragma once #include namespace icl{ namespace math{ /// 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