Peano
Loading...
Searching...
No Matches
tarch::la::Matrix< Rows, Cols, Scalar > Class Template Reference

Static (i.e. More...

#include <Matrix.h>

Public Member Functions

 Matrix ()
 Constructs a non-initialized matrix.
 Matrix (const Scalar &value)
 Constructs an initialized matrix.
 Matrix (std::initializer_list< Scalar > values)
int rows () const
 Returns the number of rows in the matrix.
int cols () const
 Returns the number of columns in the matrix.
int size () const
 Returns the number of total elements in the matrix.
Scalar & operator() (int rowIndex, int colIndex)
 Returns element at given row and column index (from 0..size-1).
const Scalar & operator() (int rowIndex, int colIndex) const
 Returns const element at given row and column index (from 0..size-1).
std::string toString () const
std::string toPrettyString (int numberOfDigits=4) const
template<typename NewScalarType>
tarch::la::Matrix< Rows, Cols, NewScalarType > convertScalar () const
Scalar * data ()
 This routine returns a pointer to the first data element.
const Scalar * data () const

Private Attributes

Scalar _values [Rows *Cols]
 Values of the matrix components.

Friends

Matrix< Rows, Cols, Scalar > buildMatrix (const Scalar *values)
 Become friend of builder mechanism.

Detailed Description

template<int Rows, int Cols, typename Scalar>
class tarch::la::Matrix< Rows, Cols, Scalar >

Static (i.e.

compiletime) sized matrix type.

Definition at line 42 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/3]

template<int Rows, int Cols, typename Scalar>
tarch::la::Matrix< Rows, Cols, Scalar >::Matrix ( )

Constructs a non-initialized matrix.

◆ Matrix() [2/3]

template<int Rows, int Cols, typename Scalar>
tarch::la::Matrix< Rows, Cols, Scalar >::Matrix ( const Scalar & value)

Constructs an initialized matrix.

◆ Matrix() [3/3]

template<int Rows, int Cols, typename Scalar>
tarch::la::Matrix< Rows, Cols, Scalar >::Matrix ( std::initializer_list< Scalar > values)

Member Function Documentation

◆ cols()

template<int Rows, int Cols, typename Scalar>
int tarch::la::Matrix< Rows, Cols, Scalar >::cols ( ) const

Returns the number of columns in the matrix.

◆ convertScalar()

template<int Rows, int Cols, typename Scalar>
template<typename NewScalarType>
tarch::la::Matrix< Rows, Cols, NewScalarType > tarch::la::Matrix< Rows, Cols, Scalar >::convertScalar ( ) const

◆ data() [1/2]

template<int Rows, int Cols, typename Scalar>
Scalar * tarch::la::Matrix< Rows, Cols, Scalar >::data ( )

This routine returns a pointer to the first data element.

Not a beautiful one as it harms the OO idea, but in many cases it is convenient to have this operation.

Definition at line 130 of file Matrix.h.

◆ data() [2/2]

template<int Rows, int Cols, typename Scalar>
const Scalar * tarch::la::Matrix< Rows, Cols, Scalar >::data ( ) const

Definition at line 134 of file Matrix.h.

◆ operator()() [1/2]

template<int Rows, int Cols, typename Scalar>
Scalar & tarch::la::Matrix< Rows, Cols, Scalar >::operator() ( int rowIndex,
int colIndex )

Returns element at given row and column index (from 0..size-1).

See also
Vector::operator[] for remarks on SSE efficiency

Definition at line 85 of file Matrix.h.

◆ operator()() [2/2]

template<int Rows, int Cols, typename Scalar>
const Scalar & tarch::la::Matrix< Rows, Cols, Scalar >::operator() ( int rowIndex,
int colIndex ) const

Returns const element at given row and column index (from 0..size-1).

Definition at line 103 of file Matrix.h.

◆ rows()

template<int Rows, int Cols, typename Scalar>
int tarch::la::Matrix< Rows, Cols, Scalar >::rows ( ) const

Returns the number of rows in the matrix.

◆ size()

template<int Rows, int Cols, typename Scalar>
int tarch::la::Matrix< Rows, Cols, Scalar >::size ( ) const

Returns the number of total elements in the matrix.

◆ toPrettyString()

template<int Rows, int Cols, typename Scalar>
std::string tarch::la::Matrix< Rows, Cols, Scalar >::toPrettyString ( int numberOfDigits = 4) const

◆ toString()

template<int Rows, int Cols, typename Scalar>
std::string tarch::la::Matrix< Rows, Cols, Scalar >::toString ( ) const

◆ buildMatrix

template<int Rows, int Cols, typename Scalar>
Matrix< Rows, Cols, Scalar > buildMatrix ( const Scalar * values)
friend

Become friend of builder mechanism.

We faced issues with some compiler versions with offering a constructor that simply takes a pointer to scalars. Further to that, it is not clear if such a constructor would create a deep copy or a shallow copy. Therefore, I decided to introduce an explicit builder function.

Field Documentation

◆ _values

template<int Rows, int Cols, typename Scalar>
Scalar tarch::la::Matrix< Rows, Cols, Scalar >::_values[Rows *Cols]
private

Values of the matrix components.

Definition at line 47 of file Matrix.h.


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