#include <kmatrix.hpp>
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. | |
KMatrix & | operator= (const T &a) |
Assigns a copy of a to all elements of the matrix. | |
KMatrix & | operator= (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. |
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.
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.T
must be default constructible.T
must be assignable.T
must be serializable.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;
T t1 = t2; T t1(t2); T(t1);
t1 = t2;
is >> t1;
operator>>()
-os << t1;
operator<<()
Finally, note that operator>>()
and operator<<()
must be compatible. Also, operator&()
must not have been overloaded.
|
|
|
Creates an
|
|
Creates an
|
|
Creates an
This function allows to transform a C-style array of
|
|
Copy constructor. Performs a deep copy.
|
|
Returns the element
|
|
Returns the element
|
|
Returns m_, the number of rows of the matrix.
|
|
Returns n_, the number of columns of the matrix.
|
|
Resizes the matrix. Resulting matrix contents are undefined.
|
|
Assigns a copy of
|
|
Copy assignment operator. Performs a deep copy.
|
|
Copies a C-style array of instances of 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.
|
|
Constant-time swap function between two matrices. This function is fast, since it exchanges pointers to underlying implementation without copying any element.
|
|
Reads a matrix from a stream.
This function will extract
|
|
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.
|