vector_BOOST.h
Go to the documentation of this file.
00001 // $Id: vector_BOOST.h 27906 2007-04-27 11:50:53Z 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 
00020 #include "../config.h"
00021 #ifdef __MATRIXWRAPPER_BOOST__
00022 
00023 #ifndef __VECTOR_BOOST__
00024 #define __VECTOR_BOOST__
00025 
00026 #include "matrix_wrapper.h"
00027 #include "vector_wrapper.h"
00028 #include <boost/numeric/ublas/vector.hpp>
00029 #include <boost/numeric/ublas/vector_proxy.hpp>
00030 #include <boost/numeric/ublas/io.hpp>
00031 
00032 
00033 #define BoostColumnVector boost::numeric::ublas::vector<double>
00034 #define BoostRowVector    boost::numeric::ublas::vector<double>
00035 
00036 
00037 namespace MatrixWrapper
00038 {
00039 
00041 class ColumnVector : public BoostColumnVector, public ColumnVector_Wrapper
00042 {
00043 public:
00044 
00046   ColumnVector();
00047 
00049   ColumnVector(int nrows);
00050   ColumnVector(int nrows,double value);
00051 
00053   ColumnVector(const MyColumnVector& a, const MyColumnVector& b);
00054 
00056   virtual ~ColumnVector();
00057 
00059   ColumnVector (const MyColumnVector& a);
00060 
00062   ColumnVector (const BoostColumnVector& a);
00063 
00064   virtual void resize(int num_rows);
00065   virtual unsigned int rows() const;
00066   virtual unsigned int columns() const;
00067   virtual ColumnVector vectorAdd(const MyColumnVector& v2) const;
00068   virtual ColumnVector& operator =(const MyColumnVector& a);
00069   virtual ColumnVector& operator =(double a);
00070 
00071   virtual MyColumnVector & operator+= (const MyColumnVector& a);
00072   virtual MyColumnVector & operator-= (const MyColumnVector& a);
00073   virtual MyColumnVector operator+ (const MyColumnVector &a) const;
00074   virtual MyColumnVector operator- (const MyColumnVector &a) const;
00075 
00076   virtual MyColumnVector& operator+= (double b);
00077   virtual MyColumnVector& operator-= (double b);
00078   virtual MyColumnVector& operator*= (double b);
00079   virtual MyColumnVector& operator/= (double b);
00080   virtual MyColumnVector operator+ (double b) const;
00081   virtual MyColumnVector operator- (double b) const;
00082   virtual MyColumnVector operator* (double b) const;
00083   virtual MyColumnVector operator/ (double b) const;
00084 
00086   virtual double operator[](unsigned int i) const
00087   { 
00088   //std::cout << "(BOOSTVECTOR) operator[] called " << i << std::endl;
00089    // if (i==0)
00090    //     std::cout << "(BOOSTVECTOR) operator[0]" << std::endl;
00091     
00092    return (*this)(i+1);
00093   }
00094 
00096   virtual double& operator[](unsigned int i) 
00097   { 
00098   //std::cout << "(BOOSTVECTOR) operator[] called " << i << std::endl;
00099   //  if (i==0)
00100   //      std::cout << "(BOOSTVECTOR) operator[0]" << std::endl;
00101      return (*this)(i+1);
00102   }
00103 
00104   virtual double operator()(unsigned int) const;
00105   virtual bool operator==(const MyColumnVector& a) const;
00106   virtual double& operator()(unsigned int);
00107   virtual MyMatrix operator* (const MyRowVector &a) const;
00108   virtual MyColumnVector sub(int j_start , int j_end) const;
00109   virtual MyRowVector transpose() const;
00110 
00111 
00112 };
00113 
00115 class RowVector : public BoostRowVector, public RowVector_Wrapper
00116 {
00117   // No private member:  We don't add anything.
00118 
00119   // Public Members
00120  public:
00121   RowVector();
00122   RowVector(int ncols);
00123   RowVector(int ncols,double value);
00124   // If you have another constructor in the matrix library you
00125   // want to use, you'll have to redefine it yourself
00126 
00127   // Copy constructor
00128   RowVector (const MyRowVector& a);
00129   // Copy constructor for boost
00130   RowVector (const BoostRowVector& a);
00131 
00132   virtual ~RowVector();
00133 
00134   virtual void resize(int num_cols);
00135   virtual RowVector vectorAdd(const MyRowVector& v2) const;
00136   virtual unsigned int rows() const;
00137   virtual unsigned int columns() const;
00138   virtual RowVector& operator =(double a);
00139   virtual RowVector& operator =(const MyRowVector& a);
00140 
00141   virtual MyRowVector & operator+= (const MyRowVector& a);
00142   virtual MyRowVector & operator-= (const MyRowVector& a);
00143   virtual MyRowVector operator+ (const MyRowVector &a) const;
00144   virtual MyRowVector operator- (const MyRowVector &a) const;
00145 
00146   virtual MyRowVector& operator+= (double b);
00147   virtual MyRowVector& operator-= (double b);
00148   virtual MyRowVector& operator*= (double b);
00149   virtual MyRowVector& operator/= (double b);
00150   virtual MyRowVector operator+ (double b) const;
00151   virtual MyRowVector operator- (double b) const;
00152   virtual MyRowVector operator* (double b) const;
00153   virtual MyRowVector operator/ (double b) const;
00154 
00155   virtual double operator()(unsigned int) const;
00156   virtual bool operator==(const MyRowVector& a) const;
00157   virtual double& operator()(unsigned int);
00158   virtual MyRowVector sub(int j_start , int j_end) const;
00159   virtual MyColumnVector transpose() const;
00160   virtual double operator*(const MyColumnVector& a) const;
00161 
00162 };
00163 
00164 }
00165 
00166 #endif
00167 
00168 #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 Thu Feb 11 2016 22:31:57