#include <gmatrix.h>
Collaboration diagram for GMatrix< M, M, TYPE >:
Public Member Functions | |
GMatrix () | |
default constructor. | |
GMatrix (const GMatrix< M, N, TYPE > &m) | |
copy constructor. | |
GVector< N, TYPE > & | operator[] (int m) |
data acces (r/w). | |
GVector< N, TYPE > | operator[] (int m) const |
data acces (ro). | |
GMatrix< N, M, TYPE > | transpose () const |
matrix transpose. | |
GMatrix< M, N, TYPE > | operator+ (const GMatrix< M, N, TYPE > &m) const |
addition. | |
GMatrix< M, N, TYPE > | operator- (const GMatrix< M, N, TYPE > &m) const |
substraction. | |
GMatrix< M, N, TYPE > | operator * (const TYPE &k) const |
multiplication (scalar). | |
GMatrix< M, N, TYPE > | operator/ (const TYPE &k) const |
divide (scalar). | |
GMatrix< M, N, TYPE > & | operator= (const GMatrix< M, N, TYPE > &m) const |
copy (operator=). | |
void | operator+= (const GMatrix< M, N, TYPE > &m) |
addition. | |
void | operator-= (const GMatrix< M, N, TYPE > &m) |
substraction. | |
void | operator *= (const TYPE &k) |
multiplication (scalar). | |
void | operator/= (const TYPE &k) |
divide (scalar). | |
template<class P> GMatrix< P, N, TYPE > | operator * (const GMatrix< P, M, TYPE > &m) const |
matrix multiplication. | |
GVector< N, TYPE > | operator * (const GVector< M, TYPE > &v) const |
vector multiplication. | |
GVector< M, TYPE > | line (int n) const |
data access (ro). | |
GVector< N, TYPE > | column (int m) const |
data access (ro). |
The GMatrix<> class implements a MxN matrix and all the classical related operations : transpose, math operators, data access and so on. As the GVector<> class, it is intended for a mathematic usage.
M | number of column in the matrix |
N | number of lines in the matrix |
TYPE | the underlying data type (default is float) |
Definition at line 299 of file gmatrix.h.
|
default constructor. Does nothing. Definition at line 316 of file gmatrix.h.
00316 { } |
|
copy constructor. Copy a matrix to this.
Definition at line 323 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00324 { 00325 for (int i=0; i<M; i++) { 00326 _m[i] = m._m[i]; 00327 } 00328 } |
|
data access (ro). Retrieve the mth columns vector. If m is out of bound the result is undefined. This function is similar to the [] operator
Definition at line 545 of file gmatrix.h.
00546 {
00547 return _m[m];
00548 }
|
|
data access (ro). Retrieve the nth line vector. If n is out of bound the result is undefined
Definition at line 528 of file gmatrix.h.
00529 { 00530 GVector<M,TYPE> l; 00531 for (int i=0; i<M; i++) { 00532 l[i] = _m[i][n]; 00533 } 00534 return l; 00535 } |
|
vector multiplication. Multiply a matrix by a M column vector.
Definition at line 510 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m, and GMatrix< M, M, TYPE >::transpose().
00511 { 00512 GMatrix<N,M,TYPE> t = this->transpose(); 00513 GVector<N,TYPE> r; 00514 for (int n=0; n<N, n++) 00515 { 00516 r[n] = t._m[n]*v; 00517 } 00518 return r; 00519 } |
|
matrix multiplication. Multiply two matrices. If this is a MxN matrix, then the m matrix should be a PxM matrix.
Definition at line 492 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m, and GMatrix< M, M, TYPE >::transpose().
00493 { 00494 GMatrix<N,M,TYPE> s = this->transpose(); 00495 GMatrix<P,N,TYPE> r; 00496 for (int p=0; p<P; p++) { 00497 for (int n=0; n<N; n++) { 00498 r._m[p][n] = m.m[p] * s._m[n]; 00499 } 00500 } 00501 return r; 00502 } |
|
multiplication (scalar). Multiply the current matrix by a scalar
Definition at line 399 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00400 { 00401 GMatrix<M,N,TYPE> r; 00402 for (int i=0; i<M; i++) { 00403 r._m[i] = _m[i] * k; 00404 } 00405 return r; 00406 } |
|
multiplication (scalar). Multiply the current matrix by a scalar
Definition at line 465 of file gmatrix.h.
00466 { 00467 for (int i=0; i<M; i++) { 00468 _m[i] *= k; 00469 } 00470 } |
|
addition. Add two matrices
Definition at line 369 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00370 { 00371 GMatrix<M,N,TYPE> r; 00372 for (int i=0; i<M; i++) { 00373 r._m[i] = _m[i] + m._m[i]; 00374 } 00375 return r; 00376 } |
|
addition. Add two matrices
Definition at line 441 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00442 { 00443 for (int i=0; i<M; i++) { 00444 _m[i] += m._m[i]; 00445 } 00446 } |
|
substraction. Sub two matrices
Definition at line 384 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00385 { 00386 GMatrix<M,N,TYPE> r; 00387 for (int i=0; i<M; i++) { 00388 r._m[i] = _m[i] - m._m[i]; 00389 } 00390 return r; 00391 } |
|
substraction. Sub two matrices
Definition at line 453 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00454 { 00455 for (int i=0; i<M; i++) { 00456 _m[i] -= m._m[i]; 00457 } 00458 } |
|
divide (scalar). Divide the current matrix by a scalar. If k is 0 the result is undefined
Definition at line 414 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00415 { 00416 GMatrix<M,N,TYPE> r; 00417 for (int i=0; i<M; i++) { 00418 r._m[i] = _m[i] / k; 00419 } 00420 return r; 00421 } |
|
divide (scalar). Divide the current matrix by a scalar. If k is 0 the result is undefined
Definition at line 477 of file gmatrix.h.
00478 { 00479 for (int i=0; i<M; i++) { 00480 _m[i] /= k; 00481 } 00482 } |
|
copy (operator=). Copy a matrix to this.
Definition at line 428 of file gmatrix.h. References GMatrix< M, M, TYPE >::_m.
00429 { 00430 for (int i=0; i<M; i++) { 00431 _m[i] = m._m[i]; 00432 } 00433 return *this; 00434 } |
|
data acces (ro). Data access - read only version.
Definition at line 344 of file gmatrix.h.
00344 { return _m[m]; }
|
|
data acces (r/w). Data access - read/write version.
Definition at line 336 of file gmatrix.h.
00336 { return _m[m]; }
|
|
matrix transpose. transpose the current matrix
Definition at line 351 of file gmatrix.h. Referenced by GMatrix< M, M, TYPE >::operator *().
00352 { 00353 GMatrix<N,M,TYPE> r; 00354 00355 for (int i=0; i<M; i++) { 00356 for (int j=0;j<N;j++) { 00357 r[j][i] = _m[i][j]; 00358 } 00359 } 00360 return r; 00361 } |