20 #include "../config.h" 21 #ifdef __MATRIXWRAPPER_BOOST__ 28 MyColumnVector::ColumnVector() : BoostColumnVector() {}
29 MyColumnVector::ColumnVector(
int num_rows) : BoostColumnVector(num_rows){}
30 MyColumnVector::ColumnVector(
int num_rows,
double value) : BoostColumnVector(num_rows){
31 ((BoostColumnVector*)
this)->assign(boost::numeric::ublas::scalar_vector<double>(num_rows,value));
35 BoostColumnVector& opl = (*this);
40 for (i=0; i< a.rows(); i++)
44 for (i=0; i< b.rows(); i++)
45 opl(a.rows() + i) = b(i+1);
49 MyColumnVector::~ColumnVector(){}
53 BoostColumnVector(a){}
54 MyColumnVector::ColumnVector(
const BoostColumnVector & a) :
55 BoostColumnVector(a){}
58 void MyColumnVector::resize(
int num_rows)
60 BoostColumnVector & op1 = (*this);
65 void MyColumnVector::assign(
int num_rows,
double value)
67 BoostColumnVector & op1 = (*this);
69 for (
unsigned int i=0; i<num_rows; i++)
74 unsigned int MyColumnVector::rows()
const {
return this->size();}
75 unsigned int MyColumnVector::columns()
const {
return 1;}
76 unsigned int MyColumnVector::capacity()
const {
return this->size();}
84 for (
unsigned int i=0; i<v1.rows(); i++)
87 for (
unsigned int i=0; i<v2.rows(); i++)
88 res(v1.rows()+i+1) = v2(i+1);
93 double& MyColumnVector::operator()(
unsigned int i)
96 BoostColumnVector& op1 = *(
this);
100 double MyColumnVector::operator()(
unsigned int i)
const 103 const BoostColumnVector op1 = (*this);
110 if (this->rows() != a.rows())
return false;
111 return(norm_inf((BoostColumnVector)(*
this)-(BoostColumnVector)a) == 0);
117 BoostColumnVector & op1 = (*this);
118 const BoostColumnVector & op2 = a;
125 BoostColumnVector & op1 = (*this);
126 const BoostColumnVector & op2 = a;
133 return (
MyColumnVector) ((BoostColumnVector)(*
this) + (BoostColumnVector)a);
138 return (
MyColumnVector) ((BoostColumnVector)(*
this) - (BoostColumnVector)a);
145 BoostColumnVector & op1 = *
this;
146 op1 += boost::numeric::ublas::scalar_vector<double>(rows(),a);
152 BoostColumnVector & op1 = *
this;
153 op1 -= boost::numeric::ublas::scalar_vector<double>(rows(),a);
159 BoostColumnVector& op1 = *
this;
166 BoostColumnVector& op1 = *
this;
174 return (
MyColumnVector)(((BoostColumnVector)(*
this)) + boost::numeric::ublas::scalar_vector<double>(rows(),a));
179 return (
MyColumnVector)(((BoostColumnVector)(*
this)) - boost::numeric::ublas::scalar_vector<double>(rows(),a));
184 const BoostColumnVector & op1 = (*this);
190 const BoostColumnVector & op1 = (*this);
198 unsigned int r = this->rows();
200 for (
unsigned int i=0; i<r; i++)
201 result(i+1) = (*this)(i+1);
207 unsigned int r = this->rows();
208 unsigned int c = a.columns();
211 for (
unsigned int i=0; i<r; i++)
212 for (
unsigned int j=0; j<c; j++)
213 result(i+1,j+1) = (*this)(i+1) * a(j+1);
220 BoostColumnVector& op1 = *
this;
221 op1 = (BoostColumnVector)a;
226 MyColumnVector::operator=(
double a)
228 BoostColumnVector& op1 = *
this;
229 op1 = boost::numeric::ublas::scalar_vector<double>(this->rows(),a);
236 for (
int j=j_start; j<=j_end; j++)
237 subvector(j-j_start+1) = (*this)(j);
250 MyRowVector::RowVector() : BoostRowVector() {}
251 MyRowVector::RowVector(
int num_cols) : BoostRowVector(num_cols){}
252 MyRowVector::RowVector(
int num_cols,
double value) : BoostRowVector(num_cols){
253 ((BoostRowVector*)
this)->assign(boost::numeric::ublas::scalar_vector<double>(num_cols,value));
257 MyRowVector::~RowVector(){}
262 MyRowVector::RowVector(
const BoostRowVector & a) :
266 void MyRowVector::resize(
int num_columns)
268 BoostRowVector & op1 = (*this);
269 op1.resize(num_columns);
273 void MyRowVector::assign(
int num_columns,
double value)
275 BoostRowVector & op1 = (*this);
276 op1.resize(num_columns);
277 for (
unsigned int i=0; i<num_columns; i++)
282 unsigned int MyRowVector::rows()
const {
return 1;}
283 unsigned int MyRowVector::columns()
const {
return this->size();}
284 unsigned int MyRowVector::capacity()
const {
return this->size();}
287 MyRowVector::vectorAdd(
const MyRowVector& v2)
const 292 for (
unsigned int i=0; i<v1.columns(); i++)
295 for (
unsigned int i=0; i<v2.columns(); i++)
296 res(v1.columns()+i+1) = v2(i+1);
301 double& MyRowVector::operator()(
unsigned int i)
304 BoostRowVector& op1 = *(
this);
308 double MyRowVector::operator()(
unsigned int i)
const 311 BoostRowVector op1 = (*this);
315 bool MyRowVector::operator==(
const MyRowVector& a)
const 317 if (this->columns() != a.columns())
return false;
318 return(norm_inf((BoostRowVector)(*
this)-(BoostRowVector)a) == 0);
324 BoostRowVector & op1 = (*this);
325 const BoostRowVector & op2 = a;
332 BoostRowVector & op1 = (*this);
333 const BoostRowVector & op2 = a;
340 return (
MyRowVector) ((BoostRowVector)(*
this) + (BoostRowVector)a);
345 return (
MyRowVector) ((BoostRowVector)(*
this) - (BoostRowVector)a);
352 BoostRowVector & op1 = *
this;
353 op1 += boost::numeric::ublas::scalar_vector<double>(columns(),a);
359 BoostRowVector & op1 = *
this;
360 op1 -= boost::numeric::ublas::scalar_vector<double>(columns(),a);
366 BoostRowVector& op1 = *
this;
373 BoostRowVector& op1 = *
this;
379 MyRowVector MyRowVector::operator+ (
double a)
const 381 return (
MyRowVector)(((BoostRowVector)(*
this)) + boost::numeric::ublas::scalar_vector<double>(columns(),a));
384 MyRowVector MyRowVector::operator- (
double a)
const 386 return (
MyRowVector)(((BoostRowVector)(*
this)) - boost::numeric::ublas::scalar_vector<double>(columns(),a));
389 MyRowVector MyRowVector::operator* (
double a)
const 391 const BoostRowVector & op1 = (*this);
395 MyRowVector MyRowVector::operator/ (
double a)
const 397 const BoostRowVector & op1 = (*this);
405 unsigned int c = this->columns();
407 for (
unsigned int i=0; i<c; i++)
408 result(i+1) = (*this)(i+1);
414 unsigned int r = a.rows();
415 unsigned int c = this->columns();
420 for (
unsigned int i=0; i<r; i++)
421 result += (*
this)(i+1) * a(i+1);
428 BoostRowVector& op1 = *
this;
429 op1 = (BoostRowVector)a;
434 MyRowVector::operator=(
double a)
436 BoostRowVector& op1 = *
this;
437 op1 = boost::numeric::ublas::scalar_vector<double>(this->columns(),a);
441 MyRowVector MyRowVector::sub(
int j_start ,
int j_end)
const 444 for (
int j=j_start; j<=j_end; j++)
445 subvector(j-j_start+1) = (*this)(j);