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 unsigned int capacity() const;
00068   virtual void assign(int size, double value) ;
00069   virtual ColumnVector vectorAdd(const MyColumnVector& v2) const;
00070   virtual ColumnVector& operator =(const MyColumnVector& a);
00071   virtual ColumnVector& operator =(double a);
00072 
00073   virtual MyColumnVector & operator+= (const MyColumnVector& a);
00074   virtual MyColumnVector & operator-= (const MyColumnVector& a);
00075   virtual MyColumnVector operator+ (const MyColumnVector &a) const;
00076   virtual MyColumnVector operator- (const MyColumnVector &a) const;
00077 
00078   virtual MyColumnVector& operator+= (double b);
00079   virtual MyColumnVector& operator-= (double b);
00080   virtual MyColumnVector& operator*= (double b);
00081   virtual MyColumnVector& operator/= (double b);
00082   virtual MyColumnVector operator+ (double b) const;
00083   virtual MyColumnVector operator- (double b) const;
00084   virtual MyColumnVector operator* (double b) const;
00085   virtual MyColumnVector operator/ (double b) const;
00086 
00088   virtual double operator[](unsigned int i) const
00089   { 
00090   //std::cout << "(BOOSTVECTOR) operator[] called " << i << std::endl;
00091    // if (i==0)
00092    //     std::cout << "(BOOSTVECTOR) operator[0]" << std::endl;
00093     
00094    return (*this)(i+1);
00095   }
00096 
00098   virtual double& operator[](unsigned int i) 
00099   { 
00100   //std::cout << "(BOOSTVECTOR) operator[] called " << i << std::endl;
00101   //  if (i==0)
00102   //      std::cout << "(BOOSTVECTOR) operator[0]" << std::endl;
00103      return (*this)(i+1);
00104   }
00105 
00106   virtual double operator()(unsigned int) const;
00107   virtual bool operator==(const MyColumnVector& a) const;
00108   virtual double& operator()(unsigned int);
00109   virtual MyMatrix operator* (const MyRowVector &a) const;
00110   virtual MyColumnVector sub(int j_start , int j_end) const;
00111   virtual MyRowVector transpose() const;
00112 
00113 
00114 };
00115 
00117 class RowVector : public BoostRowVector, public RowVector_Wrapper
00118 {
00119   // No private member:  We don't add anything.
00120 
00121   // Public Members
00122  public:
00123   RowVector();
00124   RowVector(int ncols);
00125   RowVector(int ncols,double value);
00126   // If you have another constructor in the matrix library you
00127   // want to use, you'll have to redefine it yourself
00128 
00129   // Copy constructor
00130   RowVector (const MyRowVector& a);
00131   // Copy constructor for boost
00132   RowVector (const BoostRowVector& a);
00133 
00134   virtual ~RowVector();
00135 
00136   virtual void resize(int num_cols);
00137   virtual void assign(int size, double value) ;
00138   virtual RowVector vectorAdd(const MyRowVector& v2) const;
00139   virtual unsigned int rows() const;
00140   virtual unsigned int columns() const;
00141   virtual unsigned int capacity() const;
00142   virtual RowVector& operator =(double a);
00143   virtual RowVector& operator =(const MyRowVector& a);
00144 
00145   virtual MyRowVector & operator+= (const MyRowVector& a);
00146   virtual MyRowVector & operator-= (const MyRowVector& a);
00147   virtual MyRowVector operator+ (const MyRowVector &a) const;
00148   virtual MyRowVector operator- (const MyRowVector &a) const;
00149 
00150   virtual MyRowVector& operator+= (double b);
00151   virtual MyRowVector& operator-= (double b);
00152   virtual MyRowVector& operator*= (double b);
00153   virtual MyRowVector& operator/= (double b);
00154   virtual MyRowVector operator+ (double b) const;
00155   virtual MyRowVector operator- (double b) const;
00156   virtual MyRowVector operator* (double b) const;
00157   virtual MyRowVector operator/ (double b) const;
00158 
00159   virtual double operator()(unsigned int) const;
00160   virtual bool operator==(const MyRowVector& a) const;
00161   virtual double& operator()(unsigned int);
00162   virtual MyRowVector sub(int j_start , int j_end) const;
00163   virtual MyColumnVector transpose() const;
00164   virtual double operator*(const MyColumnVector& a) const;
00165 
00166 };
00167 
00168 }
00169 
00170 #endif
00171 
00172 #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 Mon Feb 11 2019 03:45:12