|
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. More...
|
|
KMatrix & | operator= (const T &a) |
| Assigns a copy of a to all elements of the matrix. More...
|
|
KMatrix & | operator= (const KMatrix &M) |
| Copy assignment operator. Performs a deep copy. More...
|
|
void | resize (K_UINT_32 m, K_UINT_32 n) |
| Resizes the matrix. Resulting matrix contents are undefined. More...
|
|
void | swap (KMatrix &M) |
| Constant-time swap function between two matrices. More...
|
|
|
| KMatrix () |
| Default constructor. Creates an empty matrix. More...
|
|
| KMatrix (K_UINT_32 m, K_UINT_32 n) |
| Creates an m by n matrix of default instances of T . More...
|
|
| KMatrix (K_UINT_32 m, K_UINT_32 n, const T &a) |
| Creates an m by n matrix of copies of a . More...
|
|
| 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 . More...
|
|
| KMatrix (const KMatrix &M) |
| Copy constructor. Performs a deep copy. More...
|
|
| ~KMatrix () |
| Destructor. More...
|
|
|
T & | operator() (K_UINT_32 i, K_UINT_32 j) |
| Returns the element (i,j) . More...
|
|
const T & | operator() (K_UINT_32 i, K_UINT_32 j) const |
| Returns the element (i,j) , const version. More...
|
|
K_UINT_32 | nrow () const |
| Returns m_, the number of rows of the matrix. More...
|
|
K_UINT_32 | ncol () const |
| Returns n_, the number of columns of the matrix. More...
|
|
|
void | get (std::istream &is) |
| Reads a matrix from a stream. More...
|
|
void | put (std::ostream &os) const |
| Writes a matrix to a stream. More...
|
|
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
T
: Type of elements contained in the matrix. Usually float
or double
.
BEG
: Starting index of matrix. Can be either 0 or 1.
DGB
: Debug flag. If true
, then bound-checking will be performed, and OutOfBoundError
exceptions can be thrown.
- Type requirements for T
T
must be default constructible.
T
must be assignable.
T
must be serializable.
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 :
Finally, note that operator>>()
and operator<<()
must be compatible. Also, operator&()
must not have been overloaded.
Definition at line 72 of file kmatrix.hpp.
template<typename T, K_UINT_32 BEG, bool DBG>
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.
Definition at line 172 of file kmatrix_impl.hpp.
template<typename T, K_UINT_32 BEG, bool DBG>
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.
Definition at line 320 of file kmatrix_impl.hpp.
template<typename T , K_UINT_32 BEG, bool DBG>
Helper function to initialize matrix.
This function is called by all the constructors and also by the resize()
function. If either m
or n
is 0, then both m_ and n_ will be set to 0.
- Precondition
- Mimpl_ has been resized to
m*n
elements.
- Postcondition
- vimpl_ has been resized to <
m
elements.
-
All pointers of vimpl_ have been assigned to point in Mimpl_.
-
M_, m_ and n_ have been initialized correctly.
- Parameters
-
m | Number of rows. Can be 0. |
n | Number of cols. Can be 0. |
Definition at line 104 of file kmatrix_impl.hpp.
template<typename T , K_UINT_32 BEG, bool DBG>
Constant-time swap function between two matrices.
This function is fast, since it exchanges pointers to underlying implementation without copying any element.
- Parameters
-
- Note
- No pointer is invalidated by this function. They still point to the same element, but in the other matrix.
Definition at line 332 of file kmatrix_impl.hpp.
template<typename T, K_UINT_32 BEG, bool DBG>
Pointer to the start of vimpl_.
In fact, M_ is such that &M_[beg] == &vimpl_[0]
. This means also that &M_[beg][beg] == &Mimpl_[0][0]
.
- Warning
M_[0]
is not defined for beg != 0
.
Definition at line 160 of file kmatrix.hpp.
template<typename T, K_UINT_32 BEG, bool DBG>
Array of pointers to rows of Mimpl_.
In fact, vimpl_ is such that &vimpl_[i][beg] == &Mimpl_[i*n_]
.
Definition at line 151 of file kmatrix.hpp.