$search
00001 #include "../config.h" 00002 #ifdef __MATRIXWRAPPER_EIGEN__ 00003 00004 #ifndef __VECTOR_EIGEN__ 00005 #define __VECTOR_EIGEN__ 00006 00007 #include "matrix_wrapper.h" 00008 #include "vector_wrapper.h" 00009 00010 #include <Eigen/Core> 00011 00012 typedef Eigen::VectorXd EigenColumnVector; 00013 typedef Eigen::RowVectorXd EigenRowVector; 00014 00015 00016 namespace MatrixWrapper 00017 { 00018 00020 class ColumnVector : public EigenColumnVector, public ColumnVector_Wrapper 00021 { 00022 public: 00023 00025 ColumnVector(); 00026 00028 ColumnVector(int nrows); 00029 ColumnVector(int nrows,double value); 00030 00032 ColumnVector(const MyColumnVector& a, const MyColumnVector& b); 00033 00035 virtual ~ColumnVector(); 00036 00038 ColumnVector (const MyColumnVector& a); 00039 00041 ColumnVector (const EigenColumnVector& a); 00042 00043 virtual void resize(int num_rows); 00044 virtual unsigned int rows() const; 00045 virtual unsigned int columns() const; 00046 virtual unsigned int capacity() const; 00047 virtual void assign(int size, double value) ; 00048 virtual ColumnVector vectorAdd(const MyColumnVector& v2) const; 00049 virtual ColumnVector& operator =(const MyColumnVector& a); 00050 virtual ColumnVector& operator =(double a); 00051 00052 virtual MyColumnVector & operator+= (const MyColumnVector& a); 00053 virtual MyColumnVector & operator-= (const MyColumnVector& a); 00054 virtual MyColumnVector operator+ (const MyColumnVector &a) const; 00055 virtual MyColumnVector operator- (const MyColumnVector &a) const; 00056 00057 virtual MyColumnVector& operator+= (double b); 00058 virtual MyColumnVector& operator-= (double b); 00059 virtual MyColumnVector& operator*= (double b); 00060 virtual MyColumnVector& operator/= (double b); 00061 virtual MyColumnVector operator+ (double b) const; 00062 virtual MyColumnVector operator- (double b) const; 00063 virtual MyColumnVector operator* (double b) const; 00064 virtual MyColumnVector operator/ (double b) const; 00065 00067 virtual double operator[](unsigned int i) const 00068 { 00069 //std::cout << "(BOOSTVECTOR) operator[] called " << i << std::endl; 00070 // if (i==0) 00071 // std::cout << "(BOOSTVECTOR) operator[0]" << std::endl; 00072 00073 return (*this)(i+1); 00074 } 00075 00077 virtual double& operator[](unsigned int i) 00078 { 00079 //std::cout << "(BOOSTVECTOR) operator[] called " << i << std::endl; 00080 // if (i==0) 00081 // std::cout << "(BOOSTVECTOR) operator[0]" << std::endl; 00082 return (*this)(i+1); 00083 } 00084 00085 virtual double operator()(unsigned int) const; 00086 virtual bool operator==(const MyColumnVector& a) const; 00087 virtual double& operator()(unsigned int); 00088 virtual MyMatrix operator* (const MyRowVector &a) const; 00089 virtual MyColumnVector sub(int j_start , int j_end) const; 00090 virtual MyRowVector transpose() const; 00091 00092 00093 }; 00094 00096 class RowVector : public EigenRowVector, public RowVector_Wrapper 00097 { 00098 // No private member: We don't add anything. 00099 00100 // Public Members 00101 public: 00102 RowVector(); 00103 RowVector(int ncols); 00104 RowVector(int ncols,double value); 00105 // If you have another constructor in the matrix library you 00106 // want to use, you'll have to redefine it yourself 00107 00108 // Copy constructor 00109 RowVector (const MyRowVector& a); 00110 // Copy constructor for Eigen 00111 RowVector (const EigenRowVector& a); 00112 00113 virtual ~RowVector(); 00114 00115 virtual void resize(int num_cols); 00116 virtual void assign(int size, double value) ; 00117 virtual RowVector vectorAdd(const MyRowVector& v2) const; 00118 virtual unsigned int rows() const; 00119 virtual unsigned int columns() const; 00120 virtual unsigned int capacity() const; 00121 virtual RowVector& operator =(double a); 00122 virtual RowVector& operator =(const MyRowVector& a); 00123 00124 virtual MyRowVector & operator+= (const MyRowVector& a); 00125 virtual MyRowVector & operator-= (const MyRowVector& a); 00126 virtual MyRowVector operator+ (const MyRowVector &a) const; 00127 virtual MyRowVector operator- (const MyRowVector &a) const; 00128 00129 virtual MyRowVector& operator+= (double b); 00130 virtual MyRowVector& operator-= (double b); 00131 virtual MyRowVector& operator*= (double b); 00132 virtual MyRowVector& operator/= (double b); 00133 virtual MyRowVector operator+ (double b) const; 00134 virtual MyRowVector operator- (double b) const; 00135 virtual MyRowVector operator* (double b) const; 00136 virtual MyRowVector operator/ (double b) const; 00137 00138 virtual double operator()(unsigned int) const; 00139 virtual bool operator==(const MyRowVector& a) const; 00140 virtual double& operator()(unsigned int); 00141 virtual MyRowVector sub(int j_start , int j_end) const; 00142 virtual MyColumnVector transpose() const; 00143 virtual double operator*(const MyColumnVector& a) const; 00144 00145 }; 00146 00147 } 00148 00149 #endif 00150 00151 #endif