Wt  3.7.1
Wt::WGenericMatrix< T, Rows, Cols > Class Template Reference

A value class that describes a matrix. More...

`#include <Wt/WGenericMatrix>`

## 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...

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.

## Detailed Description

### template<typename T, std::size_t Rows, std::size_t Cols> class Wt::WGenericMatrix< T, Rows, Cols >

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, ...).

## ◆ WGenericMatrix() [1/2]

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

## ◆ WGenericMatrix() [2/2]

template<typename T, std::size_t Rows, std::size_t Cols>
 Wt::WGenericMatrix< T, Rows, Cols >::WGenericMatrix ( const T * elements )
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.

## ◆ constData()

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

## ◆ copyDataTo()

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

## ◆ data() [1/2]

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

## ◆ data() [2/2]

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

## ◆ isIdentity()

template<typename T, std::size_t Rows, std::size_t Cols>
 bool Wt::WGenericMatrix< T, Rows, Cols >::isIdentity ( ) const

Identity check.

Returns true if the transform represents an identity transformation.

## ◆ operator!=()

template<typename T, std::size_t Rows, std::size_t Cols>
 bool Wt::WGenericMatrix< T, Rows, Cols >::operator!= ( const WGenericMatrix< T, Rows, Cols > & rhs ) const

Inequality operator.

Returns `true` if the transforms are different.

## ◆ operator==()

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

## ◆ setToIdentity()

template<typename T, std::size_t Rows, std::size_t Cols>
 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.

Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by 1.8.13