Changeset 3327 in orxonox.OLD for orxonox/branches/parenting/src/matrix.cc
- Timestamp:
- Jan 3, 2005, 6:57:01 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/parenting/src/matrix.cc
r3326 r3327 21 21 #include "matrix.h" 22 22 23 inlineMatrix::Matrix (size_t row, size_t col)23 Matrix::Matrix (size_t row, size_t col) 24 24 { 25 25 _m = new base_mat( row, col, 0); … … 27 27 28 28 // copy constructor 29 inlineMatrix::Matrix (const Matrix& m)29 Matrix::Matrix (const Matrix& m) 30 30 { 31 31 _m = m._m; … … 34 34 35 35 // Internal copy constructor 36 inlinevoid Matrix::clone ()36 void Matrix::clone () 37 37 { 38 38 _m->Refcnt--; … … 41 41 42 42 // destructor 43 inlineMatrix::~Matrix ()43 Matrix::~Matrix () 44 44 { 45 45 if (--_m->Refcnt == 0) delete _m; … … 47 47 48 48 // assignment operator 49 inlineMatrix& Matrix::operator = (const Matrix& m)49 Matrix& Matrix::operator = (const Matrix& m) 50 50 { 51 51 m._m->Refcnt++; … … 56 56 57 57 // reallocation method 58 inlinevoid Matrix::realloc (size_t row, size_t col)58 void Matrix::realloc (size_t row, size_t col) 59 59 { 60 60 if (row == _m->RowSiz && col == _m->ColSiz) … … 80 80 81 81 // public method for resizing Matrix 82 inlinevoid Matrix::SetSize (size_t row, size_t col)82 void Matrix::SetSize (size_t row, size_t col) 83 83 { 84 84 size_t i,j; … … 101 101 102 102 // subscript operator to get/set individual elements 103 inlinefloat& Matrix::operator () (size_t row, size_t col)103 float& Matrix::operator () (size_t row, size_t col) 104 104 { 105 105 if (row >= _m->Row || col >= _m->Col) … … 110 110 111 111 // subscript operator to get/set individual elements 112 inlinefloat Matrix::operator () (size_t row, size_t col) const112 float Matrix::operator () (size_t row, size_t col) const 113 113 { 114 114 if (row >= _m->Row || col >= _m->Col) … … 118 118 119 119 // input stream function 120 i nline istream& operator >> (istream& istrm, Matrix& m)120 istream& operator >> (istream& istrm, Matrix& m) 121 121 { 122 122 for (size_t i=0; i < m.RowNo(); i++) … … 131 131 132 132 // output stream function 133 inlineostream& operator << (ostream& ostrm, const Matrix& m)133 ostream& operator << (ostream& ostrm, const Matrix& m) 134 134 { 135 135 for (size_t i=0; i < m.RowNo(); i++) … … 147 147 148 148 // logical equal-to operator 149 inlinebool operator == (const Matrix& m1, const Matrix& m2)149 bool operator == (const Matrix& m1, const Matrix& m2) 150 150 { 151 151 if (m1.RowNo() != m2.RowNo() || m1.ColNo() != m2.ColNo()) … … 161 161 162 162 // logical no-equal-to operator 163 inlinebool operator != (const Matrix& m1, const Matrix& m2)163 bool operator != (const Matrix& m1, const Matrix& m2) 164 164 { 165 165 return (m1 == m2) ? false : true; … … 167 167 168 168 // combined addition and assignment operator 169 inlineMatrix& Matrix::operator += (const Matrix& m)169 Matrix& Matrix::operator += (const Matrix& m) 170 170 { 171 171 if (_m->Row != m._m->Row || _m->Col != m._m->Col) … … 179 179 180 180 // combined subtraction and assignment operator 181 inlineMatrix& Matrix::operator -= (const Matrix& m)181 Matrix& Matrix::operator -= (const Matrix& m) 182 182 { 183 183 if (_m->Row != m._m->Row || _m->Col != m._m->Col) … … 191 191 192 192 // combined scalar multiplication and assignment operator 193 inlineMatrix&193 Matrix& 194 194 Matrix::operator *= (const float& c) 195 195 { … … 202 202 203 203 // combined Matrix multiplication and assignment operator 204 inlineMatrix&204 Matrix& 205 205 Matrix::operator *= (const Matrix& m) 206 206 { … … 223 223 224 224 // combined scalar division and assignment operator 225 inlineMatrix&225 Matrix& 226 226 Matrix::operator /= (const float& c) 227 227 { … … 235 235 236 236 // combined power and assignment operator 237 inlineMatrix&237 Matrix& 238 238 Matrix::operator ^= (const size_t& pow) 239 239 { … … 247 247 248 248 // unary negation operator 249 inlineMatrix249 Matrix 250 250 Matrix::operator - () 251 251 { … … 260 260 261 261 // binary addition operator 262 inlineMatrix262 Matrix 263 263 operator + (const Matrix& m1, const Matrix& m2) 264 264 { … … 269 269 270 270 // binary subtraction operator 271 inlineMatrix271 Matrix 272 272 operator - (const Matrix& m1, const Matrix& m2) 273 273 { … … 278 278 279 279 // binary scalar multiplication operator 280 inlineMatrix280 Matrix 281 281 operator * (const Matrix& m, const float& no) 282 282 { … … 288 288 289 289 // binary scalar multiplication operator 290 inlineMatrix290 Matrix 291 291 operator * (const float& no, const Matrix& m) 292 292 { … … 295 295 296 296 // binary Matrix multiplication operator 297 inlineMatrix297 Matrix 298 298 operator * (const Matrix& m1, const Matrix& m2) 299 299 { … … 304 304 305 305 // binary scalar division operator 306 inlineMatrix306 Matrix 307 307 operator / (const Matrix& m, const float& no) 308 308 { … … 312 312 313 313 // binary scalar division operator 314 inlineMatrix314 Matrix 315 315 operator / (const float& no, const Matrix& m) 316 316 { … … 319 319 320 320 // binary Matrix division operator 321 inlineMatrix321 Matrix 322 322 operator / (const Matrix& m1, const Matrix& m2) 323 323 { … … 326 326 327 327 // binary power operator 328 inlineMatrix328 Matrix 329 329 operator ^ (const Matrix& m, const size_t& pow) 330 330 { … … 335 335 336 336 // unary transpose operator 337 inlineMatrix337 Matrix 338 338 operator ~ (const Matrix& m) 339 339 { … … 350 350 351 351 // unary inversion operator 352 inlineMatrix352 Matrix 353 353 operator ! (const Matrix m) 354 354 { … … 358 358 359 359 // inversion function 360 inlineMatrix360 Matrix 361 361 Matrix::Inv () 362 362 { … … 405 405 406 406 // solve simultaneous equation 407 inlineMatrix407 Matrix 408 408 Matrix::Solve (const Matrix& v) const 409 409 { … … 451 451 452 452 // set zero to all elements of this Matrix 453 inlinevoid453 void 454 454 Matrix::Null (const size_t& row, const size_t& col) 455 455 { … … 467 467 468 468 // set zero to all elements of this Matrix 469 inlinevoid469 void 470 470 Matrix::Null() 471 471 { … … 478 478 479 479 // set this Matrix to unity 480 inlinevoid480 void 481 481 Matrix::Unit (const size_t& row) 482 482 { … … 494 494 495 495 // set this Matrix to unity 496 inlinevoid496 void 497 497 Matrix::Unit () 498 498 { … … 508 508 509 509 // private partial pivoting method 510 in line int510 int 511 511 Matrix::pivot (size_t row) 512 512 { … … 534 534 535 535 // calculate the determinant of a Matrix 536 inlinefloat536 float 537 537 Matrix::Det () const 538 538 { … … 565 565 566 566 // calculate the norm of a Matrix 567 inlinefloat567 float 568 568 Matrix::Norm () 569 569 { … … 579 579 580 580 // calculate the condition number of a Matrix 581 inlinefloat581 float 582 582 Matrix::Cond () 583 583 { … … 587 587 588 588 // calculate the cofactor of a Matrix for a given element 589 inlinefloat589 float 590 590 Matrix::Cofact (size_t row, size_t col) 591 591 { … … 622 622 623 623 // calculate adjoin of a Matrix 624 inlineMatrix624 Matrix 625 625 Matrix::Adj () 626 626 { … … 637 637 638 638 // Determine if the Matrix is singular 639 inlinebool639 bool 640 640 Matrix::IsSingular () 641 641 { … … 646 646 647 647 // Determine if the Matrix is diagonal 648 inlinebool648 bool 649 649 Matrix::IsDiagonal () 650 650 { … … 659 659 660 660 // Determine if the Matrix is scalar 661 inlinebool661 bool 662 662 Matrix::IsScalar () 663 663 { … … 672 672 673 673 // Determine if the Matrix is a unit Matrix 674 inlinebool674 bool 675 675 Matrix::IsUnit () 676 676 { … … 681 681 682 682 // Determine if this is a null Matrix 683 inlinebool683 bool 684 684 Matrix::IsNull () 685 685 { … … 692 692 693 693 // Determine if the Matrix is symmetric 694 inlinebool694 bool 695 695 Matrix::IsSymmetric () 696 696 { … … 705 705 706 706 // Determine if the Matrix is skew-symmetric 707 inlinebool707 bool 708 708 Matrix::IsSkewSymmetric () 709 709 { … … 718 718 719 719 // Determine if the Matrix is upper triangular 720 inlinebool720 bool 721 721 Matrix::IsUpperTriangular () 722 722 { … … 731 731 732 732 // Determine if the Matrix is lower triangular 733 inlinebool733 bool 734 734 Matrix::IsLowerTriangular () 735 735 {
Note: See TracChangeset
for help on using the changeset viewer.