#include <gmatrix.h>
Collaboration diagram for gmatrix::GMatrix< M, N, 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). | |
const 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) |
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<int 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 > | premul (const GVector< N, TYPE > &v) const |
operator* emulation. | |
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 325 of file gmatrix.h.
|
default constructor. Does nothing. Definition at line 342 of file gmatrix.h.
00342 { } |
|
copy constructor. Copy a matrix to this.
Definition at line 349 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00350 { 00351 for (int i=0; i<M; i++) { 00352 _m[i] = m._m[i]; 00353 } 00354 } |
|
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 586 of file gmatrix.h.
00587 {
00588 return _m[m];
00589 }
|
|
data access (ro). Retrieve the nth line vector. If n is out of bound the result is undefined
Definition at line 569 of file gmatrix.h.
00570 { 00571 GVector<M,TYPE> l; 00572 for (int i=0; i<M; i++) { 00573 l[i] = _m[i][n]; 00574 } 00575 return l; 00576 } |
|
vector multiplication. Multiply a matrix by a M column vector.
Definition at line 534 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::transpose().
00535 { 00536 GMatrix<N,M,TYPE> t = this->transpose(); 00537 GVector<N,TYPE> r; 00538 for (int n=0; n<N; n++) { 00539 r[n] = t[n]*v; 00540 } 00541 return r; 00542 } |
|
matrix multiplication. Multiply two matrices. If this is a MxN matrix, then the m matrix should be a PxM matrix.
Definition at line 516 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::transpose().
00517 { 00518 GMatrix<N,M,TYPE> s = this->transpose(); 00519 GMatrix<P,N,TYPE> r; 00520 for (int p=0; p<P; p++) { 00521 for (int n=0; n<N; n++) { 00522 r[p][n] = m[p] * s[n]; 00523 } 00524 } 00525 return r; 00526 } |
|
multiplication (scalar). Multiply the current matrix by a scalar
Definition at line 424 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00425 { 00426 GMatrix<M,N,TYPE> r; 00427 for (int i=0; i<M; i++) { 00428 r._m[i] = _m[i] * k; 00429 } 00430 return r; 00431 } |
|
multiplication (scalar). Multiply the current matrix by a scalar
Definition at line 490 of file gmatrix.h.
00491 { 00492 for (int i=0; i<M; i++) { 00493 _m[i] *= k; 00494 } 00495 } |
|
addition. Add two matrices
Definition at line 394 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00395 { 00396 GMatrix<M,N,TYPE> r; 00397 for (int i=0; i<M; i++) { 00398 r._m[i] = _m[i] + m._m[i]; 00399 } 00400 return r; 00401 } |
|
addition. Add two matrices
Definition at line 466 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00467 { 00468 for (int i=0; i<M; i++) { 00469 _m[i] += m._m[i]; 00470 } 00471 } |
|
substraction. Sub two matrices
Definition at line 409 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00410 { 00411 GMatrix<M,N,TYPE> r; 00412 for (int i=0; i<M; i++) { 00413 r._m[i] = _m[i] - m._m[i]; 00414 } 00415 return r; 00416 } |
|
substraction. Sub two matrices
Definition at line 478 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00479 { 00480 for (int i=0; i<M; i++) { 00481 _m[i] -= m._m[i]; 00482 } 00483 } |
|
divide (scalar). Divide the current matrix by a scalar. If k is 0 the result is undefined
Definition at line 439 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00440 { 00441 GMatrix<M,N,TYPE> r; 00442 for (int i=0; i<M; i++) { 00443 r._m[i] = _m[i] / k; 00444 } 00445 return r; 00446 } |
|
divide (scalar). Divide the current matrix by a scalar. If k is 0 the result is undefined
Definition at line 502 of file gmatrix.h.
00503 { 00504 for (int i=0; i<M; i++) { 00505 _m[i] /= k; 00506 } 00507 } |
|
copy (operator=). Copy a matrix to this.
Definition at line 453 of file gmatrix.h. References gmatrix::GMatrix< M, N, TYPE >::_m.
00454 { 00455 for (int i=0; i<M; i++) { 00456 _m[i] = m._m[i]; 00457 } 00458 return *this; 00459 } |
|
data acces (ro). Data access - read only version.
Definition at line 370 of file gmatrix.h.
00370 { return _m[m]; }
|
|
data acces (r/w). Data access - read/write version.
Definition at line 362 of file gmatrix.h.
00362 { return _m[m]; }
|
|
operator* emulation. multiply a vector v by the current matrix. Adding a premul function was necessary beacause the VC6 compiler have to way to find the difference between operator*(TYPE, GMatrix<TYPE<) and operator*(GVector<TYPE<,GMatrix<TYPE<).
Definition at line 553 of file gmatrix.h.
00554 { 00555 GVector<M,TYPE> r; 00556 for (int m=0; m<M; m++) { 00557 r[m] = v*_m[m]; 00558 } 00559 return r; 00560 } |
|
matrix transpose. transpose the current matrix
Definition at line 377 of file gmatrix.h. Referenced by gmatrix::GMatrix< M, N, TYPE >::operator *().
00378 { 00379 GMatrix<N,M,TYPE> r; 00380 for (int i=0; i<M; i++) { 00381 for (int j=0;j<N;j++) { 00382 r[j][i] = _m[i][j]; 00383 } 00384 } 00385 return r; 00386 } |