Wt
4.11.1
|
A value class that describes a matrix. More...
#include <Wt/WGenericMatrix.h>
Public Member Functions | |
WGenericMatrix () | |
Construct a identity matrix. More... | |
WGenericMatrix (const WGenericMatrix< T, Rows, Cols > &other) | |
Copy Constructor. | |
WGenericMatrix (const T *elements) | |
Constructs a matrix from an array of elements. More... | |
virtual | ~WGenericMatrix ()=default |
Destructor. | |
const ArrayType & | constData () const |
Returns a const pointer to the internal data store. More... | |
void | copyDataTo (T *data) |
Export the matrix data. More... | |
ArrayType & | data () |
Returns a reference to the internal data store. More... | |
const ArrayType & | data () const |
Returns a const reference to the internal data store. More... | |
void | fill (T value) |
Fills every element of the matrix with the given value. | |
bool | isIdentity () const |
Identity check. More... | |
void | setToIdentity () |
Set this matrix to the identity matrix. More... | |
WGenericMatrix< T, Cols, Rows > | transposed () const |
Returns the transposed of the matrix. | |
bool | operator== (const WGenericMatrix< T, Rows, Cols > &rhs) const |
Equality operator. More... | |
bool | operator!= (const WGenericMatrix< T, Rows, Cols > &rhs) const |
Inequality operator. More... | |
const T & | operator() (int row, int column) const |
Returns the element at the given position. | |
T & | operator() (int row, int column) |
Returns the element at the given position. | |
const T & | at (int row, int column) const |
Returns the element at the given position. | |
T & | at (int row, int column) |
Returns the element at the given position. | |
WGenericMatrix< T, Rows, Cols > & | operator*= (const T &factor) |
Multiply every element of the matrix with the given factor. | |
WGenericMatrix< T, Rows, Cols > & | operator/= (const T &factor) |
Divide every element of the matrix by the given factor. | |
WGenericMatrix< T, Rows, Cols > & | operator+= (const WGenericMatrix< T, Rows, Cols > &rhs) |
Add the given matrix to this matrix. | |
WGenericMatrix< T, Rows, Cols > & | operator-= (const WGenericMatrix< T, Rows, Cols > &rhs) |
Substract the given matrix from this matrix. | |
A value class that describes a matrix.
This class represents a fixed-size dense (!= sparse) matrix. It can be templatized to the number of rows and columns, and to the datatype stored (integer types, floatin point types, complex types, ...)
The row order of this matrix class is row-major. This means that when accessing the raw data store linearly, you will first encounter all elements of the first row, then the second row, and so on.
This template class is used in Wt as base class for transformation matrices, but can also be used as a general matrix class. Efficiency for this use case was considered when this class was implemented, but we recommend that you use a more specialized matrix class library if the algorithms you need exceed what's offered here (for example, if you intend to do many linear algebra computations, you may consider boost ublass, MTL, ...).
Wt::WGenericMatrix< T, Rows, Cols >::WGenericMatrix | ( | ) |
Construct a identity matrix.
An identity matrix in this context is a matrix where m(i,i) = 1 and m(i,j) = 0, for i != j.
|
explicit |
Constructs a matrix from an array of elements.
The input array is assumed to be in row-major order. If elements is 0, the matrix data is not initialized.
const ArrayType& Wt::WGenericMatrix< T, Rows, Cols >::constData | ( | ) | const |
Returns a const pointer to the internal data store.
The array can be indexed with []. You can iterate over the entire data store by using begin() and end() iterators. The row order of the data is row major.
void Wt::WGenericMatrix< T, Rows, Cols >::copyDataTo | ( | T * | data | ) |
Export the matrix data.
Stores the matrix in an array of Rows*Cols elements of type T, pointed to by data. The data will be stored in row major order.
ArrayType& Wt::WGenericMatrix< T, Rows, Cols >::data | ( | ) |
Returns a reference to the internal data store.
The array can be indexed with []. You can iterate over the entire data store by using begin() and end() iterators. The row order of the data is row major.
const ArrayType& Wt::WGenericMatrix< T, Rows, Cols >::data | ( | ) | const |
Returns a const reference to the internal data store.
The array can be indexed with []. You can iterate over the entire data store by using begin() and end() iterators. The row order of the data is row major.
bool Wt::WGenericMatrix< T, Rows, Cols >::isIdentity | ( | ) | const |
Identity check.
Returns true if the transform represents an identity transformation.
bool Wt::WGenericMatrix< T, Rows, Cols >::operator!= | ( | const WGenericMatrix< T, Rows, Cols > & | rhs | ) | const |
Inequality operator.
Returns true
if the transforms are different.
bool Wt::WGenericMatrix< T, Rows, Cols >::operator== | ( | const WGenericMatrix< T, Rows, Cols > & | rhs | ) | const |
Equality operator.
Returns true
if the matrices are exactly the same.
void Wt::WGenericMatrix< T, Rows, Cols >::setToIdentity | ( | ) |
Set this matrix to the identity matrix.
An identity matrix is in this context a matrix where m(i,i) = 1 and m(i,j) = 0, for i != j.