Bayesian Filtering Library  Generated from SVN r
matrix_wrapper.h
1 // $Id$
2 // Copyright (C) 2002 Klaas Gadeyne <first dot last at gmail dot com>
3 
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 2.1 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 #ifndef __MATRIX_WRAPPER__
20 #define __MATRIX_WRAPPER__
21 
22 
23 
24 // define
25 #define use_namespace
26 #define MyMatrix MatrixWrapper::Matrix
27 #define MyColumnVector MatrixWrapper::ColumnVector
28 #define MyRowVector MatrixWrapper::RowVector
29 #define MySymmetricMatrix MatrixWrapper::SymmetricMatrix
30 
31 namespace MatrixWrapper{
32 
33 class Matrix;
34 class ColumnVector;
35 class RowVector;
36 class SymmetricMatrix;
37 
40 {
41 public:
42 
45 
47  virtual ~Matrix_Wrapper() {};
48 
50  virtual unsigned int size() const = 0;
51 
53  virtual unsigned int capacity() const = 0;
54 
56  virtual unsigned int rows() const = 0;
57 
59  virtual unsigned int columns() const = 0;
60 
62  virtual double& operator()(unsigned int,unsigned int) = 0;
63 
65  virtual double operator()(unsigned int,unsigned int) const = 0;
66 
68  virtual bool operator==(const MyMatrix& a) const = 0;
69 
70 
72  virtual MyMatrix& operator =(double a) = 0;
73 
74 
75 
77  virtual MyMatrix& operator +=(double a) = 0;
78 
80  virtual MyMatrix& operator -=(double a) = 0;
81 
83  virtual MyMatrix& operator *=(double b) = 0;
84 
86  virtual MyMatrix& operator /=(double b) = 0;
87 
89  virtual MyMatrix operator+ (double b) const = 0;
90 
92  virtual MyMatrix operator- (double b) const = 0;
93 
95  virtual MyMatrix operator* (double b) const = 0;
96 
98  virtual MyMatrix operator/ (double b) const = 0;
99 
101  virtual MyMatrix& operator =(const MySymmetricMatrix& a) = 0;
102 
104  virtual MyMatrix& operator +=(const MyMatrix& a) = 0;
105 
107  virtual MyMatrix& operator -=(const MyMatrix& a) = 0;
108 
110  virtual MyMatrix operator+ (const MyMatrix &a) const = 0;
111 
113  virtual MyMatrix operator- (const MyMatrix &a) const = 0;
114 
116  virtual MyMatrix operator* (const MyMatrix &a) const = 0;
117 
118 
119 
121  virtual MyColumnVector operator* ( const MyColumnVector &b) const = 0;
122 
123 
125  virtual MyRowVector rowCopy(unsigned int r) const = 0;
126 
128  virtual MyColumnVector columnCopy(unsigned int c) const = 0;
129 
131  virtual void resize(unsigned int i, unsigned int j,
132  bool copy=true, bool initialize=true) = 0;
133 
135  virtual MyMatrix pseudoinverse(double epsilon = 0.01 ) const;
136 
138  virtual MyMatrix inverse() const = 0;
139 
141  virtual MyMatrix transpose() const = 0;
142 
144  virtual double determinant() const = 0;
145 
147 
150  virtual int convertToSymmetricMatrix(MySymmetricMatrix& sym) = 0;
151 
153  virtual MyMatrix sub(int i_start, int i_end, int j_start , int j_end) const = 0;
154 
156  virtual bool SVD(MyColumnVector& D, MyMatrix& U, MyMatrix& V) const ;
157 
158  double PYTHAG(double a,double b) const;
159 
160  double SIGN(double a,double b) const;
161 
162 }; // class Matrix_Wrapper
163 
164 
167 {
168 public:
171 
174 
176  virtual unsigned int size() const = 0;
177 
179  virtual unsigned int capacity() const = 0;
180 
181 
183  virtual unsigned int rows() const = 0;
184 
186  virtual unsigned int columns() const = 0;
187 
189  virtual double& operator()(unsigned int,unsigned int) = 0;
190 
192  virtual double operator()(unsigned int,unsigned int) const = 0;
193 
195  virtual bool operator==(const MySymmetricMatrix& a) const = 0;
196 
198  virtual MySymmetricMatrix& operator =(double a) = 0;
199 
200 
201 
203  virtual MySymmetricMatrix& operator +=(double a) = 0;
204 
206  virtual MySymmetricMatrix& operator -=(double a) = 0;
207 
209  virtual MySymmetricMatrix& operator *=(double b) = 0;
210 
212  virtual MySymmetricMatrix& operator /=(double b) = 0;
213 
215  virtual MySymmetricMatrix operator+ (double b) const = 0;
216 
218  virtual MySymmetricMatrix operator- (double b) const = 0;
219 
221  virtual MySymmetricMatrix operator* (double b) const = 0;
222 
224  virtual MySymmetricMatrix operator/ (double b) const = 0;
225 
226 
228  virtual MyMatrix& operator +=(const MyMatrix& a) = 0;
229 
231  virtual MyMatrix& operator -=(const MyMatrix& a) = 0;
232 
234  virtual MyMatrix operator+ (const MyMatrix &a) const = 0;
235 
237  virtual MyMatrix operator- (const MyMatrix &a) const = 0;
238 
240  virtual MyMatrix operator* (const MyMatrix &a) const = 0;
241 
243  virtual MySymmetricMatrix& operator +=(const MySymmetricMatrix& a) = 0;
244 
246  virtual MySymmetricMatrix& operator -=(const MySymmetricMatrix& a) = 0;
247 
249  virtual MySymmetricMatrix operator+ (const MySymmetricMatrix &a) const = 0;
250 
252  virtual MySymmetricMatrix operator- (const MySymmetricMatrix &a) const= 0;
253 
255  virtual MyMatrix operator* (const MySymmetricMatrix &a) const = 0;
256 
257 
258 
260  virtual ColumnVector operator* ( const MyColumnVector &b) const = 0;
261 
263  virtual void multiply( const MyColumnVector &b, MyColumnVector &result) const = 0;
264 
266  virtual void resize(unsigned int i, bool copy=true, bool initialize=true) = 0;
267 
269  virtual MySymmetricMatrix inverse() const = 0;
270 
272  virtual MySymmetricMatrix transpose() const = 0;
273 
275  virtual double determinant() const = 0;
276 
278  virtual MyMatrix sub(int i_start, int i_end, int j_start , int j_end) const = 0;
279 
281  virtual bool cholesky_semidefinite(MyMatrix& m) const ;
282 
283 }; //class SymmetricMatrix_Wrapper
284 
285 
286 } // namespace
287 
288 
289 
290 // include
291 #include "matrix_NEWMAT.h"
292 #include "matrix_BOOST.h"
293 #include "matrix_EIGEN.h"
294 
295 
296 #endif // __MATRIX_WRAPPER__
MatrixWrapper::Matrix_Wrapper::columns
virtual unsigned int columns() const =0
Ask Number of Columns.
MatrixWrapper::SymmetricMatrix_Wrapper::operator+=
virtual MySymmetricMatrix & operator+=(double a)=0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::rowCopy
virtual MyRowVector rowCopy(unsigned int r) const =0
Get row from matrix.
MatrixWrapper::SymmetricMatrix_Wrapper::operator/=
virtual MySymmetricMatrix & operator/=(double b)=0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::operator-=
virtual MyMatrix & operator-=(double a)=0
MATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::pseudoinverse
virtual MyMatrix pseudoinverse(double epsilon=0.01) const
get pseudoinverse
MatrixWrapper::SymmetricMatrix_Wrapper::multiply
virtual void multiply(const MyColumnVector &b, MyColumnVector &result) const =0
SYMMETRICMATRIX - VECTOR operator.
MatrixWrapper::Matrix_Wrapper::operator+
virtual MyMatrix operator+(double b) const =0
MATRIX - SCALAR operator.
MatrixWrapper::SymmetricMatrix_Wrapper::inverse
virtual MySymmetricMatrix inverse() const =0
get inverse
MatrixWrapper::SymmetricMatrix_Wrapper::rows
virtual unsigned int rows() const =0
Ask Number of Rows.
MatrixWrapper::Matrix_Wrapper::determinant
virtual double determinant() const =0
get determinant
MatrixWrapper::SymmetricMatrix_Wrapper::operator()
virtual double & operator()(unsigned int, unsigned int)=0
Operator ()
MatrixWrapper::SymmetricMatrix_Wrapper::operator-=
virtual MySymmetricMatrix & operator-=(double a)=0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::SymmetricMatrix_Wrapper::operator=
virtual MySymmetricMatrix & operator=(double a)=0
Set all elements of the Matrix equal to a.
MatrixWrapper::Matrix_Wrapper::operator*
virtual MyMatrix operator*(double b) const =0
MATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::operator+=
virtual MyMatrix & operator+=(double a)=0
MATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper
Class Matrixwrapper.
Definition: matrix_wrapper.h:39
MatrixWrapper::ColumnVector
Wrapper class for ColumnVectors (Boost implementation)
Definition: vector_BOOST.h:41
MatrixWrapper::SymmetricMatrix_Wrapper::capacity
virtual unsigned int capacity() const =0
Ask Number of Rows.
MatrixWrapper::Matrix_Wrapper::convertToSymmetricMatrix
virtual int convertToSymmetricMatrix(MySymmetricMatrix &sym)=0
Turn matrix into Symmetric one.
MatrixWrapper::SymmetricMatrix_Wrapper::transpose
virtual MySymmetricMatrix transpose() const =0
get transpose
MatrixWrapper::Matrix_Wrapper::operator-
virtual MyMatrix operator-(double b) const =0
MATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::~Matrix_Wrapper
virtual ~Matrix_Wrapper()
Destructor.
Definition: matrix_wrapper.h:47
MatrixWrapper::SymmetricMatrix_Wrapper::cholesky_semidefinite
virtual bool cholesky_semidefinite(MyMatrix &m) const
Cholesky Decomposition for semidefinite matrices.
MatrixWrapper::SymmetricMatrix_Wrapper::columns
virtual unsigned int columns() const =0
Ask Number of Columns.
MatrixWrapper::SymmetricMatrix_Wrapper::operator==
virtual bool operator==(const MySymmetricMatrix &a) const =0
Operator ==.
MatrixWrapper::Matrix_Wrapper::sub
virtual MyMatrix sub(int i_start, int i_end, int j_start, int j_end) const =0
get sub matrix
MatrixWrapper::Matrix_Wrapper::size
virtual unsigned int size() const =0
Ask Number of Rows.
MatrixWrapper::Matrix_Wrapper::inverse
virtual MyMatrix inverse() const =0
get inverse
MatrixWrapper::Matrix_Wrapper::operator=
virtual MyMatrix & operator=(double a)=0
Set all elements of the Matrix equal to a.
MatrixWrapper::Matrix_Wrapper::transpose
virtual MyMatrix transpose() const =0
get transpose
MatrixWrapper::Matrix_Wrapper::operator()
virtual double & operator()(unsigned int, unsigned int)=0
Operator ()
MatrixWrapper::Matrix_Wrapper::columnCopy
virtual MyColumnVector columnCopy(unsigned int c) const =0
Get column from matrix.
MatrixWrapper::Matrix_Wrapper::operator/=
virtual MyMatrix & operator/=(double b)=0
MATRIX - SCALAR operator.
MatrixWrapper::SymmetricMatrix_Wrapper::SymmetricMatrix_Wrapper
SymmetricMatrix_Wrapper()
Constructor.
Definition: matrix_wrapper.h:170
MatrixWrapper::SymmetricMatrix_Wrapper::resize
virtual void resize(unsigned int i, bool copy=true, bool initialize=true)=0
resize symmetric matrix
MatrixWrapper::SymmetricMatrix_Wrapper::operator-
virtual MySymmetricMatrix operator-(double b) const =0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::operator/
virtual MyMatrix operator/(double b) const =0
MATRIX - SCALAR operator.
MatrixWrapper::SymmetricMatrix_Wrapper::determinant
virtual double determinant() const =0
get determinant
MatrixWrapper::SymmetricMatrix_Wrapper::operator*
virtual MySymmetricMatrix operator*(double b) const =0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::SymmetricMatrix_Wrapper::size
virtual unsigned int size() const =0
Ask Number of Rows.
MatrixWrapper::Matrix_Wrapper::SVD
virtual bool SVD(MyColumnVector &D, MyMatrix &U, MyMatrix &V) const
SVD Decomposition (for pseudo-inverse properties)
MatrixWrapper::SymmetricMatrix_Wrapper::operator+
virtual MySymmetricMatrix operator+(double b) const =0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::SymmetricMatrix_Wrapper::operator/
virtual MySymmetricMatrix operator/(double b) const =0
SYMMETRICMATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::resize
virtual void resize(unsigned int i, unsigned int j, bool copy=true, bool initialize=true)=0
resize matrix
MatrixWrapper::SymmetricMatrix_Wrapper
Class SymmetricMatrixWrapper.
Definition: matrix_wrapper.h:166
MatrixWrapper::Matrix_Wrapper::Matrix_Wrapper
Matrix_Wrapper()
Constructor.
Definition: matrix_wrapper.h:44
MatrixWrapper::Matrix_Wrapper::operator==
virtual bool operator==(const MyMatrix &a) const =0
Operator ==.
MatrixWrapper::SymmetricMatrix_Wrapper::sub
virtual MyMatrix sub(int i_start, int i_end, int j_start, int j_end) const =0
get sub matrix
MatrixWrapper::Matrix_Wrapper::rows
virtual unsigned int rows() const =0
Ask Number of Rows.
MatrixWrapper::Matrix_Wrapper::operator*=
virtual MyMatrix & operator*=(double b)=0
MATRIX - SCALAR operator.
MatrixWrapper::Matrix_Wrapper::capacity
virtual unsigned int capacity() const =0
Ask Number of Rows.
MatrixWrapper::SymmetricMatrix_Wrapper::~SymmetricMatrix_Wrapper
virtual ~SymmetricMatrix_Wrapper()
Destructor.
Definition: matrix_wrapper.h:173
MatrixWrapper::SymmetricMatrix_Wrapper::operator*=
virtual MySymmetricMatrix & operator*=(double b)=0
SYMMETRICMATRIX - SCALAR operator.