#include <tnt_matrix.h>
Public Types | |
| typedef Subscript | size_type |
| typedef T | value_type |
| typedef T | element_type |
| typedef T * | pointer |
| typedef T * | iterator |
| typedef T & | reference |
| typedef const T * | const_iterator |
| typedef const T & | const_reference |
Public Member Functions | |
| Subscript | lbound () const |
| operator T ** () | |
| operator const T ** () const | |
| Subscript | size () const |
| Matrix (const Matrix< T > &A) | |
| Matrix (Subscript M, Subscript N, const T &value=T(0)) | |
| Matrix (Subscript M, Subscript N, const T *v) | |
| Matrix (Subscript M, Subscript N, const char *s) | |
| Matrix< T > & | newsize (Subscript M, Subscript N) |
| Matrix< T > & | operator= (const Matrix< T > &B) |
| Matrix< T > & | operator= (const T &scalar) |
| Subscript | dim (Subscript d) const |
| Subscript | num_rows () const |
| Subscript | num_cols () const |
| T * | operator[] (Subscript i) |
| const T * | operator[] (Subscript i) const |
| reference | operator() (Subscript i) |
| const_reference | operator() (Subscript i) const |
| reference | operator() (Subscript i, Subscript j) |
| const_reference | operator() (Subscript i, Subscript j) const |
| Vector< T > | diag () const |
| Matrix< T > | upper_triangular () const |
| Matrix< T > | lower_triangular () const |
Dense matrix class for basic linear algebra operations.
Ordering: row major.
Elements begin at (1,1) or [0][0].
Can be interfaced with C multidimentionsal arrays (e.g. double **)
copy-by-value semantics.
Optional range checking at compile time via TNT_BOUNDS_CHECK macro.
| TNT::Matrix< T >::Matrix | ( | Subscript | M, | |
| Subscript | N, | |||
| const T & | value = T(0) | |||
| ) | [inline] |
Create a MxN matrix, with each element assigned to the value 0.
| M | the number of rows | |
| N | the number of columns | |
| value | (optional default value: 0 if not specified. |
| TNT::Matrix< T >::Matrix | ( | Subscript | M, | |
| Subscript | N, | |||
| const T * | v | |||
| ) | [inline] |
Create an MxN matrix, filling in values (row-major order) from
the list (C array) provided.
| M | the number of rows | |
| N | the number of columns | |
| v | list (C array) of M*N values used to initialize matrix. |
| TNT::Matrix< T >::Matrix | ( | Subscript | M, | |
| Subscript | N, | |||
| const char * | s | |||
| ) | [inline] |
Create an MxN matrix, filling in values (row-major order) from
a character string.
| M | the number of rows | |
| N | the number of columns | |
| s | string of M*N values used to initialize matrix. |
| Matrix<T>& TNT::Matrix< T >::newsize | ( | Subscript | M, | |
| Subscript | N | |||
| ) | [inline] |
Change size of matrix to MxN, reallocating memory if necessary.
NOTE: This operations occurs in place, i.e. when resizing to
a new matrix, original matrix elements
are NOT retained. Instead, one must explicit create
a new matrix of this size and manually copy the elements, e.g.
Matrix double B(M, N);
int min_M = M < A.num_rows() ? M : A.num_rows();
int min_N = N < A.num_cols() ? N : A.num_cols();
for (int i=1; i<=min_M; i++)
for (int j=1; j<=min_N; j++)
B(i,j) = A(i,j);
A.destroy();
| M | the number of rows of new size. | |
| N | the number of columns of new size. |
| Matrix<T>& TNT::Matrix< T >::operator= | ( | const Matrix< T > & | B | ) | [inline] |
Assign (copy) one matrix to another, e.g. A=B. The
contents of A are lost, and a new copy of B is created.
| B | to matrix to be copied. |
| Subscript TNT::Matrix< T >::size | ( | ) | const [inline] |
1.6.1