Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLMath/src/ICLMath/DynVector.h ** 00010 ** Module : ICLMath ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLUtils/CompatMacros.h> 00034 #include <ICLMath/DynMatrix.h> 00035 00036 namespace icl{ 00037 namespace math{ 00038 00040 template<class T> 00041 struct DynColVector : public DynMatrix<T>{ 00043 DynColVector(const typename DynMatrix<T>::DynMatrixColumn &column): 00044 DynMatrix<T>(column){} 00045 00047 inline DynColVector():DynMatrix<T>(){}; 00048 00050 inline DynColVector(unsigned int dim,const T &initValue=0) throw (InvalidMatrixDimensionException) : 00051 DynMatrix<T> (1,dim,initValue){} 00052 00054 00057 inline DynColVector(unsigned int dim, T *data, bool deepCopy=true) throw (InvalidMatrixDimensionException) : 00058 DynMatrix<T>(1,dim,data,deepCopy){} 00059 00060 00062 inline DynColVector(unsigned int dim, const T *data) throw (InvalidMatrixDimensionException) : 00063 DynMatrix<T>(1,dim,data){} 00064 00066 inline DynColVector(const DynMatrix<T> &other) throw (InvalidMatrixDimensionException): 00067 DynMatrix<T>(other){ 00068 ICLASSERT_THROW(DynMatrix<T>::cols() == 1, 00069 InvalidMatrixDimensionException("DynColVector(DynMatrix): source matrix has more than one column")); 00070 } 00072 inline DynColVector<T> &operator=(const DynMatrix<T> &other) throw (InvalidMatrixDimensionException){ 00073 DynMatrix<T>::operator=(other); 00074 ICLASSERT_THROW(DynMatrix<T>::cols() == 1, 00075 InvalidMatrixDimensionException("DynColVector = DynMatrix: source matrix has more than one column")); 00076 return *this; 00077 } 00079 00080 inline void setBounds(unsigned int dim, bool holdContent=false, const T &initializer=0) throw (InvalidMatrixDimensionException){ 00081 DynMatrix<T>::setBounds(1,dim,holdContent,initializer); 00082 } 00083 00085 inline void setDim(unsigned int dim, bool holdContent= false, const T &initializer=0) throw (InvalidMatrixDimensionException){ 00086 setBounds(dim,holdContent,initializer); 00087 } 00088 }; 00089 00090 template<class T> 00091 struct DynRowVector : public DynMatrix<T>{ 00093 inline DynRowVector():DynMatrix<T>(){} 00094 00096 inline DynRowVector(unsigned int dim,const T &initValue=0) throw (InvalidMatrixDimensionException) : 00097 DynMatrix<T> (dim,1,initValue){} 00098 00100 00103 inline DynRowVector(unsigned int dim, T *data, bool deepCopy=true) throw (InvalidMatrixDimensionException) : 00104 DynMatrix<T>(dim,1,data,deepCopy){} 00105 00106 00108 inline DynRowVector(unsigned int dim,const T *data) throw (InvalidMatrixDimensionException) : 00109 DynMatrix<T>(dim,1,data){} 00110 00112 inline DynRowVector(const DynMatrix<T> &other) throw (InvalidMatrixDimensionException): 00113 DynMatrix<T>(other){ 00114 ICLASSERT_THROW(DynMatrix<T>::rows() == 1, 00115 InvalidMatrixDimensionException("DynRowVector(DynMatrix): source matrix has more than one rows")); 00116 } 00118 inline DynRowVector<T> &operator=(const DynMatrix<T> &other) throw (InvalidMatrixDimensionException){ 00119 DynMatrix<T>::operator=(other); 00120 ICLASSERT_THROW(DynMatrix<T>::rows() == 1, 00121 InvalidMatrixDimensionException("DynRowVector = DynMatrix: source matrix has more than one rows")); 00122 return *this; 00123 } 00124 00126 00127 inline void setBounds(unsigned int dim, bool holdContent=false, const T &initializer=0) throw (InvalidMatrixDimensionException){ 00128 DynMatrix<T>::setBounds(dim,1,holdContent,initializer); 00129 } 00130 00132 inline void setDim(unsigned int dim, bool holdContent= false, const T &initializer=0) throw (InvalidMatrixDimensionException){ 00133 setBounds(dim,holdContent,initializer); 00134 } 00135 00136 }; 00137 } // namespace math 00138 } 00139