20 #include "../config.h" 21 #ifdef __MATRIXWRAPPER_NEWMAT__ 29 MyMatrix::Matrix() : NewMatMatrix() {}
30 MyMatrix::Matrix(
int num_rows,
int num_cols) : NewMatMatrix(num_rows,
37 MyMatrix::Matrix(
const MyMatrix& a) : NewMatMatrix(a){}
40 MyMatrix::Matrix(
const NewMatMatrix & a) : NewMatMatrix(a){}
43 unsigned int MyMatrix::rows()
const {
return this->Nrows();}
44 unsigned int MyMatrix::columns()
const {
return this->Ncols();}
47 MyMatrix& MyMatrix::operator+= (
double a)
49 NewMatMatrix & op1 = (*this);
54 MyMatrix& MyMatrix::operator-= (
double a)
56 NewMatMatrix & op1 = (*this);
61 MyMatrix& MyMatrix::operator*= (
double a)
63 NewMatMatrix & op1 = (*this);
68 MyMatrix& MyMatrix::operator/= (
double a)
70 NewMatMatrix & op1 = (*this);
75 MyMatrix MyMatrix::operator+ (
double a)
const 78 NewMatMatrix op1 = (*this);
83 MyMatrix MyMatrix::operator- (
double a)
const 86 NewMatMatrix op1 = (*this);
91 MyMatrix MyMatrix::operator* (
double a)
const 94 NewMatMatrix op1 = (*this);
99 MyMatrix MyMatrix::operator/ (
double a)
const 102 NewMatMatrix op1 = (*this);
118 const NewMatMatrix& op1 = (*this);
119 const NewMatMatrix& op2 = a;
120 NewMatMatrix result = (NewMatMatrix) (op1 - op2);
126 const NewMatMatrix& op1 = (*this);
127 const NewMatMatrix& op2 = a;
128 NewMatMatrix result = (NewMatMatrix) (op1 + op2);
134 const NewMatMatrix& op1 = (*this);
135 const NewMatMatrix& op2 = a;
136 NewMatMatrix result = (NewMatMatrix) (op1 * op2);
142 NewMatMatrix & op1 = (*this);
143 const NewMatMatrix & op2 = a;
150 NewMatMatrix & op1 = (*this);
151 const NewMatMatrix & op2 = a;
160 const NewMatMatrix& op1 = (*this);
161 const NewMatColumnVector& op2 = b;
167 MyMatrix& MyMatrix::operator=(
double a)
169 NewMatMatrix temp = (NewMatMatrix) *
this;
177 MyRowVector MyMatrix::rowCopy(
unsigned int r)
const 179 const NewMatMatrix& temp = (*this);
185 const NewMatMatrix& temp = (*this);
192 MyMatrix MyMatrix::transpose()
const 194 const NewMatMatrix & base = (*this);
195 NewMatMatrix transposedbase = base.t();
199 double MyMatrix::determinant()
const 201 const NewMatMatrix& base = (*this);
202 NEWMAT::LogAndSign temp = base.LogDeterminant();
203 double result = temp.Value();
210 const NewMatMatrix & base = (*this);
211 NewMatMatrix inverted = base.i();
220 assert( this->rows() == this->columns() );
224 if ( sym.rows() != this->rows() )
225 sym.ReSize(this->rows());
229 for (
unsigned int i=0; i<this->rows(); i++ )
230 for (
unsigned int j=0; j<=i; j++ )
231 sym(i+1,j+1) = (*this)(i+1,j+1);
236 MyMatrix::resize(
unsigned int i,
unsigned int j,
bool copy,
bool initialize)
238 NewMatMatrix & temp = (NewMatMatrix &) (*
this);
243 MyMatrix MyMatrix::sub(
int i_start,
int i_end,
int j_start ,
int j_end)
const 245 assert(i_start >= 0 && i_start <= rows());
246 assert(j_start >= 0 && j_start <= columns());
247 assert(i_end >= 0 && i_end <= rows());
248 assert(j_end >= 0 && j_end <= columns());
249 assert(i_start <= i_end);
250 assert(j_start <= j_end);
252 return (
MyMatrix)(this->SubMatrix(i_start, i_end, j_start, j_end));
261 MySymmetricMatrix::SymmetricMatrix() : NewMatSymmetricMatrix() {}
262 MySymmetricMatrix::SymmetricMatrix(
int n) : NewMatSymmetricMatrix(n) {}
265 MySymmetricMatrix::SymmetricMatrix(
const SymmetricMatrix& a) : NewMatSymmetricMatrix(a){}
266 MySymmetricMatrix::SymmetricMatrix(
const NewMatSymmetricMatrix & a) : NewMatSymmetricMatrix(a){}
269 MySymmetricMatrix::~SymmetricMatrix(){}
272 unsigned int MySymmetricMatrix::rows()
const {
return this->Nrows();}
273 unsigned int MySymmetricMatrix::columns()
const {
return this->Ncols();}
280 const NewMatSymmetricMatrix & base = (NewMatSymmetricMatrix &) *
this;
281 NewMatSymmetricMatrix inverted = base.i();
285 double MySymmetricMatrix::determinant()
const 287 const NewMatSymmetricMatrix & base = (NewMatSymmetricMatrix &) *
this;
288 NEWMAT::LogAndSign temp = base.LogDeterminant();
289 double result = temp.Value();
294 double& MyMatrix::operator()(
unsigned int a,
unsigned int b)
296 NewMatMatrix & op1(*
this);
300 const double MyMatrix::operator()(
unsigned int a,
unsigned int b)
const 302 const NewMatMatrix& op1(*
this);
306 const bool MyMatrix::operator==(
const MyMatrix& a)
const 308 const NewMatMatrix& op1 = *
this;
309 const NewMatMatrix& op2 = a;
316 NewMatSymmetricMatrix temp = (NewMatSymmetricMatrix) *
this;
327 NewMatSymmetricMatrix & op1 = (*this);
334 NewMatSymmetricMatrix & op1 = (*this);
341 NewMatSymmetricMatrix & op1 = (*this);
348 NewMatSymmetricMatrix & op1 = (*this);
356 NewMatSymmetricMatrix op1 = (*this);
364 NewMatSymmetricMatrix op1 = (*this);
372 NewMatSymmetricMatrix op1 = (*this);
380 NewMatSymmetricMatrix op1 = (*this);
391 NewMatSymmetricMatrix & op1 = (*this);
392 const NewMatMatrix & op2 = a;
399 NewMatSymmetricMatrix & op1 = (*this);
400 const NewMatMatrix & op2 = a;
408 const NewMatMatrix& op1 = (*this);
409 const NewMatMatrix& op2 = a;
410 NewMatMatrix result = (NewMatMatrix) (op1 + op2);
416 const NewMatMatrix& op1 = (*this);
417 const NewMatMatrix& op2 = a;
418 NewMatMatrix result = (NewMatMatrix) (op1 - op2);
424 const NewMatMatrix& op1 = (*this);
425 const NewMatMatrix& op2 = a;
426 NewMatMatrix result = (NewMatMatrix) (op1 * op2);
435 NewMatSymmetricMatrix & op1 = (*this);
436 const NewMatSymmetricMatrix & op2 = a;
443 NewMatSymmetricMatrix & op1 = (*this);
444 const NewMatSymmetricMatrix & op2 = a;
451 const NewMatSymmetricMatrix& op1 = (*this);
452 const NewMatSymmetricMatrix& op2 = a;
453 NewMatSymmetricMatrix result = (NewMatSymmetricMatrix) (op1 + op2);
459 const NewMatSymmetricMatrix& op1 = (*this);
460 const NewMatSymmetricMatrix& op2 = a;
461 NewMatSymmetricMatrix result = (NewMatSymmetricMatrix) (op1 - op2);
467 const NewMatSymmetricMatrix& op1 = (*this);
468 const NewMatSymmetricMatrix& op2 = a;
477 const NewMatSymmetricMatrix& op1 = *
this;
478 const NewMatColumnVector& op2 = b;
484 const NewMatSymmetricMatrix& op1 = *
this;
485 const NewMatColumnVector& op2 = b;
489 MyMatrix MySymmetricMatrix::sub(
int i_start,
int i_end,
int j_start ,
int j_end)
const 491 return (
MyMatrix)(this->SubMatrix(i_start, i_end, j_start, j_end));
496 MySymmetricMatrix::resize(
unsigned int i,
bool copy,
bool initialize)
498 NewMatSymmetricMatrix & temp = (NewMatSymmetricMatrix &) (*
this);
504 double& MySymmetricMatrix::operator()(
unsigned int a,
unsigned int b)
506 NewMatSymmetricMatrix & op1 = (*this);
510 const double MySymmetricMatrix::operator()(
unsigned int a,
unsigned int b)
const 512 const NewMatSymmetricMatrix op1(*
this);
518 const NewMatSymmetricMatrix& op1 = *
this;
519 const NewMatSymmetricMatrix& op2 = a;
#define MySymmetricMatrix