This is the Tiny Vector Matrix Expression Templates library found at http://tvmet.sourceforge.net. It is the fastest and most compact matrix lib out there (for < 10x10 matricies). I have done some minor tweaks to make it compile for mbed.
For examples and hints on how to use, see: http://tvmet.sourceforge.net/usage.html
Dependents:
Eurobot_2012_Secondary
« Back to documentation index
Matrix< T, NRows, NCols > Class Template Reference
A tiny matrix class.
More...
#include <tvmet/Matrix.h >
Data Structures
struct Info
Structure for info printing as Matrix<T, Rows, Cols>. More...
Public Types
enum { Rows = NRows,
Cols = NCols,
Size = Rows * Cols
}
Dimensions.
More...
enum
Complexity counter.
More...
typedef T value_type
Data type of the tvmet::Matrix .
typedef T & reference
Reference type of the tvmet::Matrix data elements.
typedef const T & const_reference
const reference type of the tvmet::Matrix data elements.
typedef T * iterator
STL iterator interface.
typedef const T * const_iterator
STL const_iterator interface.
typedef std::reverse_iterator
< iterator > reverse_iterator
STL reverse iterator interface.
typedef std::reverse_iterator
< const_iterator > const_reverse_iterator
STL const reverse iterator interface.
Public Member Functions
iterator begin ()
STL iterator interface.
iterator end ()
STL iterator interface.
const_iterator begin () const
STL const_iterator interface.
const_iterator end () const
STL const_iterator interface.
reverse_iterator rbegin ()
STL reverse iterator interface reverse begin.
const_reverse_iterator rbegin () const
STL const reverse iterator interface reverse begin.
reverse_iterator rend ()
STL reverse iterator interface reverse end.
const_reverse_iterator rend () const
STL const reverse iterator interface reverse end.
~Matrix ()
Default Destructor.
Matrix ()
Default Constructor.
Matrix (const Matrix &rhs)
Copy Constructor, not explicit!
template<class InputIterator >
Matrix (InputIterator first, InputIterator last)
Constructor with STL iterator interface.
template<class InputIterator >
Matrix (InputIterator first, std::size_t sz)
Constructor with STL iterator interface.
Matrix (value_type rhs)
Construct the matrix by value.
template<class E >
Matrix (const XprMatrix < E, Rows, Cols > &e)
Construct a matrix by expression.
CommaInitializer < Matrix , Size > operator= (value_type rhs)
assign a value_type on array, this can be used for a single value or a comma separeted list of values.
ConstReference const_ref () const
Return a const Reference of the internal data.
ConstReference const_sliceref () const
Return a sliced const Reference of the internal data.
XprMatrix < ConstReference ,
Rows, Cols > as_expr () const
Return the vector as const expression.
template<class T2 >
Matrix & operator= (const Matrix < T2, Rows, Cols > &rhs)
assign a given matrix of a different type T2 element wise to this matrix.
template<class E >
Matrix & operator= (const XprMatrix < E, Rows, Cols > &rhs)
assign a given XprMatrix element wise to this matrix.
std::ostream & print_xpr (std::ostream &os, std::size_t l=0) const
Member function for expression level printing.
std::ostream & print_on (std::ostream &os) const
Member function for printing internal data.
Static Public Member Functions
static std::size_t size ()
The size of the matrix.
static std::size_t max_size ()
STL vector max_size() - returns allways rows() *cols().
static bool empty ()
STL vector empty() - returns allways false.
static std::size_t rows ()
The number of rows of matrix.
static std::size_t cols ()
The number of columns of matrix.
static Info info ()
Get an info object of this matrix.
Detailed Description
template<class T, std::size_t NRows, std::size_t NCols>
class tvmet::Matrix< T, NRows, NCols >
A tiny matrix class.
The array syntax A[j][j] isn't supported here. The reason is that operator[] always takes exactly one parameter, but operator() can take any number of parameters (in the case of a rectangular matrix, two paramters are needed). Therefore the cleanest way to do it is with operator() rather than with operator[].
See also: C++ FAQ Lite 13.8
Definition at line 123 of file Matrix.h .
Member Typedef Documentation
STL const_iterator interface.
Definition at line 139 of file Matrix.h .
STL const reverse iterator interface.
Definition at line 145 of file Matrix.h .
STL iterator interface.
Definition at line 136 of file Matrix.h .
STL reverse iterator interface.
Definition at line 142 of file Matrix.h .
Member Enumeration Documentation
Dimensions.
Enumerator:
Rows
Number of rows.
Cols
Number of cols.
Size
Complete Size of Matrix .
Definition at line 149 of file Matrix.h .
Complexity counter.
Definition at line 157 of file Matrix.h .
Constructor & Destructor Documentation
Default Destructor.
Definition at line 210 of file Matrix.h .
Default Constructor.
The allocated memory region isn't cleared. If you want a clean use the constructor argument zero.
Definition at line 218 of file Matrix.h .
Copy Constructor, not explicit!
Definition at line 225 of file Matrix.h .
Matrix
(
InputIterator
first ,
InputIterator
last
)
[explicit]
Constructor with STL iterator interface.
The data will be copied into the matrix self, there isn't any stored reference to the array pointer.
Definition at line 238 of file Matrix.h .
Matrix
(
InputIterator
first ,
std::size_t
sz
)
[explicit]
Constructor with STL iterator interface.
The data will be copied into the matrix self, there isn't any stored reference to the array pointer.
Definition at line 253 of file Matrix.h .
Construct the matrix by value.
Definition at line 263 of file Matrix.h .
Construct a matrix by expression.
Definition at line 274 of file Matrix.h .
Member Function Documentation
Return the vector as const expression.
Definition at line 323 of file Matrix.h .
STL iterator interface.
Definition at line 165 of file Matrix.h .
STL const_iterator interface.
Definition at line 171 of file Matrix.h .
static std::size_t cols
(
)
[static]
The number of columns of matrix.
Definition at line 206 of file Matrix.h .
Return a const Reference of the internal data.
Definition at line 314 of file Matrix.h .
Return a sliced const Reference of the internal data.
Note: Doesn't work since isn't implemented, but it is in progress. Therefore this is a placeholder.
Definition at line 320 of file Matrix.h .
static bool empty
(
)
[static]
STL const_iterator interface.
Definition at line 174 of file Matrix.h .
STL iterator interface.
Definition at line 168 of file Matrix.h .
static Info info
(
)
[static]
Get an info object of this matrix.
Definition at line 443 of file Matrix.h .
static std::size_t max_size
(
)
[static]
assign a value_type on array, this can be used for a single value or a comma separeted list of values.
Definition at line 284 of file Matrix.h .
assign a given matrix of a different type T2 element wise to this matrix.
The operator=(const Matrix&) is compiler generated.
Definition at line 355 of file Matrix.h .
std::ostream & print_on
(
std::ostream &
os )
const
Member function for printing internal data.
Definition at line 52 of file MatrixImpl.h .
std::ostream & print_xpr
(
std::ostream &
os ,
std::size_t
l = 0
)
const
Member function for expression level printing.
Definition at line 40 of file MatrixImpl.h .
STL const reverse iterator interface reverse begin.
Definition at line 180 of file Matrix.h .
STL reverse iterator interface reverse begin.
Definition at line 177 of file Matrix.h .
STL reverse iterator interface reverse end.
Definition at line 185 of file Matrix.h .
STL const reverse iterator interface reverse end.
Definition at line 188 of file Matrix.h .
static std::size_t rows
(
)
[static]
The number of rows of matrix.
Definition at line 203 of file Matrix.h .
static std::size_t size
(
)
[static]
The size of the matrix.
Definition at line 193 of file Matrix.h .