Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "../config.h"
00021 #ifdef __MATRIXWRAPPER_BOOST__
00022
00023 #include "vector_BOOST.h"
00024 #include <iostream>
00025
00026
00027
00028 MyColumnVector::ColumnVector() : BoostColumnVector() {}
00029 MyColumnVector::ColumnVector(int num_rows) : BoostColumnVector(num_rows){}
00030 MyColumnVector::ColumnVector(int num_rows,double value) : BoostColumnVector(num_rows){
00031 this->assign(boost::numeric::ublas::scalar_vector<double>(num_rows,value));
00032 }
00033 MyColumnVector::ColumnVector(const MyColumnVector& a, const MyColumnVector& b) : BoostColumnVector(a.rows() + b.rows())
00034 {
00035 BoostColumnVector& opl = (*this);
00036
00037 unsigned int i;
00038
00039
00040 for (i=0; i< a.rows(); i++)
00041 opl(i) = a(i+1);
00042
00043
00044 for (i=0; i< b.rows(); i++)
00045 opl(a.rows() + i) = b(i+1);
00046 }
00047
00048
00049 MyColumnVector::~ColumnVector(){}
00050
00051
00052 MyColumnVector::ColumnVector(const MyColumnVector& a) :
00053 BoostColumnVector(a){}
00054 MyColumnVector::ColumnVector(const BoostColumnVector & a) :
00055 BoostColumnVector(a){}
00056
00057
00058 void MyColumnVector::resize(int num_rows)
00059 {
00060 BoostColumnVector & op1 = (*this);
00061 op1.resize(num_rows);
00062 }
00063
00064
00065 unsigned int MyColumnVector::rows() const { return this->size();}
00066 unsigned int MyColumnVector::columns() const { return 1;}
00067
00068 MyColumnVector
00069 MyColumnVector::vectorAdd(const MyColumnVector& v2) const
00070 {
00071 const MyColumnVector& v1 = *this;
00072 MyColumnVector res(v1.rows() + v2.rows());
00073
00074 for (unsigned int i=0; i<v1.rows(); i++)
00075 res(i+1) = v1(i+1);
00076
00077 for (unsigned int i=0; i<v2.rows(); i++)
00078 res(v1.rows()+i+1) = v2(i+1);
00079
00080 return res;
00081 }
00082
00083 double& MyColumnVector::operator()(unsigned int i)
00084 {
00085
00086 BoostColumnVector& op1 = *(this);
00087 return op1(i-1);
00088 }
00089
00090 double MyColumnVector::operator()(unsigned int i) const
00091 {
00092
00093 const BoostColumnVector op1 = (*this);
00094 return op1(i-1);
00095 }
00096
00097
00098 bool MyColumnVector::operator==(const MyColumnVector& a) const
00099 {
00100 if (this->rows() != a.rows()) return false;
00101 return(norm_inf((BoostColumnVector)(*this)-(BoostColumnVector)a) == 0);
00102 }
00103
00104
00105 MyColumnVector & MyColumnVector::operator+= (const MyColumnVector& a)
00106 {
00107 BoostColumnVector & op1 = (*this);
00108 const BoostColumnVector & op2 = a;
00109 op1 += op2;
00110 return (MyColumnVector &) op1;
00111 }
00112
00113 MyColumnVector & MyColumnVector::operator-= (const MyColumnVector& a)
00114 {
00115 BoostColumnVector & op1 = (*this);
00116 const BoostColumnVector & op2 = a;
00117 op1 -= op2;
00118 return (MyColumnVector &) op1;
00119 }
00120
00121 MyColumnVector MyColumnVector::operator+ (const MyColumnVector &a) const
00122 {
00123 return (MyColumnVector) ((BoostColumnVector)(*this) + (BoostColumnVector)a);
00124 }
00125
00126 MyColumnVector MyColumnVector::operator- (const MyColumnVector &a) const
00127 {
00128 return (MyColumnVector) ((BoostColumnVector)(*this) - (BoostColumnVector)a);
00129 }
00130
00131
00132
00133 MyColumnVector& MyColumnVector::operator+= (double a)
00134 {
00135 BoostColumnVector & op1 = *this;
00136 op1 += boost::numeric::ublas::scalar_vector<double>(rows(),a);
00137 return (MyColumnVector&)op1;
00138 }
00139
00140 MyColumnVector& MyColumnVector::operator-= (double a)
00141 {
00142 BoostColumnVector & op1 = *this;
00143 op1 -= boost::numeric::ublas::scalar_vector<double>(rows(),a);
00144 return (MyColumnVector&)op1;
00145 }
00146
00147 MyColumnVector& MyColumnVector::operator*= (double a)
00148 {
00149 BoostColumnVector& op1 = *this;
00150 op1 *= a;
00151 return (MyColumnVector&) op1;
00152 }
00153
00154 MyColumnVector& MyColumnVector::operator/= (double a)
00155 {
00156 BoostColumnVector& op1 = *this;
00157 op1 /= a;
00158 return (MyColumnVector&) op1;
00159 }
00160
00161
00162 MyColumnVector MyColumnVector::operator+ (double a) const
00163 {
00164 return (MyColumnVector)(((BoostColumnVector)(*this)) + boost::numeric::ublas::scalar_vector<double>(rows(),a));
00165 }
00166
00167 MyColumnVector MyColumnVector::operator- (double a) const
00168 {
00169 return (MyColumnVector)(((BoostColumnVector)(*this)) - boost::numeric::ublas::scalar_vector<double>(rows(),a));
00170 }
00171
00172 MyColumnVector MyColumnVector::operator* (double a) const
00173 {
00174 const BoostColumnVector & op1 = (*this);
00175 return (MyColumnVector) (op1 * a);
00176 }
00177
00178 MyColumnVector MyColumnVector::operator/ (double a) const
00179 {
00180 const BoostColumnVector & op1 = (*this);
00181 return (MyColumnVector) (op1 / a);
00182 }
00183
00184
00185
00186 MyRowVector MyColumnVector::transpose() const
00187 {
00188 unsigned int r = this->rows();
00189 MyRowVector result(r);
00190 for (unsigned int i=0; i<r; i++)
00191 result(i+1) = (*this)(i+1);
00192 return result;
00193 }
00194
00195 MyMatrix MyColumnVector::operator* (const MyRowVector &a) const
00196 {
00197 unsigned int r = this->rows();
00198 unsigned int c = a.columns();
00199
00200 MyMatrix result(r,c);
00201 for (unsigned int i=0; i<r; i++)
00202 for (unsigned int j=0; j<c; j++)
00203 result(i+1,j+1) = (*this)(i+1) * a(j+1);
00204 return result;
00205 }
00206
00207 MyColumnVector&
00208 MyColumnVector::operator=(const MyColumnVector &a)
00209 {
00210 BoostColumnVector& op1 = *this;
00211 op1 = (BoostColumnVector)a;
00212 return *this;
00213 }
00214
00215 MyColumnVector&
00216 MyColumnVector::operator=(double a)
00217 {
00218 BoostColumnVector& op1 = *this;
00219 op1 = boost::numeric::ublas::scalar_vector<double>(this->rows(),a);
00220 return *this;
00221 }
00222
00223 MyColumnVector MyColumnVector::sub(int j_start , int j_end) const
00224 {
00225 MyColumnVector subvector(j_end-j_start+1);
00226 for (int j=j_start; j<=j_end; j++)
00227 subvector(j-j_start+1) = (*this)(j);
00228
00229 return subvector;
00230 }
00231
00232
00233
00234
00238
00239
00240 MyRowVector::RowVector() : BoostRowVector() {}
00241 MyRowVector::RowVector(int num_cols) : BoostRowVector(num_cols){}
00242 MyRowVector::RowVector(int num_cols,double value) : BoostRowVector(num_cols){
00243 this->assign(boost::numeric::ublas::scalar_vector<double>(num_cols,value));
00244 }
00245
00246
00247 MyRowVector::~RowVector(){}
00248
00249
00250 MyRowVector::RowVector(const MyRowVector& a) :
00251 BoostRowVector(a){}
00252 MyRowVector::RowVector(const BoostRowVector & a) :
00253 BoostRowVector(a){}
00254
00255
00256 void MyRowVector::resize(int num_columns)
00257 {
00258 BoostRowVector & op1 = (*this);
00259 op1.resize(num_columns);
00260 }
00261
00262
00263 unsigned int MyRowVector::rows() const { return 1;}
00264 unsigned int MyRowVector::columns() const { return this->size();}
00265
00266 MyRowVector
00267 MyRowVector::vectorAdd(const MyRowVector& v2) const
00268 {
00269 const MyRowVector& v1 = *this;
00270 MyRowVector res(v1.columns() + v2.columns());
00271
00272 for (unsigned int i=0; i<v1.columns(); i++)
00273 res(i+1) = v1(i+1);
00274
00275 for (unsigned int i=0; i<v2.columns(); i++)
00276 res(v1.columns()+i+1) = v2(i+1);
00277
00278 return res;
00279 }
00280
00281 double& MyRowVector::operator()(unsigned int i)
00282 {
00283
00284 BoostRowVector& op1 = *(this);
00285 return op1(i-1);
00286 }
00287
00288 double MyRowVector::operator()(unsigned int i) const
00289 {
00290
00291 BoostRowVector op1 = (*this);
00292 return op1(i-1);
00293 }
00294
00295 bool MyRowVector::operator==(const MyRowVector& a) const
00296 {
00297 if (this->columns() != a.columns()) return false;
00298 return(norm_inf((BoostRowVector)(*this)-(BoostRowVector)a) == 0);
00299 }
00300
00301
00302 MyRowVector & MyRowVector::operator+= (const MyRowVector& a)
00303 {
00304 BoostRowVector & op1 = (*this);
00305 const BoostRowVector & op2 = a;
00306 op1 += op2;
00307 return (MyRowVector &) op1;
00308 }
00309
00310 MyRowVector & MyRowVector::operator-= (const MyRowVector& a)
00311 {
00312 BoostRowVector & op1 = (*this);
00313 const BoostRowVector & op2 = a;
00314 op1 -= op2;
00315 return (MyRowVector &) op1;
00316 }
00317
00318 MyRowVector MyRowVector::operator+ (const MyRowVector &a) const
00319 {
00320 return (MyRowVector) ((BoostRowVector)(*this) + (BoostRowVector)a);
00321 }
00322
00323 MyRowVector MyRowVector::operator- (const MyRowVector &a) const
00324 {
00325 return (MyRowVector) ((BoostRowVector)(*this) - (BoostRowVector)a);
00326 }
00327
00328
00329
00330 MyRowVector& MyRowVector::operator+= (double a)
00331 {
00332 BoostRowVector & op1 = *this;
00333 op1 += boost::numeric::ublas::scalar_vector<double>(columns(),a);
00334 return (MyRowVector&)op1;
00335 }
00336
00337 MyRowVector& MyRowVector::operator-= (double a)
00338 {
00339 BoostRowVector & op1 = *this;
00340 op1 -= boost::numeric::ublas::scalar_vector<double>(columns(),a);
00341 return (MyRowVector&)op1;
00342 }
00343
00344 MyRowVector& MyRowVector::operator*= (double a)
00345 {
00346 BoostRowVector& op1 = *this;
00347 op1 *= a;
00348 return (MyRowVector&) op1;
00349 }
00350
00351 MyRowVector& MyRowVector::operator/= (double a)
00352 {
00353 BoostRowVector& op1 = *this;
00354 op1 /= a;
00355 return (MyRowVector&) op1;
00356 }
00357
00358
00359 MyRowVector MyRowVector::operator+ (double a) const
00360 {
00361 return (MyRowVector)(((BoostRowVector)(*this)) + boost::numeric::ublas::scalar_vector<double>(columns(),a));
00362 }
00363
00364 MyRowVector MyRowVector::operator- (double a) const
00365 {
00366 return (MyRowVector)(((BoostRowVector)(*this)) - boost::numeric::ublas::scalar_vector<double>(columns(),a));
00367 }
00368
00369 MyRowVector MyRowVector::operator* (double a) const
00370 {
00371 const BoostRowVector & op1 = (*this);
00372 return (MyRowVector) (op1 * a);
00373 }
00374
00375 MyRowVector MyRowVector::operator/ (double a) const
00376 {
00377 const BoostRowVector & op1 = (*this);
00378 return (MyRowVector) (op1 / a);
00379 }
00380
00381
00382
00383 MyColumnVector MyRowVector::transpose() const
00384 {
00385 unsigned int c = this->columns();
00386 MyColumnVector result(c);
00387 for (unsigned int i=0; i<c; i++)
00388 result(i+1) = (*this)(i+1);
00389 return result;
00390 }
00391
00392 double MyRowVector::operator* (const MyColumnVector &a) const
00393 {
00394 unsigned int r = a.rows();
00395 unsigned int c = this->columns();
00396
00397 assert(c == r);
00398
00399 double result = 0;
00400 for (unsigned int i=0; i<r; i++)
00401 result += (*this)(i+1) * a(i+1);
00402 return result;
00403 }
00404
00405 MyRowVector&
00406 MyRowVector::operator=(const MyRowVector &a)
00407 {
00408 BoostRowVector& op1 = *this;
00409 op1 = (BoostRowVector)a;
00410 return *this;
00411 }
00412
00413 MyRowVector&
00414 MyRowVector::operator=(double a)
00415 {
00416 BoostRowVector& op1 = *this;
00417 op1 = boost::numeric::ublas::scalar_vector<double>(this->columns(),a);
00418 return *this;
00419 }
00420
00421 MyRowVector MyRowVector::sub(int j_start , int j_end) const
00422 {
00423 MyRowVector subvector(j_end-j_start+1);
00424 for (int j=j_start; j<=j_end; j++)
00425 subvector(j-j_start+1) = (*this)(j);
00426
00427 return subvector;
00428 }
00429
00430 #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