ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Utils::Matrix< T, Rows, Cols > Struct Template Reference

Matrix representation with static size. More...

#include <matrix.hpp>

+ Collaboration diagram for Utils::Matrix< T, Rows, Cols >:

Public Types

using container = Utils::Array< T, Cols *Rows >
 
using pointer = typename container::pointer
 
using const_pointer = typename container::const_pointer
 
using iterator = typename container::iterator
 
using const_iterator = typename container::const_iterator
 
using value_type = typename container::value_type
 
using reference = typename container::reference
 
using const_reference = typename container::const_reference
 

Public Member Functions

 Matrix ()=default
 
 Matrix (std::initializer_list< T > init_list)
 
 Matrix (std::initializer_list< std::initializer_list< T > > init_list)
 
constexpr value_type operator() (std::size_t row, std::size_t col) const
 Element access (const).
 
constexpr reference operator() (std::size_t row, std::size_t col)
 Element access (non const).
 
constexpr pointer data ()
 Access to the underlying data pointer (non const).
 
constexpr const_pointer data () const noexcept
 Access to the underlying data pointer (non const).
 
constexpr iterator begin () noexcept
 Iterator access (non const).
 
constexpr const_iterator begin () const noexcept
 Iterator access (const).
 
constexpr iterator end () noexcept
 Iterator access (non const).
 
constexpr const_iterator end () const noexcept
 Iterator access (non const).
 
template<std::size_t R>
Vector< T, Cols > row () const
 Retrieve an entire matrix row.
 
template<std::size_t C>
Vector< T, Rows > col () const
 Retrieve an entire matrix column.
 
Vector< T, Cols > diagonal () const
 Retrieve the diagonal.
 
trace () const
 Retrieve the trace.
 
Matrix< T, Cols, Rows > transposed () const
 Retrieve a transposed copy of the matrix.
 
Matrix< T, Rows, Cols > inversed () const
 Retrieve an inverted copy of the matrix.
 
constexpr std::pair< std::size_t, std::size_t > shape () const noexcept
 Retrieve the shape of the matrix.
 

Public Attributes

container m_data
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename T, std::size_t Rows, std::size_t Cols>
struct Utils::Matrix< T, Rows, Cols >

Matrix representation with static size.

Template Parameters
TThe data type.
RowsNumber of rows.
ColsNumber of columns.

Definition at line 65 of file matrix.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::const_iterator = typename container::const_iterator

Definition at line 70 of file matrix.hpp.

◆ const_pointer

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::const_pointer = typename container::const_pointer

Definition at line 68 of file matrix.hpp.

◆ const_reference

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::const_reference = typename container::const_reference

Definition at line 73 of file matrix.hpp.

◆ container

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::container = Utils::Array<T, Cols * Rows>

Definition at line 66 of file matrix.hpp.

◆ iterator

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::iterator = typename container::iterator

Definition at line 69 of file matrix.hpp.

◆ pointer

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::pointer = typename container::pointer

Definition at line 67 of file matrix.hpp.

◆ reference

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::reference = typename container::reference

Definition at line 72 of file matrix.hpp.

◆ value_type

template<typename T , std::size_t Rows, std::size_t Cols>
using Utils::Matrix< T, Rows, Cols >::value_type = typename container::value_type

Definition at line 71 of file matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/3]

template<typename T , std::size_t Rows, std::size_t Cols>
Utils::Matrix< T, Rows, Cols >::Matrix ( )
default

◆ Matrix() [2/3]

template<typename T , std::size_t Rows, std::size_t Cols>
Utils::Matrix< T, Rows, Cols >::Matrix ( std::initializer_list< T >  init_list)
inline

Definition at line 85 of file matrix.hpp.

References Utils::Matrix< T, Rows, Cols >::begin().

◆ Matrix() [3/3]

template<typename T , std::size_t Rows, std::size_t Cols>
Utils::Matrix< T, Rows, Cols >::Matrix ( std::initializer_list< std::initializer_list< T > >  init_list)
inline

Definition at line 89 of file matrix.hpp.

References Utils::Matrix< T, Rows, Cols >::begin(), and Utils::flatten().

Member Function Documentation

◆ begin() [1/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr const_iterator Utils::Matrix< T, Rows, Cols >::begin ( ) const
inlineconstexprnoexcept

Iterator access (const).

Returns
Returns an iterator to the first element of the matrix.

Definition at line 136 of file matrix.hpp.

References Utils::Array< T, N >::begin(), and Utils::Matrix< T, Rows, Cols >::m_data.

◆ begin() [2/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr iterator Utils::Matrix< T, Rows, Cols >::begin ( )
inlineconstexprnoexcept

Iterator access (non const).

Returns
Returns an iterator to the first element of the matrix.

Definition at line 131 of file matrix.hpp.

References Utils::Array< T, N >::begin(), and Utils::Matrix< T, Rows, Cols >::m_data.

Referenced by Utils::flatten(), Utils::Matrix< T, Rows, Cols >::Matrix(), and Utils::Matrix< T, Rows, Cols >::Matrix().

◆ col()

template<typename T , std::size_t Rows, std::size_t Cols>
template<std::size_t C>
Vector< T, Rows > Utils::Matrix< T, Rows, Cols >::col ( ) const
inline

Retrieve an entire matrix column.

Template Parameters
CThe column index.
Returns
A vector containing the elements of column C.

Definition at line 163 of file matrix.hpp.

Referenced by Utils::Matrix< T, Rows, Cols >::operator()(), and Utils::Matrix< T, Rows, Cols >::operator()().

◆ data() [1/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr pointer Utils::Matrix< T, Rows, Cols >::data ( )
inlineconstexpr

Access to the underlying data pointer (non const).

Returns
Pointer to first element of the data.

Definition at line 121 of file matrix.hpp.

References Utils::Array< T, N >::data(), and Utils::Matrix< T, Rows, Cols >::m_data.

◆ data() [2/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr const_pointer Utils::Matrix< T, Rows, Cols >::data ( ) const
inlineconstexprnoexcept

Access to the underlying data pointer (non const).

Returns
Pointer to first element of the data.

Definition at line 126 of file matrix.hpp.

References Utils::Array< T, N >::data(), and Utils::Matrix< T, Rows, Cols >::m_data.

◆ diagonal()

template<typename T , std::size_t Rows, std::size_t Cols>
Vector< T, Cols > Utils::Matrix< T, Rows, Cols >::diagonal ( ) const
inline

Retrieve the diagonal.

Returns
Vector containing the diagonal elements of the matrix.

Definition at line 171 of file matrix.hpp.

Referenced by Utils::Matrix< T, Rows, Cols >::trace().

◆ end() [1/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr const_iterator Utils::Matrix< T, Rows, Cols >::end ( ) const
inlineconstexprnoexcept

Iterator access (non const).

Returns
Returns an iterator to the element following the last element of the matrix.

Definition at line 148 of file matrix.hpp.

References Utils::Array< T, N >::end(), and Utils::Matrix< T, Rows, Cols >::m_data.

◆ end() [2/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr iterator Utils::Matrix< T, Rows, Cols >::end ( )
inlineconstexprnoexcept

Iterator access (non const).

Returns
Returns an iterator to the element following the last element of the matrix.

Definition at line 142 of file matrix.hpp.

References Utils::Array< T, N >::end(), and Utils::Matrix< T, Rows, Cols >::m_data.

Referenced by Utils::flatten().

◆ inversed()

template<typename T , std::size_t Rows, std::size_t Cols>
Matrix< T, Rows, Cols > Utils::Matrix< T, Rows, Cols >::inversed ( ) const
inline

Retrieve an inverted copy of the matrix.

Returns
Inverted matrix.

Definition at line 197 of file matrix.hpp.

◆ operator()() [1/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr reference Utils::Matrix< T, Rows, Cols >::operator() ( std::size_t  row,
std::size_t  col 
)
inlineconstexpr

Element access (non const).

Parameters
rowThe row used for access.
colThe column used for access.
Returns
The matrix element at row row and column col.

Definition at line 111 of file matrix.hpp.

References Utils::Matrix< T, Rows, Cols >::col(), Utils::Matrix< T, Rows, Cols >::m_data, and Utils::Matrix< T, Rows, Cols >::row().

◆ operator()() [2/2]

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr value_type Utils::Matrix< T, Rows, Cols >::operator() ( std::size_t  row,
std::size_t  col 
) const
inlineconstexpr

Element access (const).

Parameters
rowThe row used for access.
colThe column used for access.
Returns
The matrix element at row row and column col.

Definition at line 100 of file matrix.hpp.

References Utils::Matrix< T, Rows, Cols >::col(), Utils::Matrix< T, Rows, Cols >::m_data, and Utils::Matrix< T, Rows, Cols >::row().

◆ row()

template<typename T , std::size_t Rows, std::size_t Cols>
template<std::size_t R>
Vector< T, Cols > Utils::Matrix< T, Rows, Cols >::row ( ) const
inline

Retrieve an entire matrix row.

Template Parameters
RThe row index.
Returns
A vector containing the elements of row R.

Definition at line 154 of file matrix.hpp.

Referenced by Utils::Matrix< T, Rows, Cols >::operator()(), and Utils::Matrix< T, Rows, Cols >::operator()().

◆ shape()

template<typename T , std::size_t Rows, std::size_t Cols>
constexpr std::pair< std::size_t, std::size_t > Utils::Matrix< T, Rows, Cols >::shape ( ) const
inlineconstexprnoexcept

Retrieve the shape of the matrix.

Returns
Pair containing number of rows and number of columns of the matrix.

Definition at line 206 of file matrix.hpp.

◆ trace()

template<typename T , std::size_t Rows, std::size_t Cols>
T Utils::Matrix< T, Rows, Cols >::trace ( ) const
inline

Retrieve the trace.

Returns
Vector containing the sum of diagonal matrix elements.

Definition at line 180 of file matrix.hpp.

References Utils::Matrix< T, Rows, Cols >::diagonal().

◆ transposed()

template<typename T , std::size_t Rows, std::size_t Cols>
Matrix< T, Cols, Rows > Utils::Matrix< T, Rows, Cols >::transposed ( ) const
inline

Retrieve a transposed copy of the matrix.

Returns
Transposed matrix.

Definition at line 189 of file matrix.hpp.

Referenced by Utils::basis_change(), and convert_body_to_space().

Friends And Related Symbol Documentation

◆ boost::serialization::access

template<typename T , std::size_t Rows, std::size_t Cols>
friend class boost::serialization::access
friend

Definition at line 78 of file matrix.hpp.

Member Data Documentation

◆ m_data


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