TooN
List of all members
TooN::Matrix< Rows, Cols, Precision, Layout > Struct Template Reference

A matrix. More...

#include <matrix.hh>

Inheritance diagram for TooN::Matrix< Rows, Cols, Precision, Layout >:
Inheritance graph
[legend]
Collaboration diagram for TooN::Matrix< Rows, Cols, Precision, Layout >:
Collaboration graph
[legend]

Public Member Functions

Construction and destruction
 Matrix ()
 Construction of static matrices. Values are not initialized.
 
 Matrix (int rows, int cols)
 Construction of dynamic matrices. Values are not initialized.
 
 Matrix (Precision *p)
 Construction of statically sized slice matrices.
 
 Matrix (Precision *p, int r, int c)
 Construction of dynamically sized slice matrices.
 
 Matrix (Precision *data, int rows, int cols, int rowstride, int colstride, Internal::Slicing)
 Advanced construction of dynamically sized slice matrices. More...
 
template<class Op >
 Matrix (const Operator< Op > &op)
 Construction from an operator.
 
template<int Rows2, int Cols2, typename Precision2 , typename Base2 >
 Matrix (const Matrix< Rows2, Cols2, Precision2, Base2 > &from)
 constructor from arbitrary matrix
 
Assignment

operator = from copy

Matrixoperator= (const Matrix &from)
 
template<class Op >
Matrixoperator= (const Operator< Op > &op)
 
template<int Rows2, int Cols2, typename Precision2 , typename Base2 >
Matrixoperator= (const Matrix< Rows2, Cols2, Precision2, Base2 > &from)
 
operations on the matrix
Matrixoperator*= (const Precision rhs)
 
Matrixoperator/= (const Precision rhs)
 
template<int Rows2, int Cols2, typename Precision2 , typename Base2 >
Matrixoperator+= (const Matrix< Rows2, Cols2, Precision2, Base2 > &from)
 
template<class Op >
Matrixoperator+= (const Operator< Op > &op)
 
template<class Op >
Matrixoperator-= (const Operator< Op > &op)
 
template<int Rows2, int Cols2, typename Precision2 , typename Base2 >
Matrixoperator-= (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
 
template<class Op >
bool operator!= (const Operator< Op > &op)
 
Misc
Matrixref ()
 return me as a non const reference - useful for temporaries
 

Detailed Description

template<int Rows = Dynamic, 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:

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 \(3\times4\) matrix, use:

Matrix<3,4> M;

or replace 3 and 4 with the dimensions of your choice. If the matrix is square, it can be declared as:

Matrix<3> M;

which just is a synonym for Matrix<3,3>. Matrices can also be constructed from pointers or static 1D or 2D arrays of doubles:

Matrix<2,3, Reference::RowMajor> M2 = Data(1,2,3,4,5,6);
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> .

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:

\[\begin{matrix}\text{Row major} & \text {Column major}\\ \begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix} & \begin{bmatrix}1&4&7\\2&5&8\\3&6&9\end{bmatrix} \end{matrix}\]

You can override the default for a specific matrix by specifying the layout when you construct it:

Matrix<3,3,double,ColMajor> M1;
Matrix<Dynamic,Dynamic,double,RowMajor> M2(nrows, ncols);

In this case the precision template argument must be given as it precedes the layout argument

Constructor & Destructor Documentation

◆ Matrix()

template<int Rows = Dynamic, int Cols = Rows, class Precision = DefaultPrecision, class Layout = RowMajor>
TooN::Matrix< Rows, Cols, Precision, Layout >::Matrix ( Precision *  data,
int  rows,
int  cols,
int  rowstride,
int  colstride,
Internal::Slicing   
)
inline

Advanced construction of dynamically sized slice matrices.

Internal constructor used by GenericMBase::slice(...).


The documentation for this struct was generated from the following file: