Image Component Library (ICL)
DynVector.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/DynVector.h **
10 ** Module : ICLMath **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLMath/DynMatrix.h>
35 
36 namespace icl{
37  namespace math{
38 
40  template<class T>
41  struct DynColVector : public DynMatrix<T>{
44  DynMatrix<T>(column){}
45 
47  inline DynColVector():DynMatrix<T>(){};
48 
50  inline DynColVector(unsigned int dim,const T &initValue=0) :
51  DynMatrix<T> (1,dim,initValue){}
52 
54 
57  inline DynColVector(unsigned int dim, T *data, bool deepCopy=true) :
58  DynMatrix<T>(1,dim,data,deepCopy){}
59 
60 
62  inline DynColVector(unsigned int dim, const T *data) :
63  DynMatrix<T>(1,dim,data){}
64 
66  inline DynColVector(const DynMatrix<T> &other) :
67  DynMatrix<T>(other){
69  InvalidMatrixDimensionException("DynColVector(DynMatrix): source matrix has more than one column"));
70  }
72  inline DynColVector<T> &operator=(const DynMatrix<T> &other) {
75  InvalidMatrixDimensionException("DynColVector = DynMatrix: source matrix has more than one column"));
76  return *this;
77  }
79 
80  inline void setBounds(unsigned int dim, bool holdContent=false, const T &initializer=0) {
81  DynMatrix<T>::setBounds(1,dim,holdContent,initializer);
82  }
83 
85  inline void setDim(unsigned int dim, bool holdContent= false, const T &initializer=0) {
86  setBounds(dim,holdContent,initializer);
87  }
88  };
89 
90  template<class T>
91  struct DynRowVector : public DynMatrix<T>{
93  inline DynRowVector():DynMatrix<T>(){}
94 
96  inline DynRowVector(unsigned int dim,const T &initValue=0) :
97  DynMatrix<T> (dim,1,initValue){}
98 
100 
103  inline DynRowVector(unsigned int dim, T *data, bool deepCopy=true) :
104  DynMatrix<T>(dim,1,data,deepCopy){}
105 
106 
108  inline DynRowVector(unsigned int dim,const T *data) :
109  DynMatrix<T>(dim,1,data){}
110 
112  inline DynRowVector(const DynMatrix<T> &other) :
113  DynMatrix<T>(other){
115  InvalidMatrixDimensionException("DynRowVector(DynMatrix): source matrix has more than one rows"));
116  }
118  inline DynRowVector<T> &operator=(const DynMatrix<T> &other) {
121  InvalidMatrixDimensionException("DynRowVector = DynMatrix: source matrix has more than one rows"));
122  return *this;
123  }
124 
126 
127  inline void setBounds(unsigned int dim, bool holdContent=false, const T &initializer=0) {
128  DynMatrix<T>::setBounds(dim,1,holdContent,initializer);
129  }
130 
132  inline void setDim(unsigned int dim, bool holdContent= false, const T &initializer=0) {
133  setBounds(dim,holdContent,initializer);
134  }
135 
136  };
137  } // namespace math
138 }
139 
DynColVector(const typename DynMatrix< T >::DynMatrixColumn &column)
creates a column vector from given matrix column
Definition: DynVector.h:43
DynColVector(unsigned int dim, const T *data)
Creates column vector with given data pointer and dimsion (const version: deepCopy only)
Definition: DynVector.h:62
DynColVector(const DynMatrix< T > &other)
Default copy constructor (the source matrix column count must be 'one')
Definition: DynVector.h:66
undocument this line if you encounter any issues!
Definition: Any.h:37
Definition: DynVector.h:91
DynRowVector(unsigned int dim, const T &initValue=0)
Creates a row vector with given dimension (and optional initialValue)
Definition: DynVector.h:96
DynMatrix & operator=(const DynMatrix &other)
Assignment operator (using deep/shallow-copy)
Definition: DynMatrix.h:159
Highly flexible and optimized matrix class implementation.
Definition: DynMatrix.h:81
DynColVector< T > & operator=(const DynMatrix< T > &other)
assignment operator (the rvalue's column count must be one)
Definition: DynVector.h:72
void setBounds(unsigned int dim, bool holdContent=false, const T &initializer=0)
adapts the vector dimension
Definition: DynVector.h:127
Special linear algebra exception type .
Definition: DynMatrix.h:56
DynRowVector(const DynMatrix< T > &other)
Default copy constructor (the source matrix row count must be 'one')
Definition: DynVector.h:112
DynColVector()
Default empty constructor creates a null-vector.
Definition: DynVector.h:47
DynRowVector()
Default empty constructor creates a null-vector.
Definition: DynVector.h:93
void setBounds(unsigned int dim, bool holdContent=false, const T &initializer=0)
adapts the vector dimension
Definition: DynVector.h:80
unsigned int dim() const
matrix dimension (width*height) or (cols*rows)
Definition: DynMatrix.h:483
Extension class for the DynMatrix<T> template, that restricts the the matrix column count to 'one'.
Definition: DynVector.h:41
void setBounds(unsigned int cols, unsigned int rows, bool holdContent=false, const T &initializer=0)
resets matrix dimensions
Definition: DynMatrix.h:179
void setDim(unsigned int dim, bool holdContent=false, const T &initializer=0)
adapts the vector dimension
Definition: DynVector.h:85
DynRowVector(unsigned int dim, const T *data)
Creates column vector with given data pointer and dimsion (const version: deepCopy only)
Definition: DynVector.h:108
DynColVector(unsigned int dim, T *data, bool deepCopy=true)
Create a column vector with given data.
Definition: DynVector.h:57
void setDim(unsigned int dim, bool holdContent=false, const T &initializer=0)
adapts the vector dimension
Definition: DynVector.h:132
DynRowVector(unsigned int dim, T *data, bool deepCopy=true)
Create a row vector with given data.
Definition: DynVector.h:103
#define ICLASSERT_THROW(X, OBJ)
Definition: Macros.h:155
DynColVector(unsigned int dim, const T &initValue=0)
Creates a column vector with given dimension (and optional initialValue)
Definition: DynVector.h:50
DynRowVector< T > & operator=(const DynMatrix< T > &other)
assignment operator (the rvalue's column count must be one)
Definition: DynVector.h:118
T * data()
internal data pointer
Definition: DynMatrix.h:477
Internally used Utility structure referencing a matrix column shallowly.
Definition: DynMatrix.h:643