qualpal 2.3.0
Loading...
Searching...
No Matches
qualpal::FixedMatrix< T, rows, cols > Class Template Reference

Fixed-size matrix class with compile-time dimensions. More...

#include <matrix.h>

Public Member Functions

constexpr FixedMatrix ()
 Default constructor - elements are zero-initialized.
 
constexpr FixedMatrix (std::initializer_list< std::initializer_list< T > > list)
 Construct from nested initializer list.
 
constexpr FixedMatrix< T, cols, rows > t () const
 Create transpose of this matrix.
 
constexpr T & operator() (std::size_t row, std::size_t col)
 Access matrix element (mutable)
 
constexpr const T & operator() (std::size_t row, std::size_t col) const
 Access matrix element (const)
 
constexpr FixedMatrix< T, rows, cols > operator* (const T &scalar) const
 Scalar multiplication.
 
constexpr std::array< T, rows > operator* (const std::array< T, cols > &vec) const
 Matrix-vector multiplication.
 
template<std::size_t other_cols>
constexpr FixedMatrix< T, rows, other_cols > operator* (const FixedMatrix< T, cols, other_cols > &other) const
 Matrix-matrix multiplication (FixedMatrix * FixedMatrix)
 
constexpr Matrix< T > operator* (const Matrix< T > &other) const
 Matrix-matrix multiplication (FixedMatrix * dynamic Matrix)
 
constexpr FixedMatrix< T, rows, cols > operator+ (const FixedMatrix< T, rows, cols > &other) const
 Matrix addition.
 
constexpr FixedMatrix< T, rows, cols > operator- (const FixedMatrix< T, rows, cols > &other) const
 Matrix subtraction.
 
constexpr void fill (const T &value)
 Fill all elements with specified value.
 
constexpr void zeros ()
 Set all elements to zero.
 

Detailed Description

template<typename T, std::size_t rows, std::size_t cols>
class qualpal::FixedMatrix< T, rows, cols >

Fixed-size matrix class with compile-time dimensions.

Template Parameters
TElement type (typically double or float)
rowsNumber of rows (compile-time constant)
colsNumber of columns (compile-time constant)

Definition at line 116 of file matrix.h.

Constructor & Destructor Documentation

◆ FixedMatrix() [1/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr qualpal::FixedMatrix< T, rows, cols >::FixedMatrix ( )
inlineconstexpr

Default constructor - elements are zero-initialized.

Definition at line 120 of file matrix.h.

◆ FixedMatrix() [2/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr qualpal::FixedMatrix< T, rows, cols >::FixedMatrix ( std::initializer_list< std::initializer_list< T > >  list)
inlineconstexpr

Construct from nested initializer list.

Parameters
listNested initializer list of matrix elements

Definition at line 129 of file matrix.h.

Member Function Documentation

◆ fill()

template<typename T , std::size_t rows, std::size_t cols>
constexpr void qualpal::FixedMatrix< T, rows, cols >::fill ( const T &  value)
inlineconstexpr

Fill all elements with specified value.

Definition at line 280 of file matrix.h.

◆ operator()() [1/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr T & qualpal::FixedMatrix< T, rows, cols >::operator() ( std::size_t  row,
std::size_t  col 
)
inlineconstexpr

Access matrix element (mutable)

Parameters
rowRow index
colColumn index
Returns
Reference to element at (row, col)

Definition at line 162 of file matrix.h.

◆ operator()() [2/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr const T & qualpal::FixedMatrix< T, rows, cols >::operator() ( std::size_t  row,
std::size_t  col 
) const
inlineconstexpr

Access matrix element (const)

Parameters
rowRow index
colColumn index
Returns
Const reference to element at (row, col)

Definition at line 173 of file matrix.h.

◆ operator*() [1/4]

template<typename T , std::size_t rows, std::size_t cols>
template<std::size_t other_cols>
constexpr FixedMatrix< T, rows, other_cols > qualpal::FixedMatrix< T, rows, cols >::operator* ( const FixedMatrix< T, cols, other_cols > &  other) const
inlineconstexpr

Matrix-matrix multiplication (FixedMatrix * FixedMatrix)

Template Parameters
other_colsNumber of columns in the other matrix
Parameters
otherThe matrix to multiply with
Returns
Result matrix with dimensions (rows × other_cols)

Definition at line 215 of file matrix.h.

◆ operator*() [2/4]

template<typename T , std::size_t rows, std::size_t cols>
constexpr Matrix< T > qualpal::FixedMatrix< T, rows, cols >::operator* ( const Matrix< T > &  other) const
inlineconstexpr

Matrix-matrix multiplication (FixedMatrix * dynamic Matrix)

Parameters
otherDynamic matrix to multiply with
Returns
Result as dynamic Matrix

Definition at line 235 of file matrix.h.

◆ operator*() [3/4]

template<typename T , std::size_t rows, std::size_t cols>
constexpr std::array< T, rows > qualpal::FixedMatrix< T, rows, cols >::operator* ( const std::array< T, cols > &  vec) const
inlineconstexpr

Matrix-vector multiplication.

Parameters
vecVector to multiply with (must have 'cols' elements)
Returns
Result vector with 'rows' elements

Definition at line 197 of file matrix.h.

◆ operator*() [4/4]

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, rows, cols > qualpal::FixedMatrix< T, rows, cols >::operator* ( const T &  scalar) const
inlineconstexpr

Scalar multiplication.

Parameters
scalarValue to multiply all elements by
Returns
New matrix with all elements multiplied by scalar

Definition at line 183 of file matrix.h.

◆ operator+()

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, rows, cols > qualpal::FixedMatrix< T, rows, cols >::operator+ ( const FixedMatrix< T, rows, cols > &  other) const
inlineconstexpr

Matrix addition.

Parameters
otherMatrix to add (must have same dimensions)
Returns
New matrix containing element-wise sum

Definition at line 254 of file matrix.h.

◆ operator-()

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, rows, cols > qualpal::FixedMatrix< T, rows, cols >::operator- ( const FixedMatrix< T, rows, cols > &  other) const
inlineconstexpr

Matrix subtraction.

Parameters
otherMatrix to subtract (must have same dimensions)
Returns
New matrix containing element-wise difference

Definition at line 269 of file matrix.h.

◆ t()

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, cols, rows > qualpal::FixedMatrix< T, rows, cols >::t ( ) const
inlineconstexpr

Create transpose of this matrix.

Returns
New FixedMatrix that is the transpose of this matrix

Definition at line 145 of file matrix.h.

◆ zeros()

template<typename T , std::size_t rows, std::size_t cols>
constexpr void qualpal::FixedMatrix< T, rows, cols >::zeros ( )
inlineconstexpr

Set all elements to zero.

Definition at line 283 of file matrix.h.


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