IOLink  IOL_v1.1.0_release
iolink::Matrix< ValueType, N > Class Template Reference

An arithmetic square matrix. More...

#include <iolink/Matrix.h>

Public Member Functions

 Matrix ()
 Default constructor. More...
 
 Matrix (const ValueType *values)
 Constructor with C-array parameter. More...
 
 Matrix (const ValueType *values, bool isRowMajor)
 Constructor with C-array parameter. More...
 
 Matrix (std::initializer_list< ValueType > init)
 Create a matrix giving initialization values. More...
 
bool operator== (const Matrix &other) const
 
bool operator!= (const Matrix &other) const
 
ValueType at (size_t row, size_t column) const
 Access an element of the matrix. More...
 
ValueType operator() (size_t row, size_t column) const
 Access an element of the matrix. More...
 
void setAt (size_t row, size_t column, ValueType value)
 Set an element of the matrix. More...
 
void transposeInPlace ()
 Transpose the matrix in place.
 
Matrix transpose () const
 Return the transposed matrix.
 
ValueType * data ()
 Exposes the internal data of the matrix, use it only if you know what you do. More...
 
const ValueType * data () const
 Exposes the internal data of the matrix, use it only if you know what you do. More...
 
std::string toString () const
 Return a string representation of the matrix.
 
Matrix operator- () const
 
Matrixoperator+= (const Matrix &m)
 
Matrixoperator-= (const Matrix &m)
 
Matrix operator+ (const Matrix &m) const
 
Matrix operator- (const Matrix &m) const
 
Matrixoperator*= (ValueType value)
 
Matrixoperator/= (ValueType value)
 
Matrix operator* (ValueType v) const
 
Matrix operator/ (ValueType v) const
 

Static Public Member Functions

static Matrix identity ()
 Return an identity matrix.
 
static Matrix uniform (ValueType value)
 Initialize an uniform matrix with an unique value. More...
 

Detailed Description

template<typename ValueType, size_t N>
class iolink::Matrix< ValueType, N >

An arithmetic square matrix.

Do not use this class directly, only uses its aliases.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

template<typename ValueType , size_t N>
iolink::Matrix< ValueType, N >::Matrix ( )

Default constructor.

Object will have indeterminate values.

◆ Matrix() [2/4]

template<typename ValueType , size_t N>
iolink::Matrix< ValueType, N >::Matrix ( const ValueType *  values)

Constructor with C-array parameter.

With the following matrix:

| a11 | a12 | a13 | a14 |
| a21 | a22 | a23 | a24 |
| a31 | a32 | a33 | a34 |
| a41 | a42 | a43 | a44 |

Values should be given to this function in ROW-major order: a11 a12 a13 a14 a21 a22 a23 a24 ...

Parameters
valuesPointer on first element to use to initialize the NxN internal values

◆ Matrix() [3/4]

template<typename ValueType , size_t N>
iolink::Matrix< ValueType, N >::Matrix ( const ValueType *  values,
bool  isRowMajor 
)

Constructor with C-array parameter.

With the following matrix:

| a11 | a12 | a13 | a14 |
| a21 | a22 | a23 | a24 |
| a31 | a32 | a33 | a34 |
| a41 | a42 | a43 | a44 |

Values should be given to this function in:

  • ROW-major order (a11 a12 a13 a14 a21...)
  • COL-major order (a11, a21, a31, a41, a12...)
Parameters
valuesPointer on first element to use to initialize the NxN internal values
isRowMajorBoolean which indicates how given data must be stored

◆ Matrix() [4/4]

template<typename ValueType , size_t N>
iolink::Matrix< ValueType, N >::Matrix ( std::initializer_list< ValueType >  init)
explicit

Create a matrix giving initialization values.

With the following matrix:

| a11 | a12 | a13 | a14 |
| a21 | a22 | a23 | a24 |
| a31 | a32 | a33 | a34 |
| a41 | a42 | a43 | a44 |

This fonction should be used this way:

Matrix4f m{a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44};

Member Function Documentation

◆ at()

template<typename ValueType , size_t N>
ValueType iolink::Matrix< ValueType, N >::at ( size_t  row,
size_t  column 
) const

Access an element of the matrix.

Parameters
columnThe column of the element
rowThe row of the element

◆ data() [1/2]

template<typename ValueType , size_t N>
ValueType* iolink::Matrix< ValueType, N >::data ( )

Exposes the internal data of the matrix, use it only if you know what you do.

As the internal layout of our matrices is column-major, the data will be in a different order than the initialisation list.

Example for the following matrix:

| a11 | a12 | a13 | a14 |
| a21 | a22 | a23 | a24 |
| a31 | a32 | a33 | a34 |
| a41 | a42 | a43 | a44 |

Data will return a buffer with the following data:

{a11, a21, a31, a41, a12, a22, a32 a42, a13, a23, a33, a43, a14, a24, a34, a44}

◆ data() [2/2]

template<typename ValueType , size_t N>
const ValueType* iolink::Matrix< ValueType, N >::data ( ) const

Exposes the internal data of the matrix, use it only if you know what you do.

As the internal layout of our matrices is column-major, the data will be in a different order than the initialisation list.

Example for the following matrix:

| a11 | a12 | a13 | a14 |
| a21 | a22 | a23 | a24 |
| a31 | a32 | a33 | a34 |
| a41 | a42 | a43 | a44 |

Data will return a buffer with the following data:

{a11, a21, a31, a41, a12, a22, a32 a42, a13, a23, a33, a43, a14, a24, a34, a44}

◆ operator()()

template<typename ValueType , size_t N>
ValueType iolink::Matrix< ValueType, N >::operator() ( size_t  row,
size_t  column 
) const

Access an element of the matrix.

Parameters
columnThe column of the element
rowThe row of the element

◆ setAt()

template<typename ValueType , size_t N>
void iolink::Matrix< ValueType, N >::setAt ( size_t  row,
size_t  column,
ValueType  value 
)

Set an element of the matrix.

Parameters
columnThe column of the element
rowThe row of the element
valueThe value to assign to the element

◆ uniform()

template<typename ValueType , size_t N>
static Matrix iolink::Matrix< ValueType, N >::uniform ( ValueType  value)
static

Initialize an uniform matrix with an unique value.

Parameters
valueThe value to assign to each element of the matrix

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