#include <matrix.h>

| Public Member Functions | |
| ~TMatrix () | |
| Destructor. | |
| T & | operator() (uint i, uint j) | 
| Reference operator. | |
| uint | GetN () | 
| Columns. | |
| uint | GetM () | 
| Rows. | |
| T ** | GetAnsiRef () | 
| Returns the ANSI (C/C++) reference. | |
| T | Det () | 
| Determinant. | |
| void | LoadIdentity () | 
| Loads identity. | |
| TMatrix (uint N=3, uint M=3, T data=(T) 0) | |
| Default constructor. | |
| TMatrix (const TMatrix< T > &r) | |
| Copy constructor. | |
| TMatrix (T **block, uint N, uint M) | |
| ANSI casting constructor. | |
| TMatrix< T > & | operator= (const TMatrix< T > &r) | 
| Natural assignation. | |
| TMatrix< T > & | operator= (TVector< T > &r) | 
| Vector assignation. | |
| TMatrix< T > & | operator= (T r) | 
| Scalar assignation. | |
| bool | operator== (const TMatrix< T > &r) | 
| Equality. | |
| bool | operator!= (const TMatrix< T > &r) | 
| Inequality. | |
| TMatrix< T > | operator+ (const TMatrix< T > &r) | 
| Addition. | |
| TMatrix< T > | operator- (const TMatrix< T > &r) | 
| Substraction. | |
| TMatrix< T > | operator * (const TMatrix< T > &r) | 
| Product. | |
| TMatrix< T > | operator * (TVector< T > &r) | 
| Product (vector). | |
| TMatrix< T > | operator * (T r) | 
| Scalar product. | |
| TMatrix< T > & | operator+= (const TMatrix< T > &r) | 
| Addition. | |
| TMatrix< T > & | operator-= (const TMatrix< T > &r) | 
| Substraction. | |
| TMatrix< T > & | operator *= (const TMatrix< T > &r) | 
| Product. | |
| TMatrix< T > & | operator *= (TVector< T > &r) | 
| Product (vector). | |
| TMatrix< T > & | operator *= (T r) | 
| Scalar product. | |
| TMatrix< T > | operator- () | 
| Additive inverse. | |
| TMatrix< T > | operator! () | 
| Matrix inverse. | |
| TMatrix< T > | operator~ () | 
| Matrix transpose. | |
| Private Attributes | |
| T ** | _matrix | 
| Matrix' internal state. | |
| uint | _N | 
| Columns. | |
| uint | _M | 
| Rows. | |
This class defines a C++ template to use mathematical matrices of NxM.
Definition at line 39 of file matrix.h.
| gtm::TMatrix< T >::TMatrix | ( | uint | N = 3, | |
| uint | M = 3, | |||
| T | data = ( T )0 | |||
| ) |  [inline] | 
Default constructor.
Constructors.
| N | Columns. | |
| M | Rows. | |
| data | Initial data. | |
| r | Copy object (matrix or vector). | |
| block | Memory block. | 
Definition at line 214 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00215 { 00216 _N = N; 00217 _M = M; 00218 _matrix = MatrixAllocateMemory< T >( _N, _M ); 00219 MatrixAssignScalar< T >( _matrix, data, _N, _M ); 00220 00221 }
| gtm::TMatrix< T >::TMatrix | ( | const TMatrix< T > & | r | ) |  [inline] | 
Copy constructor.
Definition at line 225 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00226 { 00227 _N = r._N; 00228 _M = r._M; 00229 _matrix = MatrixCopyMemory< T >( r._matrix, _N, _M ); 00230 00231 }
| gtm::TMatrix< T >::TMatrix | ( | T ** | block, | |
| uint | N, | |||
| uint | M | |||
| ) |  [inline] | 
ANSI casting constructor.
Definition at line 235 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00236 { 00237 _N = N; 00238 _M = M; 00239 _matrix = MatrixCopyMemory< T >( block, N, M ); 00240 00241 }
| gtm::TMatrix< T >::~TMatrix | ( | ) |  [inline] | 
Destructor.
Definition at line 61 of file matrix.h.
References gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
| TMatrix< T > & gtm::TMatrix< T >::operator= | ( | const TMatrix< T > & | r | ) |  [inline] | 
Natural assignation.
Assignation operators.
| r | Right object (matrix, vector or scalar). | 
Definition at line 245 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00246 { 00247 if( _N != r._N || _M != r._M ) { 00248 00249 MatrixFreeMemory< T >( _matrix, _N ); 00250 _N = r._N; 00251 _M = r._M; 00252 _matrix = MatrixCopyMemory< T >( r._matrix, _N, _M ); 00253 00254 } else MatrixAssignMemory< T >( _matrix, r._matrix, _N, _M ); 00255 return( *this ); 00256 00257 }
| TMatrix< T > & gtm::TMatrix< T >::operator= | ( | TVector< T > & | r | ) |  [inline] | 
Vector assignation.
Definition at line 261 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, gtm::TMatrix< T >::_N, COL_VECTOR, gtm::TVector< T >::GetN(), and gtm::TVector< T >::GetType().
00262 { 00263 uint i; 00264 uint n = r.GetN( ); 00265 bool column = ( r.GetType( ) == COL_VECTOR ); 00266 00267 MatrixFreeMemory< T >( _matrix, _N ); 00268 _N = ( column )? 1: n; 00269 _M = ( column )? n: 1; 00270 _matrix = MatrixAllocateMemory< T >( _N, _M ); 00271 for( i = 0; i < n; _matrix[ ( column )? 0: i ][ ( column )? i: 0 ] = r( i ), i++ ); 00272 return( *this ); 00273 00274 }

| TMatrix< T > & gtm::TMatrix< T >::operator= | ( | T | r | ) |  [inline] | 
Scalar assignation.
Definition at line 278 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
| bool gtm::TMatrix< T >::operator== | ( | const TMatrix< T > & | r | ) |  [inline] | 
Equality.
Comparation operators.
| Right | matrix. | 
Definition at line 287 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00288 { 00289 uint i, j; 00290 bool ret; 00291 00292 for( 00293 i = 0, ret = ( _N == r._N && _M == r._M ); 00294 i < _N && ret; 00295 i++ 00296 ) for( 00297 j = 0; 00298 j < _M && ret; 00299 ret &= ( _matrix[ i ][ j ] == r._matrix[ i ][ j ] ), j++ 00300 ); 00301 return( ret ); 00302 00303 }
| bool gtm::TMatrix< T >::operator!= | ( | const TMatrix< T > & | r | ) |  [inline] | 
Inequality.
Definition at line 307 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00308 { 00309 uint i, j; 00310 bool ret; 00311 00312 for( 00313 i = 0, ret = ( _N != r._N || _M != r._M ); 00314 i < _N && !ret; 00315 i++ 00316 ) for( 00317 j = 0; 00318 j < _M && !ret; 00319 ret |= ( _matrix[ i ][ j ] != r._matrix[ i ][ j ] ), j++ 00320 ); 00321 return( ret ); 00322 00323 }
| T& gtm::TMatrix< T >::operator() | ( | uint | i, | |
| uint | j | |||
| ) |  [inline] | 
Reference operator.
Definition at line 90 of file matrix.h.
References gtm::TMatrix< T >::_matrix.
00090 { 00091 return( _matrix[ i ][ j ] ); 00092 };
| uint gtm::TMatrix< T >::GetN | ( | ) |  [inline] | 
Columns.
Definition at line 94 of file matrix.h.
References gtm::TMatrix< T >::_N.
Referenced by gtm::TVector< T >::operator=().
00094 { 00095 return( _N ); 00096 };

| uint gtm::TMatrix< T >::GetM | ( | ) |  [inline] | 
Rows.
Definition at line 98 of file matrix.h.
References gtm::TMatrix< T >::_M.
Referenced by gtm::TVector< T >::operator=().
00098 { 00099 return( _M ); 00100 };

| T** gtm::TMatrix< T >::GetAnsiRef | ( | ) |  [inline] | 
Returns the ANSI (C/C++) reference.
Definition at line 102 of file matrix.h.
References gtm::TMatrix< T >::_matrix.
00102 { 00103 return( _matrix ); 00104 };
| T gtm::TMatrix< T >::Det | ( | ) |  [inline] | 
Determinant.
Definition at line 106 of file matrix.h.
References gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
Referenced by UtilVtk3DGeometriSelection::IntersectPlaneWithLine(), and vtk3DSurfaceSTLWidget::IntersectPlaneWithLine().

| void gtm::TMatrix< T >::LoadIdentity | ( | ) |  [inline] | 
Loads identity.
Definition at line 110 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, gtm::TMatrix< T >::_N, and GTM_MIN.
| TMatrix< T > gtm::TMatrix< T >::operator+ | ( | const TMatrix< T > & | r | ) |  [inline] | 
Addition.
Binary operators.
| r | Right objet (matrix, vector or scalar). | 
Definition at line 327 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, gtm::TMatrix< T >::_N, and GTM_MIN.
00328 { 00329 TMatrix< T > ret( _N, _M ); 00330 00331 MatrixAdd< T >( 00332 ret._matrix, 00333 _matrix, 00334 r._matrix, 00335 GTM_MIN( _N, r._N ), 00336 GTM_MIN( _M, r._M ) 00337 ); 00338 return( ret ); 00339 00340 }
| TMatrix< T > gtm::TMatrix< T >::operator- | ( | const TMatrix< T > & | r | ) |  [inline] | 
Substraction.
Definition at line 344 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, gtm::TMatrix< T >::_N, and GTM_MIN.
00345 { 00346 TMatrix< T > ret( _N, _M ); 00347 00348 MatrixSubtract< T >( 00349 ret._matrix, 00350 _matrix, 00351 r._matrix, 00352 GTM_MIN( _N, r._N ), 00353 GTM_MIN( _M, r._M ) 00354 ); 00355 return( ret ); 00356 00357 }
| TMatrix< T > gtm::TMatrix< T >::operator * | ( | const TMatrix< T > & | r | ) |  [inline] | 
Product.
Definition at line 361 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00362 { 00363 TMatrix< T > ret( r._N, _M ); 00364 00365 MatrixProduct< T >( ret._matrix, _matrix, r._matrix, _N, _M, r._N ); 00366 return( ret ); 00367 00368 }
| TMatrix< T > gtm::TMatrix< T >::operator * | ( | TVector< T > & | r | ) |  [inline] | 
| TMatrix< T > gtm::TMatrix< T >::operator * | ( | T | r | ) |  [inline] | 
Scalar product.
Definition at line 372 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00373 { 00374 TMatrix< T > ret( _N, _M ); 00375 00376 MatrixScalarProduct< T >( ret._matrix, _matrix, r, _N, _M ); 00377 return( ret ); 00378 00379 }
| TMatrix< T >& gtm::TMatrix< T >::operator+= | ( | const TMatrix< T > & | r | ) |  [inline] | 
| TMatrix< T >& gtm::TMatrix< T >::operator-= | ( | const TMatrix< T > & | r | ) |  [inline] | 
| TMatrix< T >& gtm::TMatrix< T >::operator *= | ( | const TMatrix< T > & | r | ) |  [inline] | 
| TMatrix< T >& gtm::TMatrix< T >::operator *= | ( | TVector< T > & | r | ) |  [inline] | 
| TMatrix< T >& gtm::TMatrix< T >::operator *= | ( | T | r | ) |  [inline] | 
| TMatrix< T > gtm::TMatrix< T >::operator- | ( | ) |  [inline] | 
Additive inverse.
Unary operators.
Definition at line 393 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00394 { 00395 TMatrix< T > ret( _N, _M ); 00396 uint i, j; 00397 00398 for( i = 0; i < _N; i++ ) 00399 for( j = 0; j < _M; ret._matrix[ i ][ j ] = ( T )0 - _matrix[ i ][ j ], j++ ); 00400 return( ret ); 00401 00402 }
| TMatrix< T > gtm::TMatrix< T >::operator! | ( | ) |  [inline] | 
Matrix inverse.
Definition at line 406 of file matrix.h.
References gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00407 { 00408 TMatrix< T > ret( _N, _N ); 00409 00410 if( _N <= 4 ) MatrixInverseAdjoint< T >( ret._matrix, _matrix, _N ); 00411 else MatrixInverseGauss< T >( ret._matrix, _matrix, _N ); 00412 return( ret ); 00413 00414 }
| TMatrix< T > gtm::TMatrix< T >::operator~ | ( | ) |  [inline] | 
Matrix transpose.
Definition at line 418 of file matrix.h.
References gtm::TMatrix< T >::_M, gtm::TMatrix< T >::_matrix, and gtm::TMatrix< T >::_N.
00419 { 00420 TMatrix< T > ret( _M, _N ); 00421 00422 MatrixTranspose< T >( ret._matrix, _matrix, _N, _M ); 00423 return( ret ); 00424 00425 }
| T** gtm::TMatrix< T >::_matrix  [private] | 
Matrix' internal state.
Memory block.
Definition at line 179 of file matrix.h.
Referenced by gtm::TMatrix< T >::Det(), gtm::TMatrix< T >::GetAnsiRef(), gtm::TMatrix< T >::LoadIdentity(), gtm::TMatrix< T >::operator *(), gtm::TMatrix< T >::operator!(), gtm::TMatrix< T >::operator!=(), gtm::TMatrix< T >::operator()(), gtm::TMatrix< T >::operator+(), gtm::TMatrix< T >::operator-(), gtm::TMatrix< T >::operator=(), gtm::TMatrix< T >::operator==(), gtm::TMatrix< T >::operator~(), gtm::TMatrix< T >::TMatrix(), and gtm::TMatrix< T >::~TMatrix().
| uint gtm::TMatrix< T >::_N  [private] | 
Columns.
Definition at line 181 of file matrix.h.
Referenced by gtm::TMatrix< T >::Det(), gtm::TMatrix< T >::GetN(), gtm::TMatrix< T >::LoadIdentity(), gtm::TMatrix< T >::operator *(), gtm::TMatrix< T >::operator!(), gtm::TMatrix< T >::operator!=(), gtm::TMatrix< T >::operator+(), gtm::TMatrix< T >::operator-(), gtm::TMatrix< T >::operator=(), gtm::TMatrix< T >::operator==(), gtm::TMatrix< T >::operator~(), gtm::TMatrix< T >::TMatrix(), and gtm::TMatrix< T >::~TMatrix().
| uint gtm::TMatrix< T >::_M  [private] | 
Rows.
Definition at line 183 of file matrix.h.
Referenced by gtm::TMatrix< T >::GetM(), gtm::TMatrix< T >::LoadIdentity(), gtm::TMatrix< T >::operator *(), gtm::TMatrix< T >::operator!=(), gtm::TMatrix< T >::operator+(), gtm::TMatrix< T >::operator-(), gtm::TMatrix< T >::operator=(), gtm::TMatrix< T >::operator==(), gtm::TMatrix< T >::operator~(), and gtm::TMatrix< T >::TMatrix().
 1.5.3
 1.5.3