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 = container::pointer
using const_pointer = container::const_pointer
using iterator = container::iterator
using const_iterator = container::const_iterator
using value_type = container::value_type
using reference = container::reference
using const_reference = 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.
T 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.
auto flatten () const noexcept

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 68 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 = container::const_iterator

Definition at line 73 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 = container::const_pointer

Definition at line 71 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 = container::const_reference

Definition at line 76 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 69 of file matrix.hpp.

◆ iterator

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

Definition at line 72 of file matrix.hpp.

◆ pointer

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

Definition at line 70 of file matrix.hpp.

◆ reference

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

Definition at line 75 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 = container::value_type

Definition at line 74 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 88 of file matrix.hpp.

◆ 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 92 of file matrix.hpp.

Member Function Documentation

◆ begin() [1/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 139 of file matrix.hpp.

◆ begin() [2/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 134 of file matrix.hpp.

Referenced by Utils::Matrix< T, codim, 3 >::Matrix(), and Utils::Matrix< T, codim, 3 >::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 166 of file matrix.hpp.

◆ data() [1/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 124 of file matrix.hpp.

◆ data() [2/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 129 of file matrix.hpp.

◆ 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 174 of file matrix.hpp.

Referenced by Utils::Matrix< T, codim, 3 >::trace().

◆ end() [1/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 151 of file matrix.hpp.

◆ end() [2/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 145 of file matrix.hpp.

◆ flatten()

template<typename T, std::size_t Rows, std::size_t Cols>
auto Utils::Matrix< T, Rows, Cols >::flatten ( ) const
inlinenoexcept

Definition at line 213 of file matrix.hpp.

◆ 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 200 of file matrix.hpp.

◆ operator()() [1/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 114 of file matrix.hpp.

◆ operator()() [2/2]

template<typename T, std::size_t Rows, std::size_t Cols>
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 103 of file matrix.hpp.

◆ 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 157 of file matrix.hpp.

◆ shape()

template<typename T, std::size_t Rows, std::size_t Cols>
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 209 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 183 of file matrix.hpp.

◆ 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 192 of file matrix.hpp.

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

◆ boost::serialization::access

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

Definition at line 81 of file matrix.hpp.

Member Data Documentation

◆ m_data

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

Definition at line 78 of file matrix.hpp.


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