TNT::Matrix< T > Class Template Reference

#include <tnt_matrix.h>

Collaboration diagram for TNT::Matrix< T >:
[legend]

List of all members.

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 ()
 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 ()
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

Private Member Functions

void initialize (Subscript M, Subscript N)
void copy (const T *v)
void set (const T &val)
void destroy ()

Private Attributes

Subscript m_
Subscript n_
Subscript mn_
T * v_
T ** row_
T * vm1_
T ** rowm1_


Detailed Description

template<class T>
class TNT::Matrix< T >

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.

Definition at line 56 of file tnt_matrix.h.


Member Typedef Documentation

template<class T>
typedef const T* TNT::Matrix< T >::const_iterator

Definition at line 175 of file tnt_matrix.h.

template<class T>
typedef const T& TNT::Matrix< T >::const_reference

Definition at line 176 of file tnt_matrix.h.

template<class T>
typedef T TNT::Matrix< T >::element_type

Definition at line 171 of file tnt_matrix.h.

template<class T>
typedef T* TNT::Matrix< T >::iterator

Definition at line 173 of file tnt_matrix.h.

template<class T>
typedef T* TNT::Matrix< T >::pointer

Definition at line 172 of file tnt_matrix.h.

template<class T>
typedef T& TNT::Matrix< T >::reference

Definition at line 174 of file tnt_matrix.h.

template<class T>
typedef Subscript TNT::Matrix< T >::size_type

Definition at line 169 of file tnt_matrix.h.

template<class T>
typedef T TNT::Matrix< T >::value_type

Definition at line 170 of file tnt_matrix.h.


Constructor & Destructor Documentation

template<class T>
TNT::Matrix< T >::Matrix (  )  [inline]

Definition at line 194 of file tnt_matrix.h.

template<class T>
TNT::Matrix< T >::Matrix ( const Matrix< T > &  A  )  [inline]

Definition at line 196 of file tnt_matrix.h.

template<class T>
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.

Parameters:
M the number of rows
N the number of columns
value (optional default value: 0 if not specified.

Definition at line 210 of file tnt_matrix.h.

template<class T>
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.

Parameters:
M the number of rows
N the number of columns
v list (C array) of M*N values used to initialize matrix.

Definition at line 224 of file tnt_matrix.h.

template<class T>
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.

Parameters:
M the number of rows
N the number of columns
s string of M*N values used to initialize matrix.

Definition at line 238 of file tnt_matrix.h.

template<class T>
TNT::Matrix< T >::~Matrix (  )  [inline]

Definition at line 253 of file tnt_matrix.h.


Member Function Documentation

template<class T>
void TNT::Matrix< T >::copy ( const T *  v  )  [inline, private]

Definition at line 98 of file tnt_matrix.h.

template<class T>
void TNT::Matrix< T >::destroy (  )  [inline, private]

Definition at line 153 of file tnt_matrix.h.

template<class T>
Vector<T> TNT::Matrix< T >::diag (  )  const [inline]

Definition at line 407 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::dim ( Subscript  d  )  const [inline]

Definition at line 328 of file tnt_matrix.h.

template<class T>
void TNT::Matrix< T >::initialize ( Subscript  M,
Subscript  N 
) [inline, private]

Definition at line 71 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::lbound (  )  const [inline]

Definition at line 178 of file tnt_matrix.h.

template<class T>
Matrix<T> TNT::Matrix< T >::lower_triangular (  )  const

template<class T>
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();
				

Parameters:
M the number of rows of new size.
N the number of columns of new size.

Definition at line 282 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::num_cols (  )  const [inline]

Definition at line 338 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::num_rows (  )  const [inline]

Definition at line 337 of file tnt_matrix.h.

template<class T>
TNT::Matrix< T >::operator const T ** (  )  const [inline]

Definition at line 184 of file tnt_matrix.h.

template<class T>
TNT::Matrix< T >::operator T ** (  )  [inline]

Definition at line 183 of file tnt_matrix.h.

template<class T>
const_reference TNT::Matrix< T >::operator() ( Subscript  i,
Subscript  j 
) const [inline]

Definition at line 394 of file tnt_matrix.h.

template<class T>
reference TNT::Matrix< T >::operator() ( Subscript  i,
Subscript  j 
) [inline]

Definition at line 381 of file tnt_matrix.h.

template<class T>
const_reference TNT::Matrix< T >::operator() ( Subscript  i  )  const [inline]

Definition at line 370 of file tnt_matrix.h.

template<class T>
reference TNT::Matrix< T >::operator() ( Subscript  i  )  [inline]

Definition at line 361 of file tnt_matrix.h.

template<class T>
Matrix<T>& TNT::Matrix< T >::operator= ( const T &  scalar  )  [inline]

Definition at line 321 of file tnt_matrix.h.

template<class T>
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.

Parameters:
B to matrix to be copied.

Definition at line 303 of file tnt_matrix.h.

template<class T>
const T* TNT::Matrix< T >::operator[] ( Subscript  i  )  const [inline]

Definition at line 352 of file tnt_matrix.h.

template<class T>
T* TNT::Matrix< T >::operator[] ( Subscript  i  )  [inline]

Definition at line 343 of file tnt_matrix.h.

template<class T>
void TNT::Matrix< T >::set ( const T &  val  )  [inline, private]

Definition at line 124 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::size (  )  const [inline]

Returns:
the total number of items in matrix (M*N).

Definition at line 190 of file tnt_matrix.h.

template<class T>
Matrix<T> TNT::Matrix< T >::upper_triangular (  )  const


Member Data Documentation

template<class T>
Subscript TNT::Matrix< T >::m_ [private]

Definition at line 60 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::mn_ [private]

Definition at line 62 of file tnt_matrix.h.

template<class T>
Subscript TNT::Matrix< T >::n_ [private]

Definition at line 61 of file tnt_matrix.h.

template<class T>
T** TNT::Matrix< T >::row_ [private]

Definition at line 64 of file tnt_matrix.h.

template<class T>
T** TNT::Matrix< T >::rowm1_ [private]

Definition at line 66 of file tnt_matrix.h.

template<class T>
T* TNT::Matrix< T >::v_ [private]

Definition at line 63 of file tnt_matrix.h.

template<class T>
T* TNT::Matrix< T >::vm1_ [private]

Definition at line 65 of file tnt_matrix.h.


The documentation for this class was generated from the following file:

Generated on Fri Feb 6 13:30:19 2009 for CorAL by  doxygen 1.5.8