|
|
| Matrix () |
| Construction of static matrices. Values are not initialized. More...
|
|
| Matrix (int rows, int cols) |
| Construction of dynamic matrices. Values are not initialized. More...
|
|
| Matrix (Precision *p) |
| Construction of statically sized slice matrices. More...
|
|
| Matrix (Precision *p, int r, int c) |
| Construction of dynamically sized slice matrices. More...
|
|
| Matrix (Precision *data, int rows, int cols, int rowstride, int colstride, Internal::Slicing) |
|
template<class Op > |
| Matrix (const Operator< Op > &op) |
| Construction from an operator. More...
|
|
template<int Rows2, int Cols2, typename Precision2 , typename Base2 > |
| Matrix (const Matrix< Rows2, Cols2, Precision2, Base2 > &from) |
| constructor from arbitrary matrix More...
|
|
|
|
Matrix & | operator= (const Matrix &from) |
|
template<class Op > |
Matrix & | operator= (const Operator< Op > &op) |
|
template<int Rows2, int Cols2, typename Precision2 , typename Base2 > |
Matrix & | operator= (const Matrix< Rows2, Cols2, Precision2, Base2 > &from) |
|
|
Matrix & | operator*= (const Precision &rhs) |
|
Matrix & | operator/= (const Precision &rhs) |
|
template<int Rows2, int Cols2, typename Precision2 , typename Base2 > |
Matrix & | operator+= (const Matrix< Rows2, Cols2, Precision2, Base2 > &from) |
|
template<class Op > |
Matrix & | operator+= (const Operator< Op > &op) |
|
template<class Op > |
Matrix & | operator-= (const Operator< Op > &op) |
|
template<int Rows2, int Cols2, typename Precision2 , typename Base2 > |
Matrix & | operator-= (const Matrix< Rows2, Cols2, Precision2, Base2 > &from) |
|
template<int Rows2, int Cols2, typename Precision2 , typename Base2 > |
bool | operator== (const Matrix< Rows2, Cols2, Precision2, Base2 > &rhs) const |
|
template<int Rows2, int Cols2, typename Precision2 , typename Base2 > |
bool | operator!= (const Matrix< Rows2, Cols2, Precision2, Base2 > &rhs) const |
|
|
Matrix & | ref () |
| return me as a non const reference - useful for temporaries More...
|
|
template<int Rows = -1, int Cols = Rows, class Precision = DefaultPrecision, class Layout = RowMajor>
struct TooN::Matrix< Rows, Cols, Precision, Layout >
A matrix. Support is provided for all the usual matrix operations:
- the (a,b) notation can be used to access an element directly
- the [] operator can be used to yield a vector from a matrix (which can be used as an l-value)
- they can be added and subtracted
- they can be multiplied (on either side) or divided by a scalar on the right:
- they can be multiplied by matrices or vectors
- submatrices can be extracted using the templated slice() member function
- they can be transposed (and the transpose used as an l-value)
- inverse is not supported. Use one of the matrix decompositions instead
See individual member function documentation for examples of usage.
- Statically-sized matrices
The library provides classes for statically and dynamically sized matrices. As with Vectors, statically sized matrices are more efficient, since their size is determined at compile-time, not run-time. To create a matrix, use:
or replace 3 and 4 with the dimensions of your choice. If the matrix is square, it can be declared as:
which just is a synonym for Matrix<3,3>
. Matrices can also be constructed from pointers or static 1D or 2D arrays of doubles:
double dvals1[9]={1,2,3,4,5,6};
Matrix<2,3, Reference::RowMajor> M2 (dvals1);
- Dynamically-sized matrices
To create a dynamically sized matrix, use:
Matrix<> M(num_rows, num_cols);
where num_rows and num_cols are integers which will be evaluated at run time.
Half-dynamic matriced can be constructed in either dimension:
Matrix<Dynamic, 2> M(num_rows, 2);
note that the static dimension must be provided, but it is ignored.
Matrix<>
is a synonym for Matrix<Dynamic, Dynamic>
which is Matrix<-1,-1>
- Row-major and column-major
The library supports both row major (the default - but you can change this if you prefer) and column major layout ordering. Row major implies that the matrix is laid out in memory in raster scan order:
You can override the default for a specific matrix by specifying the layout when you construct it:
Matrix<3,3,double,ColMajor> M1;
Matrix<-1,-1,double,RowMajor> M2(nrows, ncols);
In this case the precision template argument must be given as it precedes the layout argument
Definition at line 110 of file matrix.hh.