20 #include "../config.h" 21 #ifdef __MATRIXWRAPPER_NEWMAT__ 26 MyColumnVector::ColumnVector() : NewMatColumnVector() {}
27 MyColumnVector::ColumnVector(
int num_rows) : NewMatColumnVector(num_rows){}
30 NewMatColumnVector& opl = (*this);
35 for (i=0; i< a.rows(); i++)
39 for (i=0; i< b.rows(); i++)
40 opl(a.rows() + i+1) = b(i+1);
44 MyColumnVector::~ColumnVector(){}
48 NewMatColumnVector(a){}
49 MyColumnVector::ColumnVector(
const NewMatColumnVector & a) :
50 NewMatColumnVector(a){}
53 void MyColumnVector::resize(
int num_rows)
55 NewMatColumnVector & op1 = (*this);
60 void MyColumnVector::assign(
int num_rows,
double value)
62 NewMatColumnVector & op1 = (*this);
64 for (
unsigned int i=0; i<num_rows; i++)
69 unsigned int MyColumnVector::rows()
const {
return this->Nrows();}
70 unsigned int MyColumnVector::columns()
const {
return this->Ncols();}
71 unsigned int MyColumnVector::capacity()
const {
return this->Nrows();}
79 for (
unsigned int i=0; i<v1.rows(); i++)
82 for (
unsigned int i=0; i<v2.rows(); i++)
83 res(v1.rows()+i+1) = v2(i+1);
88 double& MyColumnVector::operator()(
unsigned int i)
90 NewMatColumnVector& op1 = *(
this);
94 const double MyColumnVector::operator()(
unsigned int i)
const 96 NewMatColumnVector op1 = (*this);
104 NewMatColumnVector & op1 = (*this);
105 const NewMatColumnVector & op2 = a;
112 NewMatColumnVector & op1 = (*this);
113 const NewMatColumnVector & op2 = a;
120 const NewMatColumnVector& op1 = (*this);
121 const NewMatColumnVector & op2 = a;
122 NewMatColumnVector result = (NewMatColumnVector) (op1 + op2);
128 const NewMatColumnVector & op1 = (*this);
129 const NewMatColumnVector & op2 = a;
130 NewMatColumnVector result = (NewMatColumnVector) (op1 - op2);
138 NewMatColumnVector& op1 = *
this;
145 NewMatColumnVector& op1 = *
this;
152 NewMatColumnVector& op1 = *
this;
159 NewMatColumnVector& op1 = *
this;
167 const NewMatColumnVector & op1 = (*this);
173 const NewMatColumnVector & op1 = (*this);
179 const NewMatColumnVector & op1 = (*this);
185 const NewMatColumnVector & op1 = (*this);
189 const bool MyColumnVector::operator==(
const MyColumnVector& a)
const 191 const NewMatColumnVector& op1 = *
this;
192 const NewMatColumnVector& op2 = a;
198 NewMatColumnVector & base = (NewMatColumnVector &) *
this;
199 NewMatRowVector transposedbase = base.t();
205 const NewMatColumnVector & op1 = (*this);
206 const NewMatRowVector & op2 = a;
207 NewMatMatrix result = (NewMatMatrix) (op1 * op2);
215 NewMatColumnVector * op1;
const NewMatColumnVector * op2;
216 op1 =
this; op2 = &a;
222 MyColumnVector::operator=(
double a)
225 NewMatColumnVector * op1;
237 if (nr < 1 || nc < 1)
238 is.clear (ios::badbit);
242 for (
int i = 0; i < nr; i++)
266 MyRowVector::RowVector() : NewMatRowVector() {}
267 MyRowVector::RowVector(
int num_rows) : NewMatRowVector(num_rows){}
270 MyRowVector::~RowVector(){}
273 MyRowVector::RowVector(
const MyRowVector& a) : NewMatRowVector(a){}
274 MyRowVector::RowVector(
const NewMatRowVector & a) : NewMatRowVector(a){}
277 unsigned int MyRowVector::rows()
const {
return this->Nrows();}
278 unsigned int MyRowVector::columns()
const {
return this->Ncols();}
279 unsigned int MyRowVector::capacity()
const {
return this->Ncols();}
284 NewMatRowVector & op1 = (*this);
285 const NewMatRowVector & op2 = a;
292 NewMatRowVector & op1 = (*this);
293 const NewMatRowVector & op2 = a;
300 const NewMatRowVector & op1 = (*this);
301 const NewMatRowVector & op2 = a;
302 NewMatRowVector result = (NewMatRowVector) (op1 + op2);
308 const NewMatRowVector & op1 = (*this);
309 const NewMatRowVector & op2 = a;
310 NewMatRowVector result = (NewMatRowVector) (op1 - op2);
320 assert (this->columns() == a.rows());
322 const NewMatRowVector& op1 = (*this);
323 const NewMatColumnVector & op2 = a;
324 NewMatMatrix matrixresult = op1 * op2;
325 double result = matrixresult.AsScalar();
334 NewMatRowVector * op1;
const NewMatRowVector * op2;
335 op1 =
this; op2 = &a;
344 NewMatRowVector & base = (NewMatRowVector &) *
this;
345 NewMatColumnVector transposedbase = base.t();
350 MyRowVector MyRowVector::sub(
int j_start ,
int j_end)
const 352 return (
MyRowVector)(this->SubMatrix(1, 1, j_start, j_end));
359 NewMatRowVector& op1 = *
this;
366 NewMatRowVector& op1 = *
this;
373 NewMatRowVector& op1 = *
this;
380 NewMatRowVector& op1 = *
this;
386 MyRowVector MyRowVector::operator+ (
double a)
const 388 const NewMatRowVector & op1 = (*this);
392 MyRowVector MyRowVector::operator- (
double a)
const 394 const NewMatRowVector & op1 = (*this);
398 MyRowVector MyRowVector::operator* (
double a)
const 400 const NewMatRowVector & op1 = (*this);
404 MyRowVector MyRowVector::operator/ (
double a)
const 406 const NewMatRowVector & op1 = (*this);
413 MyRowVector::operator=(
double a)
416 NewMatRowVector * op1;
423 double& MyRowVector::operator()(
unsigned int i)
425 NewMatRowVector& op1 = *(
this);
429 const double MyRowVector::operator()(
unsigned int i)
const 431 NewMatRowVector op1 = (*this);
435 const bool MyRowVector::operator==(
const MyRowVector& a)
const 437 const NewMatRowVector& op1 = *
this;
438 const NewMatRowVector& op2 = a;
444 MyRowVector::vectorAdd(
const MyRowVector& v2)
const 449 for (
unsigned int i=0; i<v1.rows(); i++)
452 for (
unsigned int i=0; i<v2.rows(); i++)
453 res(v1.rows()+i+1) = v2(i+1);
460 void MyRowVector::resize(
int num_cols)
462 NewMatRowVector & op1 = (*this);
463 op1.ReSize(num_cols);
467 void MyRowVector::assign(
int num_columns,
double value)
469 NewMatRowVector & op1 = (*this);
470 op1.resize(num_columns);
471 for (
unsigned int i=0; i<num_columns; i++)
istream & operator>>(istream &stream, Probability &prob)