matrix_BOOST.h
Go to the documentation of this file.
00001 // $Id: matrix_BOOST.h 27912 2007-04-27 14:25:33Z wmeeusse $
00002 // Copyright (C) 2002 Klaas Gadeyne <first dot last at gmail dot com>
00003 
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation; either version 2.1 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 //
00019 #include "../config.h"
00020 #ifdef __MATRIXWRAPPER_BOOST__
00021 
00022 #ifndef __MATRIX_BOOST__
00023 #define __MATRIX_BOOST__
00024 #include "../../bfl_constants.h"
00025 #include "matrix_wrapper.h"
00026 #include "vector_wrapper.h"
00027 #include <boost/numeric/ublas/matrix.hpp>
00028 #include <boost/numeric/ublas/lu.hpp>
00029 #include <boost/numeric/ublas/symmetric.hpp>
00030 #include <boost/numeric/ublas/io.hpp>
00031 #include <boost/numeric/ublas/lu.hpp>
00032 #include <boost/numeric/ublas/triangular.hpp>
00033 #include <boost/numeric/ublas/storage.hpp>
00034 #include <boost/numeric/ublas/matrix_proxy.hpp>
00035 #include <boost/numeric/ublas/matrix_expression.hpp>
00036 #include <assert.h>
00037 
00038 
00039 typedef boost::numeric::ublas::matrix<double> BoostMatrix;
00040 typedef boost::numeric::ublas::symmetric_matrix<double, boost::numeric::ublas::lower> BoostSymmetricMatrix;
00041 
00042 namespace MatrixWrapper
00043 {
00044 
00046 class Matrix : public BoostMatrix, public Matrix_Wrapper
00047 {
00048  private: // No private members:  We don't add anything.
00049 
00050  public: // Public Members
00051 
00052   // Constructors
00053   Matrix();
00054   Matrix(int m, int n);
00055 
00056   // Destructor
00057   virtual ~Matrix();
00058 
00059   // Copy constructor
00060   Matrix (const MyMatrix& a);
00061   Matrix(const BoostMatrix & a);
00062 
00063   Matrix(int num_rows,const RowVector& v);
00064 
00065   
00066   virtual unsigned int rows() const;
00067   virtual unsigned int columns() const;
00068   virtual double& operator()(unsigned int,unsigned int);
00069   virtual double operator()(unsigned int,unsigned int) const;
00070   virtual RowVector operator[](unsigned int)const;
00071 
00072   virtual bool operator==(const MyMatrix& a) const;
00073 
00074   virtual MyMatrix& operator =(double a);
00075 
00076   virtual MyMatrix& operator +=(double a);
00077   virtual MyMatrix& operator -=(double a);
00078   virtual MyMatrix& operator *=(double b);
00079   virtual MyMatrix& operator /=(double b);
00080   virtual MyMatrix operator+ (double b) const;
00081   virtual MyMatrix operator- (double b) const;
00082   virtual MyMatrix operator* (double b) const;
00083   virtual MyMatrix operator/ (double b) const;
00084 
00085   virtual MyMatrix& operator =(const MySymmetricMatrix& a);
00086   virtual MyMatrix& operator +=(const MyMatrix& a);
00087   virtual MyMatrix& operator -=(const MyMatrix& a);
00088   virtual MyMatrix operator+ (const MyMatrix &a) const;
00089   virtual MyMatrix operator- (const MyMatrix &a) const;
00090   virtual MyMatrix operator* (const MyMatrix &a) const;
00091 
00092   virtual MyColumnVector operator* ( const MyColumnVector &b) const;
00093 
00094   virtual MyRowVector rowCopy(unsigned int r) const;
00095   virtual MyColumnVector columnCopy(unsigned int c) const;
00096 
00097   virtual void resize(unsigned int i, unsigned int j,
00098                       bool copy=true, bool initialize=true);
00099   virtual MyMatrix inverse() const;
00100   virtual MyMatrix transpose() const;
00101   virtual double determinant() const;
00102   virtual int convertToSymmetricMatrix(MySymmetricMatrix& sym);
00103   virtual MyMatrix sub(int i_start, int i_end, int j_start , int j_end) const;
00104 
00105 };
00106 
00107 class SymmetricMatrix : public BoostSymmetricMatrix, public SymmetricMatrix_Wrapper
00108 {
00109  private: //
00110 
00111  public: //
00112   // Constructors
00113   SymmetricMatrix();
00114   SymmetricMatrix(int n);
00115 
00116   // Copy constructors
00117   SymmetricMatrix(const MySymmetricMatrix& a);
00118   SymmetricMatrix(const BoostSymmetricMatrix & a);
00119 
00120   SymmetricMatrix(int num_rows,const RowVector& v);
00121 
00122   // Destructor
00123   virtual ~SymmetricMatrix();
00124 
00125   virtual unsigned int rows() const;
00126   virtual unsigned int columns() const;
00127   virtual MySymmetricMatrix inverse() const;
00128   virtual MySymmetricMatrix transpose() const;
00129   virtual double determinant() const;
00130 
00131   virtual double& operator()(unsigned int,unsigned int);
00132   virtual double operator()(unsigned int,unsigned int) const;
00133   virtual RowVector operator[](unsigned int)const;
00134   virtual bool operator==(const MySymmetricMatrix& a) const;
00135 
00136   virtual MySymmetricMatrix& operator=(double a);
00137 
00138   virtual MySymmetricMatrix& operator +=(double a);
00139   virtual MySymmetricMatrix& operator -=(double a);
00140   virtual MySymmetricMatrix& operator *=(double b);
00141   virtual MySymmetricMatrix& operator /=(double b);
00142   virtual MySymmetricMatrix  operator + (double b) const;
00143   virtual MySymmetricMatrix  operator - (double b) const;
00144   virtual MySymmetricMatrix  operator * (double b) const;
00145   virtual MySymmetricMatrix  operator / (double b) const;
00146 
00147   virtual MyRowVector rowCopy(unsigned int r) const;
00148 
00149   virtual MyMatrix& operator +=(const MyMatrix& a);
00150   virtual MyMatrix& operator -=(const MyMatrix& a);
00151   virtual MyMatrix operator  + (const MyMatrix &a) const;
00152   virtual MyMatrix operator  - (const MyMatrix &a) const;
00153   virtual MyMatrix operator  * (const MyMatrix &a) const;
00154 
00155   virtual MySymmetricMatrix& operator +=(const MySymmetricMatrix& a);
00156   virtual MySymmetricMatrix& operator -=(const MySymmetricMatrix& a);
00157   virtual MySymmetricMatrix  operator + (const MySymmetricMatrix &a) const;
00158   virtual MySymmetricMatrix  operator - (const MySymmetricMatrix &a) const;
00159   virtual MyMatrix  operator * (const MySymmetricMatrix& a) const;
00160 
00161   virtual MyColumnVector operator* (const MyColumnVector &b) const;
00162   virtual void multiply (const MyColumnVector &b, MyColumnVector &result) const;
00163 
00164   virtual void resize(unsigned int i, bool copy=true, bool initialize=true);
00165   virtual MyMatrix sub(int i_start, int i_end, int j_start , int j_end) const;
00166 
00167 };
00168 
00169 }
00170 
00171 #endif
00172 
00173 #endif


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Fri Aug 28 2015 10:10:21