CreOS SDK
The CreOS SDK allows you to interact with Avular robots
 
Loading...
Searching...
No Matches
creos_messages::Matrix< T, n_rows, n_cols > Class Template Reference

Matrix template for a 2D array of type T. More...

#include <creos/messages/generic.hpp>

Public Member Functions

 Matrix ()=default
 Default constructor.
 
 Matrix (const std::array< std::array< T, n_cols >, n_rows > &data)
 Constructor from 2D array.
 
 Matrix (const std::array< T, n_rows *n_cols > &array)
 Constructor from 1D array.
 
 Matrix (std::initializer_list< T > init)
 Constructor from initializer list.
 
 Matrix (std::initializer_list< std::initializer_list< T > > init)
 Constructor from initializer list of initializer lists.
 
template<typename U >
 Matrix (const std::array< U, n_rows *n_cols > &array)
 Transform constructor from another type of array.
 
std::array< T, n_rows *n_cols > toArray () const
 Convert the matrix to a 1D array.
 
template<typename U >
std::array< U, n_rows *n_cols > transformToArray () const
 Transform the matrix to another type of array.
 
std::array< T, n_cols > & operator[] (std::size_t index)
 Access the elements of the matrix.
 
const std::array< T, n_cols > & operator[] (std::size_t index) const
 Access the elements of the matrix.
 
auto operator<=> (const Matrix &other) const =default
 Compare two Matrix messages.
 
auto begin () const
 Returns a constant iterator to the beginning of the matrix.
 
auto end () const
 Returns a constant iterator to the end of the matrix.
 

Detailed Description

template<typename T, std::size_t n_rows, std::size_t n_cols>
class creos_messages::Matrix< T, n_rows, n_cols >

Matrix template for a 2D array of type T.

Constructor & Destructor Documentation

◆ Matrix() [1/6]

template<typename T , std::size_t n_rows, std::size_t n_cols>
creos_messages::Matrix< T, n_rows, n_cols >::Matrix ( )
default

Default constructor.

Initializes the matrix with zeros

◆ Matrix() [2/6]

template<typename T , std::size_t n_rows, std::size_t n_cols>
creos_messages::Matrix< T, n_rows, n_cols >::Matrix ( const std::array< std::array< T, n_cols >, n_rows > & data)
inline

Constructor from 2D array.

Parameters
dataThe 2D array to initialize the matrix with

◆ Matrix() [3/6]

template<typename T , std::size_t n_rows, std::size_t n_cols>
creos_messages::Matrix< T, n_rows, n_cols >::Matrix ( const std::array< T, n_rows *n_cols > & array)
inline

Constructor from 1D array.

Parameters
arrayThe 1D array to initialize the matrix with

◆ Matrix() [4/6]

template<typename T , std::size_t n_rows, std::size_t n_cols>
creos_messages::Matrix< T, n_rows, n_cols >::Matrix ( std::initializer_list< T > init)
inline

Constructor from initializer list.

Parameters
initThe initializer list to initialize the matrix with

◆ Matrix() [5/6]

template<typename T , std::size_t n_rows, std::size_t n_cols>
creos_messages::Matrix< T, n_rows, n_cols >::Matrix ( std::initializer_list< std::initializer_list< T > > init)
inline

Constructor from initializer list of initializer lists.

Parameters
initThe initializer list of initializer lists to initialize the matrix with

◆ Matrix() [6/6]

template<typename T , std::size_t n_rows, std::size_t n_cols>
template<typename U >
creos_messages::Matrix< T, n_rows, n_cols >::Matrix ( const std::array< U, n_rows *n_cols > & array)
inline

Transform constructor from another type of array.

Template Parameters
UThe type of the input array
Parameters
arrayThe array to initialize the matrix with

Member Function Documentation

◆ begin()

template<typename T , std::size_t n_rows, std::size_t n_cols>
auto creos_messages::Matrix< T, n_rows, n_cols >::begin ( ) const
inline

Returns a constant iterator to the beginning of the matrix.

Returns
Constant iterator to the beginning of the matrix

◆ end()

template<typename T , std::size_t n_rows, std::size_t n_cols>
auto creos_messages::Matrix< T, n_rows, n_cols >::end ( ) const
inline

Returns a constant iterator to the end of the matrix.

Returns
Constant iterator to the end of the matrix

◆ operator[]() [1/2]

template<typename T , std::size_t n_rows, std::size_t n_cols>
std::array< T, n_cols > & creos_messages::Matrix< T, n_rows, n_cols >::operator[] ( std::size_t index)
inline

Access the elements of the matrix.

Parameters
indexThe index of the row
Returns
The row of the matrix

◆ operator[]() [2/2]

template<typename T , std::size_t n_rows, std::size_t n_cols>
const std::array< T, n_cols > & creos_messages::Matrix< T, n_rows, n_cols >::operator[] ( std::size_t index) const
inline

Access the elements of the matrix.

Parameters
indexThe index of the row
Returns
The row of the matrix

◆ toArray()

template<typename T , std::size_t n_rows, std::size_t n_cols>
std::array< T, n_rows *n_cols > creos_messages::Matrix< T, n_rows, n_cols >::toArray ( ) const
inline

Convert the matrix to a 1D array.

Returns
The 1D array representation of the matrix

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