$search
00001 #include "../config.h" 00002 #ifdef __MATRIXWRAPPER_EIGEN__ 00003 00004 #ifndef __MATRIX_EIGEN__ 00005 #define __MATRIX_EIGEN__ 00006 #include "../../bfl_constants.h" 00007 #include "matrix_wrapper.h" 00008 #include "vector_wrapper.h" 00009 00010 #include <Eigen/Core> 00011 #include <assert.h> 00012 00013 typedef Eigen::MatrixXd EigenMatrix; 00014 typedef Eigen::MatrixXd EigenSymmetricMatrix; 00015 typedef Eigen::MatrixXd::ConstSelfAdjointViewReturnType<Eigen::Upper>::Type EigenSymmetricView; 00016 00017 namespace MatrixWrapper 00018 { 00019 00021 class Matrix : public EigenMatrix, public Matrix_Wrapper 00022 { 00023 private: // No private members: We don't add anything. 00024 00025 public: // Public Members 00026 00027 // Constructors 00028 Matrix(); 00029 Matrix(int m, int n); 00030 00031 // Destructor 00032 virtual ~Matrix(); 00033 00034 // Copy constructor 00035 Matrix (const MyMatrix& a); 00036 Matrix(const EigenMatrix & a); 00037 00038 Matrix(int num_rows,const RowVector& v); 00039 00040 00041 virtual unsigned int size() const; 00042 virtual unsigned int capacity() const; 00043 virtual unsigned int rows() const; 00044 virtual unsigned int columns() const; 00045 virtual double& operator()(unsigned int,unsigned int); 00046 virtual double operator()(unsigned int,unsigned int) const; 00047 virtual RowVector operator[](unsigned int)const; 00048 00049 virtual bool operator==(const MyMatrix& a) const; 00050 00051 virtual MyMatrix& operator =(double a); 00052 00053 virtual MyMatrix& operator +=(double a); 00054 virtual MyMatrix& operator -=(double a); 00055 virtual MyMatrix& operator *=(double b); 00056 virtual MyMatrix& operator /=(double b); 00057 virtual MyMatrix operator+ (double b) const; 00058 virtual MyMatrix operator- (double b) const; 00059 virtual MyMatrix operator* (double b) const; 00060 virtual MyMatrix operator/ (double b) const; 00061 00062 virtual MyMatrix& operator =(const MySymmetricMatrix& a); 00063 virtual MyMatrix& operator +=(const MyMatrix& a); 00064 virtual MyMatrix& operator -=(const MyMatrix& a); 00065 virtual MyMatrix operator+ (const MyMatrix &a) const; 00066 virtual MyMatrix operator- (const MyMatrix &a) const; 00067 virtual MyMatrix operator* (const MyMatrix &a) const; 00068 00069 virtual MyColumnVector operator* ( const MyColumnVector &b) const; 00070 00071 virtual MyRowVector rowCopy(unsigned int r) const; 00072 virtual MyColumnVector columnCopy(unsigned int c) const; 00073 00074 virtual void resize(unsigned int i, unsigned int j, 00075 bool copy=true, bool initialize=true); 00076 virtual MyMatrix inverse() const; 00077 virtual MyMatrix transpose() const; 00078 virtual double determinant() const; 00079 virtual int convertToSymmetricMatrix(MySymmetricMatrix& sym); 00080 virtual MyMatrix sub(int i_start, int i_end, int j_start , int j_end) const; 00081 00082 }; 00083 00084 class SymmetricMatrix : public EigenSymmetricMatrix, public SymmetricMatrix_Wrapper 00085 { 00086 private: // 00087 00088 public: // 00089 // Constructors 00090 SymmetricMatrix(); 00091 SymmetricMatrix(int n); 00092 00093 // Copy constructors 00094 SymmetricMatrix(const MySymmetricMatrix& a); 00095 SymmetricMatrix(const EigenSymmetricMatrix& a); 00096 SymmetricMatrix(const EigenSymmetricView & a); 00097 00098 SymmetricMatrix(int num_rows,const RowVector& v); 00099 00100 // Destructor 00101 virtual ~SymmetricMatrix(); 00102 00103 virtual unsigned int size() const; 00104 virtual unsigned int capacity() const; 00105 virtual unsigned int rows() const; 00106 virtual unsigned int columns() const; 00107 virtual MySymmetricMatrix inverse() const; 00108 virtual MySymmetricMatrix transpose() const; 00109 virtual double determinant() const; 00110 00111 virtual double& operator()(unsigned int,unsigned int); 00112 virtual double operator()(unsigned int,unsigned int) const; 00113 virtual RowVector operator[](unsigned int)const; 00114 virtual bool operator==(const MySymmetricMatrix& a) const; 00115 00116 virtual MySymmetricMatrix& operator=(double a); 00117 00118 virtual MySymmetricMatrix& operator +=(double a); 00119 virtual MySymmetricMatrix& operator -=(double a); 00120 virtual MySymmetricMatrix& operator *=(double b); 00121 virtual MySymmetricMatrix& operator /=(double b); 00122 virtual MySymmetricMatrix operator + (double b) const; 00123 virtual MySymmetricMatrix operator - (double b) const; 00124 virtual MySymmetricMatrix operator * (double b) const; 00125 virtual MySymmetricMatrix operator / (double b) const; 00126 00127 virtual MyRowVector rowCopy(unsigned int r) const; 00128 00129 virtual MyMatrix& operator +=(const MyMatrix& a); 00130 virtual MyMatrix& operator -=(const MyMatrix& a); 00131 virtual MyMatrix operator + (const MyMatrix &a) const; 00132 virtual MyMatrix operator - (const MyMatrix &a) const; 00133 virtual MyMatrix operator * (const MyMatrix &a) const; 00134 00135 virtual MySymmetricMatrix& operator +=(const MySymmetricMatrix& a); 00136 virtual MySymmetricMatrix& operator -=(const MySymmetricMatrix& a); 00137 virtual MySymmetricMatrix operator + (const MySymmetricMatrix &a) const; 00138 virtual MySymmetricMatrix operator - (const MySymmetricMatrix &a) const; 00139 virtual MyMatrix operator * (const MySymmetricMatrix& a) const; 00140 00141 virtual MyColumnVector operator* (const MyColumnVector &b) const; 00142 virtual void multiply (const MyColumnVector &b, MyColumnVector &result) const; 00143 00144 virtual void resize(unsigned int i, bool copy=true, bool initialize=true); 00145 virtual MyMatrix sub(int i_start, int i_end, int j_start , int j_end) const; 00146 00147 }; 00148 00149 } 00150 00151 #endif 00152 00153 #endif