#include <marMatrix.h>
Public Member Functions | |
marMatrix (const marMatrix &m) | |
marMatrix (double *data, size_t size1=3, size_t size2=3) | |
marMatrix (size_t size1, size_t size2) | |
virtual | ~marMatrix () |
marMatrix & | operator= (const marMatrix &o) |
marMatrix & | operator= (double o) |
marMatrix & | operator= (double *o) |
operator double * () const | |
double & | operator() (size_t i, size_t j) |
const double & | operator() (size_t i, size_t j) const |
marMatrix | operator+ (const marMatrix &o) |
marMatrix | operator+ (double o) |
marMatrix | operator+ (double *o) |
marMatrix | operator- (const marMatrix &o) |
marMatrix | operator- (double o) |
marMatrix | operator- (double *o) |
marMatrix | operator* (const marMatrix &o) |
marVector | operator* (const marVector &o) |
marMatrix | operator* (double o) |
bool | operator== (const marMatrix &o) const |
bool | operator!= (const marMatrix &o) const |
size_t | columns () const |
size_t | rows () const |
Private Attributes | |
bool | shallowCopy |
size_t | _size1 |
size_t | _size2 |
double * | _data |
Friends | |
std::ostream & | operator<< (std::ostream &os, const marMatrix &m) |
Definition at line 9 of file marMatrix.h.
marMatrix::marMatrix | ( | const marMatrix & | m | ) |
Definition at line 44 of file marMatrix.cpp.
References _data, _size1, and _size2.
00045 :shallowCopy(false) 00046 { 00047 if (m._size1==0 || m._size2==0) 00048 { 00049 assert(false); 00050 } 00051 else 00052 { 00053 _size1=m._size1; 00054 _size2=m._size2; 00055 00056 size_t iMax=_size1*_size2; 00057 _data=new double[iMax]; 00058 00059 int i; 00060 for (i=0;i<iMax;i++) 00061 { 00062 _data[i]=m._data[i]; 00063 } 00064 } 00065 }
marMatrix::marMatrix | ( | double * | data, | |
size_t | size1 = 3 , |
|||
size_t | size2 = 3 | |||
) |
Definition at line 19 of file marMatrix.cpp.
References _data, _size1, and _size2.
00020 :shallowCopy(true) 00021 { 00022 if (size1==0 || size2==0) 00023 { 00024 assert(false); 00025 } 00026 else 00027 { 00028 _size1=size1; 00029 _size2=size2; 00030 _data=data; 00031 00032 // PS -> size_t iMax=_size1*_size2; 00033 // PS -> _data=new double[iMax]; 00034 // PS -> 00035 // PS -> for (int i=0;i<iMax;i++) 00036 // PS -> { 00037 // PS -> _data[i]=data[i]; 00038 // PS -> } 00039 00040 } 00041 }
marMatrix::marMatrix | ( | size_t | size1, | |
size_t | size2 | |||
) |
marMatrix::~marMatrix | ( | ) | [virtual] |
Definition at line 70 of file marMatrix.cpp.
References _data, and shallowCopy.
00071 { 00072 if (!shallowCopy) 00073 { 00074 delete _data; 00075 } 00076 else 00077 { 00078 _data=NULL; 00079 } 00080 }
size_t marMatrix::columns | ( | ) | const |
Definition at line 422 of file marMatrix.cpp.
References _size2.
00423 { 00424 return _size2; 00425 }
marMatrix::operator double * | ( | ) | const |
Definition at line 103 of file marMatrix.cpp.
References _data.
00104 { 00105 return(_data); 00106 }
bool marMatrix::operator!= | ( | const marMatrix & | o | ) | const |
Definition at line 207 of file marMatrix.cpp.
const double & marMatrix::operator() | ( | size_t | i, | |
size_t | j | |||
) | const |
double & marMatrix::operator() | ( | size_t | i, | |
size_t | j | |||
) |
marMatrix marMatrix::operator* | ( | double | o | ) |
Definition at line 344 of file marMatrix.cpp.
References _data, _size1, and _size2.
00345 { 00346 marMatrix result(*this); 00347 00348 if ((result._size1==0) || (result._size2==0)) 00349 { 00350 assert(false); 00351 } 00352 else 00353 { 00354 size_t iMax=result._size1*result._size2; 00355 int i; 00356 for (i=0;i < iMax;i++) 00357 { 00358 result._data[i]*=o; 00359 } 00360 } 00361 return result; 00362 }
Definition at line 397 of file marMatrix.cpp.
References _size1, _size2, and marVector::size().
00398 { 00399 marVector result(_size1); 00400 if (o.size()!=_size2) 00401 { 00402 assert(false); 00403 } 00404 else 00405 { 00406 marMatrix resultM(_size1,1); 00407 marMatrix B((double*)o,o.size(),1); 00408 resultM=(*this)*B; 00409 result=(double*)resultM; 00410 } 00411 return result; 00412 }
Definition at line 364 of file marMatrix.cpp.
References _size1, and _size2.
00365 { 00366 size_t mA=_size1; 00367 size_t nA=_size2; 00368 size_t mB=o._size1; 00369 size_t nB=o._size2; 00370 size_t mR=mA; 00371 size_t nR=nB; 00372 00373 marMatrix result(mR,nR); 00374 result=0.0; 00375 00376 int k,i,j; 00377 if (nA==mB) 00378 { 00379 for (k=0;k<nA;k++) 00380 { 00381 for (i=0;i<mR;i++) 00382 { 00383 for (j=0;j<nR;j++) 00384 { 00385 result(i,j)+=(*this)(i,k)*o(k,j); 00386 } 00387 } 00388 } 00389 } 00390 else 00391 { 00392 assert(false); 00393 } 00394 return result; 00395 }
marMatrix marMatrix::operator+ | ( | double * | o | ) |
Definition at line 257 of file marMatrix.cpp.
References _data, _size1, and _size2.
00258 { 00259 marMatrix result(*this); 00260 00261 if ((result._size1==0) || (result._size2==0)) 00262 { 00263 assert(false); 00264 } 00265 else 00266 { 00267 size_t iMax=result._size1*result._size2; 00268 int i; 00269 for (i=0;i < iMax;i++) 00270 { 00271 result._data[i]+=o[i]; 00272 } 00273 } 00274 return result; 00275 }
marMatrix marMatrix::operator+ | ( | double | o | ) |
Definition at line 237 of file marMatrix.cpp.
References _data, _size1, and _size2.
00238 { 00239 marMatrix result(*this); 00240 00241 if ((result._size1==0) || (result._size2==0)) 00242 { 00243 assert(false); 00244 } 00245 else 00246 { 00247 size_t iMax=result._size1*result._size2; 00248 int i; 00249 for (i=0;i < iMax;i++) 00250 { 00251 result._data[i]+=o; 00252 } 00253 } 00254 return result; 00255 }
Definition at line 214 of file marMatrix.cpp.
References _data, _size1, and _size2.
00215 { 00216 marMatrix result(*this); 00217 00218 if ((o._size1!=result._size1) 00219 || (result._size1==0) 00220 || (o._size2!=result._size2) 00221 || (result._size2==0)) 00222 { 00223 assert(false); 00224 } 00225 else 00226 { 00227 size_t iMax=result._size1*result._size2; 00228 int i; 00229 for (i=0 ; i < iMax ; i++) 00230 { 00231 result._data[i]+=o._data[i]; 00232 } 00233 } 00234 return result; 00235 }
marMatrix marMatrix::operator- | ( | double * | o | ) |
Definition at line 322 of file marMatrix.cpp.
References _data, _size1, and _size2.
00323 { 00324 marMatrix result(*this); 00325 00326 if ((result._size1==0) || (result._size2==0)) 00327 { 00328 assert(false); 00329 } 00330 else 00331 { 00332 size_t iMax=result._size1*result._size2; 00333 int i; 00334 for (i=0;i < iMax;i++) 00335 { 00336 result._data[i]-=o[i]; 00337 } 00338 } 00339 return result; 00340 }
marMatrix marMatrix::operator- | ( | double | o | ) |
Definition at line 302 of file marMatrix.cpp.
References _data, _size1, and _size2.
00303 { 00304 marMatrix result(*this); 00305 00306 if ((result._size1==0) || (result._size2==0)) 00307 { 00308 assert(false); 00309 } 00310 else 00311 { 00312 size_t iMax=result._size1*result._size2; 00313 int i; 00314 for (i=0;i < iMax;i++) 00315 { 00316 result._data[i]-=o; 00317 } 00318 } 00319 return result; 00320 }
Definition at line 279 of file marMatrix.cpp.
References _data, _size1, and _size2.
00280 { 00281 marMatrix result(*this); 00282 00283 if ((o._size1!=result._size1) 00284 || (result._size1==0) 00285 || (o._size2!=result._size2) 00286 || (result._size2==0)) 00287 { 00288 assert(false); 00289 } 00290 else 00291 { 00292 size_t iMax=result._size1*result._size2; 00293 int i; 00294 for (i=0;i < iMax;i++) 00295 { 00296 result._data[i]-=o._data[i]; 00297 } 00298 } 00299 return result; 00300 }
marMatrix & marMatrix::operator= | ( | double * | o | ) |
Definition at line 165 of file marMatrix.cpp.
References _data, _size1, _size2, and shallowCopy.
00166 { 00167 if (_size1!=0 && _size2!=0) 00168 { 00169 if (!(_data==NULL)&&(!shallowCopy)) 00170 { 00171 delete _data; 00172 } 00173 shallowCopy=false; 00174 size_t iMax=_size1*_size2; 00175 _data=new double[iMax]; 00176 for (int i=0;i<iMax;i++) 00177 { 00178 _data[i]=o[i]; 00179 } 00180 } 00181 else 00182 { 00183 assert(false); 00184 } 00185 return (*this); 00186 }
marMatrix & marMatrix::operator= | ( | double | o | ) |
Definition at line 142 of file marMatrix.cpp.
References _data, _size1, _size2, and shallowCopy.
00143 { 00144 if (_size1!=0 && _size2!=0) 00145 { 00146 if (!(_data==NULL)&&(!shallowCopy)) 00147 { 00148 delete _data; 00149 } 00150 shallowCopy=false; 00151 size_t iMax=_size1*_size2; 00152 _data=new double[iMax]; 00153 for (int i=0;i<iMax;i++) 00154 { 00155 _data[i]=o; 00156 } 00157 } 00158 else 00159 { 00160 assert(false); 00161 } 00162 return (*this); 00163 }
Definition at line 122 of file marMatrix.cpp.
References _data, _size1, _size2, and shallowCopy.
00123 { 00124 _size1=o._size1; 00125 _size2=o._size2; 00126 if (!(_data==NULL)&&(!shallowCopy)) 00127 { 00128 delete _data; 00129 } 00130 shallowCopy=false; 00131 size_t iMax=_size1*_size2; 00132 _data=new double[iMax]; 00133 00134 int i; 00135 for (i=0;i<iMax;i++) 00136 { 00137 _data[i]=o._data[i]; 00138 } 00139 return (*this); 00140 }
bool marMatrix::operator== | ( | const marMatrix & | o | ) | const |
Definition at line 190 of file marMatrix.cpp.
size_t marMatrix::rows | ( | ) | const |
Definition at line 417 of file marMatrix.cpp.
References _size1.
00418 { 00419 return _size1; 00420 }
std::ostream& operator<< | ( | std::ostream & | os, | |
const marMatrix & | m | |||
) | [friend] |
double* marMatrix::_data [private] |
Definition at line 55 of file marMatrix.h.
Referenced by marMatrix(), operator double *(), operator()(), operator*(), operator+(), operator-(), operator<<(), operator=(), operator==(), and ~marMatrix().
size_t marMatrix::_size1 [private] |
Definition at line 53 of file marMatrix.h.
Referenced by marMatrix(), operator*(), operator+(), operator-(), operator<<(), operator=(), operator==(), and rows().
size_t marMatrix::_size2 [private] |
Definition at line 54 of file marMatrix.h.
Referenced by columns(), marMatrix(), operator()(), operator*(), operator+(), operator-(), operator<<(), operator=(), and operator==().
bool marMatrix::shallowCopy [private] |
Definition at line 52 of file marMatrix.h.
Referenced by operator=(), and ~marMatrix().