Kalman::KMatrix< T, BEG, DBG > Class Template Reference

Minimalist matrix template class. More...

#include <kmatrix.hpp>

List of all members.

Public Types

typedef T type
 Type of objects contained in the matrix.
enum  { beg = BEG }

Public Member Functions

void resize (K_UINT_32 m, K_UINT_32 n)
 Resizes the matrix. Resulting matrix contents are undefined.
KMatrixoperator= (const T &a)
 Assigns a copy of a to all elements of the matrix.
KMatrixoperator= (const KMatrix &M)
 Copy assignment operator. Performs a deep copy.
void assign (K_UINT_32 m, K_UINT_32 n, const T *v)
 Copies a C-style array of instances of T in an m by n matrix.
void swap (KMatrix &M)
 Constant-time swap function between two matrices.
Constructors and destructor.
 KMatrix ()
 Default constructor. Creates an empty matrix.
 KMatrix (K_UINT_32 m, K_UINT_32 n)
 Creates an m by n matrix of default instances of T.
 KMatrix (K_UINT_32 m, K_UINT_32 n, const T &a)
 Creates an m by n matrix of copies of a.
 KMatrix (K_UINT_32 m, K_UINT_32 n, const T *v)
 Creates an m by n matrix from an array of instances of T.
 KMatrix (const KMatrix &M)
 Copy constructor. Performs a deep copy.
 ~KMatrix ()
 Destructor.
Member access functions.
T & operator() (K_UINT_32 i, K_UINT_32 j)
 Returns the element (i,j).
const T & operator() (K_UINT_32 i, K_UINT_32 j) const
 Returns the element (i,j), const version.
K_UINT_32 nrow () const
 Returns m_, the number of rows of the matrix.
K_UINT_32 ncol () const
 Returns n_, the number of columns of the matrix.
Streaming functions
void get (std::istream &is)
 Reads a matrix from a stream.
void put (std::ostream &os) const
 Writes a matrix to a stream.


Detailed Description

template<typename T, K_UINT_32 BEG, bool DBG>
class Kalman::KMatrix< T, BEG, DBG >

Minimalist matrix template class.

This matrix class does not define any fancy linear algebra functions, nor even any operator between matrices. Its sole purpose is to well encapsulate an extensible array representing a matrix, and also to allow starting index to be 0 or 1.

Template parameters
Type requirements for T
This means that, if t1, t2 are instances of T, is is of type istream and os is of type ostream, the following expressions must be valid : -
 T(); T t1; 
Default constructor -
 T t1 = t2; T t1(t2); T(t1); 
Copy constructor -
 t1 = t2; 
Assignment operator -
 is >> t1; 
operator>>() -
 os << t1; 
operator<<() Finally, note that operator>>() and operator<<() must be compatible. Also, operator&() must not have been overloaded.


Member Enumeration Documentation

template<typename T, K_UINT_32 BEG, bool DBG>
anonymous enum
 

Enumerator:
beg  Starting index of matrix, either 0 or 1.


Constructor & Destructor Documentation

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KMatrix< T, BEG, DBG >::KMatrix K_UINT_32  m,
K_UINT_32  n
[inline]
 

Creates an m by n matrix of default instances of T.

Parameters:
m Number of rows in matrix. Can be 0.
n Number of columns in matrix. Can be 0.
Note:
If either m or n is 0, then both the number of rows and the number of columns will be set to 0.

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KMatrix< T, BEG, DBG >::KMatrix K_UINT_32  m,
K_UINT_32  n,
const T &  a
[inline]
 

Creates an m by n matrix of copies of a.

Parameters:
m Number of rows in matrix. Can be 0.
n Number of columns in matrix. Can be 0.
a Value to copy multiple times in the matrix.
Note:
If either m or n is 0, then both the number of rows and the number of columns will be set to 0.

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KMatrix< T, BEG, DBG >::KMatrix K_UINT_32  m,
K_UINT_32  n,
const T *  v
[inline]
 

Creates an m by n matrix from an array of instances of T.

This function allows to transform a C-style array of T objects in a KMatrix<T, BEG, DBG> equivalent array. Note that objects from the C-style array are copied into the matrix, which may slow down application if used extensively. The elements are copied row-wise, that is to say, the elements of the C-style array first fill the first row of the matrix, then the second, etc.

Parameters:
m Number of rows in matrix. Can be 0.
n Number of columns in matrix. Can be 0.
v Pointer to an m*n array of T objects.
Note:
If either m or n is 0, then both the number of rows and the number of columns will be set to 0.

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KMatrix< T, BEG, DBG >::KMatrix const KMatrix< T, BEG, DBG > &  M  )  [inline]
 

Copy constructor. Performs a deep copy.

Parameters:
M Matrix to copy. Can be an empty matrix.


Member Function Documentation

template<typename T, K_UINT_32 BEG, bool DBG>
T & Kalman::KMatrix< T, BEG, DBG >::operator() K_UINT_32  i,
K_UINT_32  j
[inline]
 

Returns the element (i,j).

Parameters:
i Row index of matrix element.
j Column index of matrix element.
Returns:
A reference to the element (i,j).
Exceptions:
OutOfBoundError Thrown if i or j is out of matrix bounds and DBG == true.

template<typename T, K_UINT_32 BEG, bool DBG>
const T & Kalman::KMatrix< T, BEG, DBG >::operator() K_UINT_32  i,
K_UINT_32  j
const [inline]
 

Returns the element (i,j), const version.

Parameters:
i Row index of matrix element.
j Column index of matrix element.
Returns:
A const reference to the element (i,j).
Exceptions:
OutOfBoundError Thrown if i or j is out of matrix bounds and DBG == true.

template<typename T, K_UINT_32 BEG, bool DBG>
K_UINT_32 Kalman::KMatrix< T, BEG, DBG >::nrow  )  const [inline]
 

Returns m_, the number of rows of the matrix.

Returns:
The number of rows in the matrix.

template<typename T, K_UINT_32 BEG, bool DBG>
K_UINT_32 Kalman::KMatrix< T, BEG, DBG >::ncol  )  const [inline]
 

Returns n_, the number of columns of the matrix.

Returns:
The number of columns in the matrix.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KMatrix< T, BEG, DBG >::resize K_UINT_32  m,
K_UINT_32  n
[inline]
 

Resizes the matrix. Resulting matrix contents are undefined.

Parameters:
m Number of rows in matrix. Can be 0.
n Number of columns in matrix. Can be 0.
Warning:
This function may invalidates pointers inside the matrix.
Note:
Resizing to a smaller size does not free any memory. To do so, one can swap the matrix to shrink with a temporary copy of itself : KMatrix<T, BEG, DBG>(M).swap(M).

If either m or n is 0, then both the number of rows and the number of columns will be set to 0.

template<typename T, K_UINT_32 BEG, bool DBG>
KMatrix< T, BEG, DBG > & Kalman::KMatrix< T, BEG, DBG >::operator= const T &  a  )  [inline]
 

Assigns a copy of a to all elements of the matrix.

Parameters:
a Instance to copy to each element of matrix.
Returns:
A reference to the matrix.

template<typename T, K_UINT_32 BEG, bool DBG>
KMatrix< T, BEG, DBG > & Kalman::KMatrix< T, BEG, DBG >::operator= const KMatrix< T, BEG, DBG > &  M  )  [inline]
 

Copy assignment operator. Performs a deep copy.

Parameters:
M Matrix to copy.
Returns:
A reference to the assigned matrix.
Warning:
This function invalidates pointers inside the matrix.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KMatrix< T, BEG, DBG >::assign K_UINT_32  m,
K_UINT_32  n,
const T *  v
[inline]
 

Copies a C-style array of instances of T in an m by n matrix.

The elements are copied row-wise, that is to say, the elements of the C-style array first fill the first row of the matrix, then the second, etc.

Parameters:
m Number of rows in matrix. Can be 0.
n Number of columns in matrix. Can be 0.
v Pointer to first element to copy from C-style array.
Warning:
This function invalidates pointers inside the vector.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KMatrix< T, BEG, DBG >::swap KMatrix< T, BEG, DBG > &  M  )  [inline]
 

Constant-time swap function between two matrices.

This function is fast, since it exchanges pointers to underlying implementation without copying any element.

Parameters:
M Matrix to swap.
Note:
No pointer is invalidated by this function. They still point to the same element, but in the other matrix.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KMatrix< T, BEG, DBG >::get std::istream &  is  )  [inline]
 

Reads a matrix from a stream.

This function will extract nrow()*ncol() elements from a stream to fill the matrix, while considering the formatting constraints of the current matrix printing context.

Parameters:
is A reference to the input stream.
See also:
createKMatrixContext()

selectKMatrixContext()

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KMatrix< T, BEG, DBG >::put std::ostream &  os  )  const [inline]
 

Writes a matrix to a stream.

This function will send all the matrix elements to a stream, while considering the formatting constraints of the current matrix printing context.

Parameters:
os A reference to the output stream.
See also:
createKMatrixContext()

selectKMatrixContext()


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 21:02:01 2006 for KFilter by  doxygen 1.4.5